# Create

## <mark style="color:green;">POST</mark> api/v1/channel/create

* Note: This is to creat a group chat. There are two group types: regular and peer-to-peer. With a regular group chat, there can exist an admin and multiple members. With a peer-to-peer group chat, there exists only two members, and you cannot add or remove members.
* Header

| Field         | Type   | Remarks                                                                                |
| ------------- | ------ | -------------------------------------------------------------------------------------- |
| ApiKey        | String | [ApiKey](/relation-one-api/guide/glossary.md#apikey) acquired from the admin           |
| Authorization | String | Bearer ${unifiedAuthToken} , in which the unifiedAuthToken is returned by /api/v1/auth |

* Request Parameters

| Field   | Type           | Remarks                                                                                                                                                                               |
| ------- | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| name    | String         | name of the group chat                                                                                                                                                                |
| type    | String         | Group Chat Type, enumerated as: G-Regular Group Chat, P-p2p Group Chat                                                                                                                |
| members | Array\[String] | The collection of group members' relationId. If type=P, then it will only see the caller and the first user as group chat members. The admin of the group chat is the current caller. |

* Request Example

```shell
curl POST 'https://api.relationlabs.ai/api/v1/channel/create' \
--header 'ApiKey: <ApiKey>' \
--header 'Authorization: bearer eyJhbGciOiJFUzI1Ni19.eyJqdGkiOiI0MzdiN2EzZDEwMGY0ODVkOWVhMWUzZmZlOWE1NmEyZSIsImlz1cyI6InJlbGF0aW9ubGFicy5haSIsImlhdCI6MTY2NTIxNTUzNSwic3ViIjoiZGhreXEtc3FhYWEtYWFhYWotc2d6M3EtY2FpIiwiZXhwIjoxNjY1ODIwMzM1fQ.rj7KKuIcgmvaIwZ63YHnXQ4jvvI-eR2Wo7k3YEyzMuxo8j5ezCowKDpcW0u9zI1uHPFqwD0-1XPWdPLR1d1HLFw' \
--header 'Content-Type: application/json' \
--data-raw '{
  "members": [
    "dhkyq-sqaaa-aaaaj-sgz3q-cai","qddyo-3aaaa-aaaaj-allxa-cai"
  ],
  "name": "test-group",
  "type": "G"
}'
```

* Response Parameters

| Field | Type                  | Remarks            |
| ----- | --------------------- | ------------------ |
| code  | String                | the Return Code    |
| desc  | String                | the Return Message |
| data  | CreateChannelResponse | the data           |

The CreateChannelResponse field consists of the following subfields:

| Field       | Type   | Remarks                    |
| ----------- | ------ | -------------------------- |
| channelUuid | String | the uuid of the group chat |

* Response Body

```json
{
    "code": "0",
    "desc": "success",
    "data": {
        "channelUuid": "4f326124812c41448bc587bf6b2eaf42"
    }
}
```

* Return Code

| code  | desc             | Remarks                           |
| ----- | ---------------- | --------------------------------- |
| 0     | success          | the flag for a successful request |
| 13101 | group type error | Cannot recognize the group type   |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://relationlabs.gitbook.io/relation-one-api/api/channel/create.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
