<!-- Generated from the canonical 99 Digital API documentation. Do not edit this file. -->

Canonical page: https://docs.99digital.co.il/online-api/teams/members/replace-team-members

# Replace Team Members

`PATCH https://online.99digital.co.il/api/v1/accounts/{account_id}/teams/{team_id}/team_members`

Sets the team's member list to exactly the agents you send.

The list becomes exactly `user_ids`: missing agents are added, and members not in the list are removed. Returns the full member list
after the change.

| Setting | Value |
| --- | --- |
| **Method** | `PATCH` |
| **Path** | `/api/v1/accounts/{account_id}/teams/{team_id}/team_members` |
| **Authorization** | User token. Legacy: `administrator`. New rules: **Teams → update**. Not available to agent-bot tokens. |

**Path parameters**

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `account_id` | integer | Yes | Account ID. |
| `team_id` | integer | Yes | Team ID. |

**Body parameters (JSON)**

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `user_ids` | integer[] | Yes | The complete list of member IDs. |

**Example request**: the team had members `51` and `53`; after this call it
has `51` and `52`.

```bash
curl -X PATCH 'https://online.99digital.co.il/api/v1/accounts/12/teams/7/team_members' \
  -H 'api_access_token: <YOUR_API_ACCESS_TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '{ "user_ids": [51, 52] }'
```

**Example response** (`200 OK`): an array of agent objects for all current
members (here the agents with `"id": 51` and `"id": 52`).

**Error responses**: `422 {"error": "Invalid User IDs"}`.

## Authentication

`api_access_token` in the header — Your access token. A user token is in the dashboard under **Profile settings → Access Token**, and grants exactly what that agent's role allows. An agent-bot token may call only the endpoints marked for agent bots. See [Getting Started](https://docs.99digital.co.il/online-api/getting-started#authentication).

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `account_id` | path | integer | Yes | The numeric ID of your account: the number after `/app/accounts/` in the dashboard URL. Example: `12`. |
| `team_id` | path | integer | Yes | The numeric ID of the team. Example: `7`. |

## Request body

Content type: `application/json` (required)

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `user_ids` | array of integer | Yes | The complete list of the team's members, as user IDs. Every ID must be an agent of the account. |

### Example (generated from the schema)

```json
{
  "user_ids": [
    51,
    52
  ]
}
```

## Responses

### 200 — All the team's members after the change.

Content type: `application/json`

| Field | Type | Description |
| --- | --- | --- |
| `[].id` | integer | The agent's numeric ID (user ID). |
| `[].account_id` | integer | The numeric ID of the account. |
| `[].availability_status` | string | The availability status of the agent: their live presence, computed from the agent's connection — not only the availability the agent chose (`availability` in Add Agent and Update Agent). One of: `online` — Available — connected, with availability set to online; `busy` — Connected, with availability set to busy; `offline` — Not available — availability set to offline, or not connected. |
| `[].auto_offline` | boolean | Whether the agent's availability is configured to go offline automatically when they are away (when they disconnect). |
| `[].confirmed` | boolean | Whether the agent's account has been validated: `true` once the agent clicked the link in the invitation email they received (confirmed their email). |
| `[].email` | string | The agent's login email address. |
| `[].available_name` | string | The agent's display name. |
| `[].custom_attributes` | object | Free-form attributes (key-value pairs) stored on the agent's membership in this account. |
| `[].name` | string | The agent's full name. |
| `[].role` | string | The agent's role. Legacy roles: whether the agent is an `administrator` or an `agent`. New rules system: the name of the agent's custom role (for example `Shift Manager`). |
| `[].operation_bot` | boolean | `true` for internal operation-bot users. |
| `[].see_all_conversations` | boolean | Whether the agent can see all the conversations in the account. On accounts with the new rules system the role decides this (**Inbox read all conversations** in every inbox). |
| `[].assignable_to_inbox` | array \| null | The IDs of the inboxes in which the agent's role grants **Inbox can be assigned** (the agent may be assigned conversations there), or `null`. |
| `[].new_role` | string \| null | The agent's custom role name, or `null` on accounts with legacy roles. |
| `[].thumbnail` | string | The agent's thumbnail (avatar image) URL, or an empty string. |
| `[].capacity_cap` | integer \| null | The agent's own cap of open tickets for queue routing. `null` means the account default (unlimited). Returned only when the account has the queue management (`queue_management`) feature. |
| `[].two_factor_type` | string \| null | The agent's two-factor authentication method, or `null` when two-factor authentication is disabled. One of: `sms` — Two-factor codes are sent by SMS to `phone1`; `email` — Two-factor codes are sent by email to `email1`; `null` — Two-factor authentication is disabled. |
| `[].phone1` | string \| null | The phone number that receives two-factor codes by SMS. |
| `[].email1` | string \| null | The email address that receives two-factor codes by email. |
| `[].create_time` | integer | When the agent was created (Unix timestamp, in seconds). |

