# Add collaborators

This API is used to add  collaborators for a task. Multiple collaborators can be added by one request. Only the creator and collaborator of the task can add executors, and followers do not have permission to add them.

## Request

Facts | &nbsp;
---|---
HTTP URL | https://open.feishu.cn/open-apis/task/v1/tasks/:task_id/collaborators
HTTP Method | POST
Rate Limit | [100 per minute](https://open.feishu.cn/document/ukTMukTMukTM/uUzN04SN3QjL1cDN)
Supported app types | Custom App、Store App
Required scopes<br>**To use this API, you must have at least 1 of the listed scopes.** | View, create, update, and delete Task (legacy version)(task:task)
Required field scopes | **Notice**：The response body of the API contains the following sensitive fields, and they will be returned only after corresponding scopes are added. If you do not need the fields, it is not recommended that you request the scopes.<br>Obtain user ID(contact:user.employee_id:readonly)

### Request header

Parameter | Type | Required | Description
---|---|---|---
Authorization | string | Yes | `tenant_access_token`<br>or<br>`user_access_token`<br>**Value format**: "Bearer `access_token`"<br>**Example value**: "Bearer u-7f1bcd13fc57d46bac21793a18e560"<br>[How to choose and get access token](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-choose-which-type-of-token-to-use)
Content-Type | string | Yes | **Fixed value**: "application/json; charset=utf-8"

### Path parameters

Parameter | Type | Description
---|---|---
task_id | string | The task ID, which can be obtained from the id field in the response body [when the task is created](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/task-v1/task/create)<br>**Example value**: "83912691-2e43-47fc-94a4-d512e03984fa"

### Query parameters

Parameter | Type | Required | Description
---|---|---|---
user_id_type | string | No | User ID categories<br>**Example value**: open_id<br>**Optional values are**:<br>- open_id：Identifies a user to an app. The same user has different Open IDs in different apps. [How to get Open ID](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-obtain-openid)<br>- union_id：Identifies a user to a tenant that acts as a developer. A user has the same Union ID in apps developed by the same developer, and has different Union IDs in apps developed by different developers. A developer can use Union ID to link the same user's identities in multiple apps.[How to get Union ID](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-obtain-union-id)<br>- user_id：Identifies a user to a tenant. The same user has different User IDs in different tenants. In one single tenant, a user has the same User ID in all apps （including store apps）. User ID is usually used to communicate user data between different apps. [How to get User ID](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-obtain-user-id)<br>**Default value**: `open_id`<br>**When the value is `user_id`, the following field scopes are required**:<br>Obtain user ID(contact:user.employee_id:readonly)

### Request body

Parameter | Type | Required | Description
---|---|---|---
id | string | No | The ID of the task collaborator. The value passed in is user_id or open_id, determined by user_id_type. For details, see: [How to get ID](https://open.feishu.cn/document/home/user-identity-introduction/open-id)<br>**Notice**：**Example value**: "ou_99e1a581b36ecc4862cbfbce473f1234"
id_list | string\[\] | No | List of collaborator ids added when creating the task. The value passed in is user_id or open_id, determined by user_id_type. For details, see: [How to get ID](https://open.feishu.cn/document/home/user-identity-introduction/open-id)<br>**Example value**: ["ou_99e1a581b36ecc4862cbfbce473f1234"]

### Request body example
```json
{
    "id": "ou_99e1a581b36ecc4862cbfbce473f1234",
    "id_list": [
        "ou_99e1a581b36ecc4862cbfbce473f1234"
    ]
}
```

## Response

### Response body

Parameter | Type | Description
---|---|---
code | int | Error codes, fail if not zero
msg | string | Error descriptions
data | \- | \-
collaborator | collaborator | Returns the added task collaborator.
id | string | The ID of the task collaborator. The value passed in is user_id or open_id, determined by user_id_type. For details, see: [How to get ID](https://open.feishu.cn/document/home/user-identity-introduction/open-id)<br><md-alert><br>Deprecated, reserved for forward compatibility in the early days when only one person was added at a time, but it is no longer recommended, it is recommended to use the id_list field
id_list | string\[\] | List of collaborator ids added when creating the task. The value passed in is user_id or open_id, determined by user_id_type. For details, see: [How to get ID](https://open.feishu.cn/document/home/user-identity-introduction/open-id)

### Response body example
```json
{
    "code": 0,
    "msg": "success",
    "data": {
        "collaborator": {
            "id": "ou_99e1a581b36ecc4862cbfbce473f1234",
            "id_list": [
                "ou_99e1a581b36ecc4862cbfbce473f1234"
            ]
        }
    }
}
```

### Error code

HTTP status code | Error code | Description | Troubleshooting suggestions
---|---|---|---
401 | 1470403 | The identity token is incorrect. It should be either user_access_token or tenant_access_token. | The identity token is incorrect. It should be either user_access_token or tenant_access_token.
400 | 1470404 | Be refused to update task, possibly due to lack of permission. | Generally, the creation or update task fails because the operator does not have operation permission. For example, the task follower has no permission to modify the task.
400 | 1470429 | The total number of collaborators exceeds the maximum number limit. | The total number of executors exceeds the maximum number limit. Currently, only 50 people can be added to a task
400 | 1470431 | Users are all collaborators of tasks. | The user is already collaborator of the task and cannot be added repeatedly
429 | 1470450 | There are too many requests currently, please try again later. | There are too many requests currently initiated at the same time, and the peak value is high, resulting in current limit, please try again later.
400 | 1470451 | Operation requests for the same task are too frequent. | The operation request for the same task is too frequent, and the request frequency needs to be reduced
400 | 1470602 | Invalid task id. | Check whether the task ID is valid.
500 | 1470701 | Failed to add task collaborator. | Failed to add the collaborator for the task. If retrying cannot solve the problem, please contact Feishu technicians to assist in troubleshooting.

