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

# Create an agent

> The created agent

### Headers

<ParamField header="Idempotency-Key" type="string">
  Optional client-generated key that makes the POST safe to retry: a repeat with the same key and body replays the original response instead of creating a duplicate.
</ParamField>

### Request body

`CreateAgent`

<ParamField body="name" type="string" required>
  Minimum length: `1`. Maximum length: `200`.
</ParamField>

<ParamField body="type" type="string" required>
  One of: assistant, customer\_service, sales. Minimum length: `1`. Maximum length: `100`.
</ParamField>

<ParamField body="description" type="string">
  Maximum length: `5000`.
</ParamField>

<ParamField body="instructions" type="string">
  The system prompt / persona. Maximum length: `50000`.
</ParamField>

<ParamField body="goal" type="string">
  Maximum length: `2000`.
</ParamField>

<ParamField body="role" type="string">
  Maximum length: `2000`.
</ParamField>

<ParamField body="activated" type="boolean" />

### Response

`Agent`

<ResponseField name="object" type="string">
  Fixed value: `'agent'`.
</ResponseField>

<ResponseField name="id" type="string" />

<ResponseField name="name" type="string,null" />

<ResponseField name="type" type="string,null" />

<ResponseField name="description" type="string,null" />

<ResponseField name="activated" type="boolean" />

<ResponseField name="goal" type="string,null" />

<ResponseField name="role" type="string,null" />

<ResponseField name="updated_at" type="string,null" />

<ResponseField name="instructions" type="string,null">
  Present on single-agent reads and writes only.
</ResponseField>

<ResponseField name="settings" type="AgentSettingsOut">
  <Expandable title="AgentSettingsOut">
    <ResponseField name="object" type="string">
      Fixed value: `'agent.settings'`.
    </ResponseField>

    <ResponseField name="configured" type="boolean">
      False when no settings row exists yet (fields are all null).
    </ResponseField>
  </Expandable>
</ResponseField>

### Status codes

| Code | Meaning |
| - | - |
| `201` | The created agent |
| `400` | Invalid request. `issues` names the offending field(s). |
| `401` | Missing, invalid, or expired API key. |
| `403` | The key lacks a required scope. |
| `409` | Conflict — either the creation ceiling was reached for this organization (`agent_limit_reached`), or a request with the same Idempotency-Key is still in flight (`idempotency_in_progress`); retry the latter after the first attempt settles. |
| `422` | The Idempotency-Key was already used with a DIFFERENT request body (`idempotency_key_reused`). Reuse a key only to retry the identical request. |
| `429` | Rate limit exceeded. |

### Access

| | |
| - | - |
| Required scope | `agents:write` |
| Rate limit | 30 requests per minute |

### Using this contract

Read the [source OpenAPI document](/spec/responsecx.json) for declared schemas and alternatives.
This page also includes documented corrections from the [spec overlays](https://github.com/stateset/docs/tree/main/spec/overlays).
Example IDs and values are illustrative; replace them with records from your workspace.

<RequestExample>
  ```bash cURL theme={null}
  curl --silent --show-error --fail-with-body --request POST \
    --url 'https://response.stateset.com/api/v1/agents' \
    --header "Authorization: Bearer $RESPONSECX_API_KEY" \
    --header "Idempotency-Key: ${IDEMPOTENCY_KEY:?Set a unique key for this operation; preserve it on retries}" \
    --header 'Content-Type: application/json' \
    --data '{
    "name": "Quickstart Support",
    "type": "customer_service",
    "description": "Answers order and return questions",
    "role": "Customer Support Specialist",
    "instructions": "Help customers with orders and returns. Ask for missing information and escalate when you cannot verify an answer.",
    "activated": false
  }'
  ```
</RequestExample>

<ResponseExample>
  ```json 201 theme={null}
  {
    "object": "agent",
    "id": "3f9c2a10-7b4e-4d8a-9c1e-5a2b8d7f6e01",
    "name": "Quickstart Support",
    "type": "customer_service",
    "description": "Answers order and return questions",
    "activated": false,
    "goal": "",
    "role": "Customer Support Specialist",
    "updated_at": "2026-09-20T12:00:00Z",
    "instructions": "Help customers with orders and returns. Ask for missing information and escalate when you cannot verify an answer."
  }
  ```
</ResponseExample>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.