> ## 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.

# Replace Agent API

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

Replaces one or more agents in 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": "replace",
"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: `replace`. |
\| `mode`                 | String        | Yes      | Mode of action mapping objects.\
\| `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-7c1255a5-41*********7-77cce1d07b0c",
    "status": "queued",
    "type": "AGENT_MAPPING",
    "action": "assign",
    "mode": "replace",
    "total": 2,
    "accepted": 2,
    "rejected": 0,
    "statusUrl": "/api/v1/public/st-606d6d99-1e25-5fc*********e9afa33f/qm/queues/jobs/qjb-7c1255a5-4109***********-77cce1d07b0c",
    "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. |
