# Import agent procedures

Extract up to ten free-form procedures from a supported SOP file.

## Endpoint

`POST /api/v1/workspaces/{workspace_id}/agents/{agent_id}/procedures/import`

## Authentication

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

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `workspace_id` | path | `string` | Yes | — |
| `agent_id` | path | `string` | Yes | — |
| `branch_id` | query | `string or null` | No | — |

## Request body

### multipart/form-data request schema

| Field path | Type | Reference | Format | Nullable | Required | Enum | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `$` | `object` | Body_importAgentProcedures | — | No | Yes | — | — |
| `file` | `string` | — | — | No | Yes | — | — |

## Example

```bash
curl --request POST 'https://operade.ai/api/v1/workspaces/ws_demo/agents/agt_demo/procedures/import' \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --form 'file=@./example-sop.txt'
```

## Responses

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

### 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` | ProcedureImportResponse | — | No | Yes | — | — |
| `items` | `array<FreeFormProcedure>` | — | — | No | Yes | — | — |
| `items[]` | `object` | FreeFormProcedure | — | No | Yes | — | — |
| `items[].content` | `string` | — | — | No | Yes | — | — |
| `items[].guardrails` | `array<CustomGuardrail>` | — | — | No | No | — | — |
| `items[].guardrails[]` | `object` | CustomGuardrail | — | No | Yes | — | — |
| `items[].guardrails[].execution_mode` | `string` | — | — | No | No | "streaming", "blocking" | — |
| `items[].guardrails[].history_message_count` | `integer` | — | — | No | No | — | — |
| `items[].guardrails[].id` | `string` | — | — | No | Yes | — | — |
| `items[].guardrails[].is_enabled` | `boolean` | — | — | No | No | — | — |
| `items[].guardrails[].model` | `string` | — | — | No | No | — | — |
| `items[].guardrails[].name` | `string` | — | — | No | No | — | — |
| `items[].guardrails[].prompt` | `string` | — | — | No | No | — | — |
| `items[].guardrails[].trigger_action` | `object` | TriggerAction | — | No | No | — | — |
| `items[].guardrails[].trigger_action.feedback` | `string` | — | — | No | No | — | — |
| `items[].guardrails[].trigger_action.type` | `string` | — | — | No | No | "end_call", "retry" | — |
| `items[].id` | `string` | — | — | No | Yes | — | — |
| `items[].name` | `string` | — | — | No | Yes | — | — |
| `items[].trigger` | `string` | — | — | No | Yes | — | — |
| `items[].type` | `string` | — | — | No | No | "free_form" | — |

### Response example

```json
{
  "items": []
}
```

## 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` | The authenticated caller does not have access to this operation. |
| 404 | `not_found` | The requested workspace resource was not found. |
| 422 | `validation_failed` | The request did not pass field or business validation. |
| 403 | `workspace_not_activated` | The workspace is not active for model-backed configuration work. |

## Related operations

No related operations in this resource group.
