# Update agent deployments

Replace the agent's branch traffic distribution with percentages totaling 100.

## Endpoint

`PUT /api/v1/workspaces/{workspace_id}/agents/{agent_id}/deployments`

## Authentication

| Class | Authentication | Minimum role | API key |
| --- | --- | --- | --- |
| customer-api | Bearer API key or dashboard session cookie; dashboard mutations also require X-CX-Request: 1. | admin | Allowed |

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `workspace_id` | path | `string` | Yes | — |
| `agent_id` | path | `string` | Yes | — |

## Request body

### application/json request schema

| Field path | Type | Reference | Format | Nullable | Required | Enum | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `$` | `object` | PermintaanDeployment | — | No | Yes | — | — |
| `branches` | `array<BobotDeployment>` | — | — | No | Yes | — | — |
| `branches[]` | `object` | BobotDeployment | — | No | Yes | — | — |
| `branches[].branch_id` | `string` | — | — | No | Yes | — | — |
| `branches[].percentage` | `number or string` | — | — | No | Yes | — | — |

## Example

```bash
curl --request PUT 'https://operade.ai/api/v1/workspaces/ws_demo/agents/agt_demo/deployments' \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{"branches":[{"branch_id":"br_main","percentage":"100.00"}]}'
```

## Responses

| Status | Description | Content |
| --- | --- | --- |
| 4XX | Handled client error | application/json: `ErrorResponse` |
| 200 | Successful Response | application/json: `DeploymentMutationResponse` |

### 4XX application/json response schema

| Field path | Type | Reference | Format | Nullable | Required | Enum | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `$` | `object` | ErrorResponse | — | No | Yes | — | — |
| `error` | `object` | ErrorItem | — | No | Yes | — | — |
| `error.code` | `string` | — | — | No | Yes | — | — |
| `error.details` | `object` | — | — | No | No | — | — |
| `error.message` | `string` | — | — | No | Yes | — | — |

### 200 application/json response schema

| Field path | Type | Reference | Format | Nullable | Required | Enum | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `$` | `object` | DeploymentMutationResponse | — | No | Yes | — | — |
| `changed` | `boolean` | — | — | No | Yes | — | — |
| `deployment_id` | `string or null` | — | — | Yes | Yes | — | — |
| `distribution` | `array<TrafficAllocation>` | — | — | No | Yes | — | — |
| `distribution[]` | `object` | TrafficAllocation | — | No | Yes | — | — |
| `distribution[].basis_points` | `integer` | — | — | No | Yes | — | — |
| `distribution[].branch_id` | `string` | — | — | No | Yes | — | — |
| `distribution[].percentage` | `string` | — | — | No | Yes | — | — |

### Response example

```json
{
  "changed": false,
  "deployment_id": "string",
  "distribution": []
}
```

## Errors

Reviewed common and route-declared errors are summarized here; the list is not exhaustive. Start with the [distributed error index](/docs/reference/api/errors) to find each code's canonical domain page.

| Status | Code | Description |
| --- | --- | --- |
| 401 | `unauthenticated` | Authentication is missing, invalid, or revoked. |
| 403 | `forbidden` | Only an admin or owner can deploy branch traffic. |
| 404 | `not_found` | The requested workspace resource was not found. |
| 422 | `deployment_invalid` | The requested distribution has invalid percentages, duplicate branches, unknown branches, or an active traffic total other than 100 percent. |
| 409 | `deployment_branch_archived` | Restore archived branches before deploying traffic to them. |
| 409 | `deployment_stale` | A selected live branch has no published version or is no longer ready for production traffic. |

## Related operations

- [List agent deployments](/docs/api-reference/deployments/list-agent-deployments) — `GET /api/v1/workspaces/{workspace_id}/agents/{agent_id}/deployments`
