# Assign or unassign a person on a task

```http
PUT https://secure.yoprint.com/v2/api/store/{team_slug}/v2/work_pipeline/{hash_id}/assign
```

- API version: v2
- Operation ID: `v2_public_job_work_pipeline_assign`
- Section: Production › [Tasks](https://developer.yoprint.com/reference/tasks.md)
- Web page: https://developer.yoprint.com/reference/tasks/v2-job-work-pipeline-assign/
- Authentication: `Authorization: Bearer YOUR_API_KEY`

Adds one team member to a task, or removes one. Returns the task's assignees after the change (people who have left the team are left out).

## Permission

Any member of the team may assign or unassign anyone on the team.

## Business rules

- Assigning someone already assigned, or unassigning someone who isn't, changes nothing and succeeds.

## Side effects

- No email or notification is sent.

## Path parameters

- `team_slug` (string, required): Your team slug, shown as Team ID next to your API key in Profile. Example `your-team`.
- `hash_id` (string, required): The task's hash id. Hash ids only: a unique key or a document number gives 404. Example `hpioY1gDBQZdbI`.

## Request body

Content type `application/json`, required.

Fields:

- `action` (string, required): One of: `"assign"`, `"unassign"`.
- `user_id` (string, required): A member of your team (from List users).

### Example request

```bash
curl -X PUT 'https://secure.yoprint.com/v2/api/store/your-team/v2/work_pipeline/hpioY1gDBQZdbI/assign' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Accept: application/json' \
  -H 'X-Yoprint-Decimal-Format: exact-v1' \
  -H 'Content-Type: application/json' \
  -d '{
    "action": "assign",
    "user_id": "4mdDkMg3dgQOa3"
  }'
```

## Response

`200` Successful response.

Fields:

- `data` (array of objects, required): The task's assignees after the change.
  - Each item:
    - `avatar_url` (string | null, optional)
    - `email` (string, optional)
    - `id` (string, optional): The user.
    - `name` (string, optional)
    - `timezone` (string | null, optional)
- `status` (integer, required)
- `success` (boolean, required)

Example response:

```json
{
  "data": [
    {
      "avatar_url": null,
      "email": "alex@example.com",
      "id": "4mdDkMg3dgQOa3",
      "name": "Alex Rivera",
      "timezone": "America/Chicago"
    }
  ],
  "status": 200,
  "success": true
}
```

## Errors

- `401` The API key is missing or wrong (`unauthenticated`).
- `403` You are not allowed to do this. `api_access_not_in_plan`: your team's plan doesn't include API access (Pro and above, with an active subscription or trial), so every request answers this until the team upgrades. When your role lacks the permission the operation needs, the body is only `{"message": "Insufficient Permission"}`. Other refusals use the error envelope, with `unauthorized` or `user_is_not_authorized`.
- `404` Not found. `page_not_found`: the team slug is unknown, you are not a member of the team, or an id in the path is not one of this team's. `code: null`, with a message that starts "No query results for": there is no record with that id.
  - When: The user isn't on your team, or the task isn't your team's. Fix: Use ids from List users and the task list.
- `422` The request was refused and changed nothing. `validation_failed` lists what to fix in `error.fields`; other codes name a business rule, explained in `error.message`. A few checks answer with only `{"message": "..."}`. An operation that calls another service (a payment provider, a carrier, an accounting app) can answer `connect_timeout` ("Please retry again") when that service does not answer in time: the change may or may not have happened there, so read the record back before you retry.
  - When: `action` isn't `assign` or `unassign`, or `user_id` is missing. Fix: Send both fields.

## Related

- [List team members](https://developer.yoprint.com/reference/team-members/v1-user-index.md): `GET /v1/api/store/{team_slug}/setting/user`
- [Update a task](https://developer.yoprint.com/reference/tasks/v2-job-work-pipeline-update.md): `PUT /v2/api/store/{team_slug}/v2/work_pipeline/{hash_id}`
