> For the complete documentation index, see [llms.txt](https://relationlabs.gitbook.io/relation-one-api/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://relationlabs.gitbook.io/relation-one-api/api-zh/api/channel/create.md).

# 创建

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

* 说明：如何创建一个群组。我们把群组分成普通群组和点对点聊天群组。其中，普通群组有管理员，可以添加成员。点对点聊天的群成员只有两个人，不能添加、移除成员。
* Header

| Field         | Type   | Remarks                                                            |
| ------------- | ------ | ------------------------------------------------------------------ |
| ApiKey        | String | 从管理员获取的[ApiKey](/relation-one-api/api-zh/guide/glossary.md#apikey) |
| Authorization | String | Bearer ${unifiedAuthToken} ,其中unifiedAuthToken来自/api/v1/auth接口的返回  |

* Request Parameters

| Field   | Type           | Remarks                                                  |
| ------- | -------------- | -------------------------------------------------------- |
| name    | String         | 群组名称                                                     |
| type    | String         | 群组类型,当前枚举值： G-普通群组，P-p2p聊天群组                             |
| members | Array\[String] | 群成员的relationId集合。如果type=P，则只会将调用者和首个用户作为群聊成员。群管理员为当前调用者。 |

* 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                | 返回码     |
| desc  | String                | 返回信息    |
| data  | CreateChannelResponse | 数据      |

The CreateChannelResponse field consists of the following subfields:

| Field       | Type   | Remarks |
| ----------- | ------ | ------- |
| channelUuid | String | 群组的uuid |

* Response Body

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

* Return Code

| code  | desc             | Remarks  |
| ----- | ---------------- | -------- |
| 0     | success          | 接口调用成功   |
| 13101 | group type error | 群组类型无法识别 |