#### Example: Members after the change

The team had agents 51 and 53; now it has 51 and 52.

```json
[
  {
    "id": 51,
    "account_id": 12,
    "availability_status": "online",
    "auto_offline": true,
    "confirmed": true,
    "email": "jane.agent@example.com",
    "available_name": "Jane Agent",
    "custom_attributes": {},
    "name": "Jane Agent",
    "role": "General Manager",
    "operation_bot": false,
    "see_all_conversations": true,
    "assignable_to_inbox": [
      31,
      32,
      33
    ],
    "new_role": "General Manager",
    "thumbnail": "",
    "capacity_cap": null,
    "two_factor_type": "sms",
    "phone1": "+972541234567",
    "email1": null,
    "create_time": 1790000000
  },
  {
    "id": 52,
    "account_id": 12,
    "availability_status": "offline",
    "auto_offline": true,
    "confirmed": true,
    "email": "dana.levi@example.com",
    "available_name": "Dana Levi",
    "custom_attributes": {
      "department": "sales"
    },
    "name": "Dana Levi",
    "role": "Shift Manager",
    "operation_bot": false,
    "see_all_conversations": false,
    "assignable_to_inbox": [
      31,
      32
    ],
    "new_role": "Shift Manager",
    "thumbnail": "",
    "capacity_cap": null,
    "two_factor_type": null,
    "phone1": "+972507654321",
    "email1": null,
    "create_time": 1794470400
  }
]
```

### 401 — The access token is missing or wrong, or its user does not belong to this account.

Content type: `application/json`

| Field | Type | Description |
| --- | --- | --- |
| `error` | string | The error message. |

#### Example: Invalid token

The api_access_token header is missing or wrong.

```json
{
  "error": "Invalid Access Token"
}
```

#### Example: Another account

A valid token, for a user who is not in this account.

```json
{
  "error": "You are not authorized to access this account"
}
```

### 403 — The token's role does not have the permission this endpoint needs, or the endpoint is not open to agent-bot tokens. See [Authorization](https://docs.99digital.co.il/online-api/getting-started#authorization).

Content type: `application/json`

| Field | Type | Description |
| --- | --- | --- |
| `error` | string | The error message. |

#### Example: No permission

The role lacks the permission.

```json
{
  "error": "You are not authorized to do this action"
}
```

#### Example: Agent bot

An agent-bot token on an endpoint that is not open to bots.

```json
{
  "error": "Access to this endpoint is not authorized for bots"
}
```

### 404 — The resource does not exist in this account.

Content type: `application/json`

| Field | Type | Description |
| --- | --- | --- |
| `error` | string | The error message. |

#### Example

```json
{
  "error": "Resource could not be found"
}
```

### 422 — One of the IDs is not an agent of this account.

Content type: `application/json`

| Field | Type | Description |
| --- | --- | --- |
| `error` | string | The error message. |

#### Example

```json
{
  "error": "Invalid User IDs"
}
```
