> ## Documentation Index
> Fetch the complete documentation index at: https://koreai.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Assign Agent API

<Badge icon="arrow-left" color="gray">[Back to API List](/ai-for-service/apis/quality-ai/api-list)</Badge>

Assigns one or more agents to one or more Quality AI queues in bulk.

| **Method** | POST |
| - | - |
| **Endpoint** | `https://{{host}}/qualityai/api/v1/public/{{streamId}}/qm/queues/agent-mapping` |
| **Content-Type** | `application/json` |
| **Authorization** | `auth: {{JWT_TOKEN}}` See [How to generate the JWT Token](/ai-for-service/apis/automation/api-introduction#generating-the-jwt-token). |
| **API Scope** | SmartAssist Analytics |

## Path Parameters

| Parameter | Description | Type |
| - | - | - |
| `host` | Environment URL. For example, `https://platform.kore.ai` | String, required |
| `streamId` | Unique identifier of the stream. | String, required |

## Header Parameters

| Parameter | Description | Type |
| - | - | - |
| `auth` | Authentication token used to authorize the request. | String, required |
| `accountId` | Unique account identifier. | String, required |
| `iid` | Unique Stream identifier. | String, required |

## Sample Request

```bash expandable=true theme={null}
curl --location --request POST 'https://{{host}}/qualityai/api/v1/public/{{streamId}}/qm/queues/agent-mapping' \
--header 'auth: {{JWT_TOKEN}}' \
--header 'Content-Type: application/json' \
--header 'iId: {{streamId}}' \
--header 'accountId: {{accountId}}' \
--data-raw '{
"action": "assign",
"mode": "append",
"mappings": [
{ "customQueueId": "RETAIL_L1",
"agentEmails": ["john.doe@example.com", "john.smith@example.com"] }
]
}'
```

## Request Body Parameters

|| Field                      | Type          | Required | Description                                                            |
\| -------------------------- | ------------- | -------- | ---------------------------------------------------------------------- |
\| `action`                   | String        | Yes      | Specifies the mapping operation to perform. Supported value: `assign` or `unassign`. |
\| `mode`                 | String        | Yes      | Processing mode used for the request. |
\| `mappings`                 | Array | Yes      | List of queue-to-agent mapping objects.                                |
\| `customQueueId` | String        | Yes      | Unique identifier of the queue to which agents are assigned.           |
\| `agentEmails`   | Array | Yes      | List of agent email addresses to assign to the specified queue.        |

## Sample Response

```json expandable=true theme={null}
{
  "jobId": "qjb-ac15b9d********-873e-d3f3abb5d206",
  "status": "queued",
  "type": "AGENT_MAPPING",
  "action": "assign",
  "mode": "append",
  "total": 2,
  "accepted": 2,
  "rejected": 0,
  "statusUrl": "/api/v1/public/st-606d6d99-1e25-5fc3-********e5e9afa33f/qm/queues/jobs/qjb-ac15b9d3-a6e6-52dd-87*********5d206",
  "rejectedItems": []
}
```

## Response Body Parameters

| Field | Type | Description |
| - | - | - |
| `jobId` | String | Unique identifier of the queue management job. |
| `status` | String | Current status of the job. Possible values include `queued`, `inProgress`, `completed`, or `failed`. |
| `type` | String | Type of queue management operation being processed. |
| `action` | String | Action performed by the job, such as assigning or removing mappings. |
| `mode` | String | Processing mode used for the request. |
| `total` | Integer | Total number of items submitted in the request. |
| `accepted` | Integer | Number of items accepted for processing. |
| `rejected` | Integer | Number of items rejected during validation. |
| `statusUrl` | String | Relative URL used to retrieve the current job status and results. |
| `rejectedItems` | Array | List of rejected items and their associated validation errors. Empty if no items are rejected. |
