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

# Build a complete agent — rules, tools and settings — in one atomic call

> Preferred over create + configure + add_rule + add_function. Pass template_id to seed a proven ruleset.

Preferred over create + configure + add\_rule + add\_function. Pass template\_id to seed a proven ruleset.

### Request body

`ProvisionAgent`

<ParamField body="name" type="string" required />

<ParamField body="template_id" type="string">
  Seeds rules/attributes/examples from a starter template.
</ParamField>

<ParamField body="type" type="string">
  One of: assistant, customer\_service, sales.
</ParamField>

<ParamField body="description" type="string" />

<ParamField body="instructions" type="string">
  The system prompt / persona.
</ParamField>

<ParamField body="goal" type="string" />

<ParamField body="role" type="string" />

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

<ParamField body="rules" type="object[]" />

<ParamField body="functions" type="object[]" />

<ParamField body="settings" type="object">
  Model config. Defaults to the template's when a template is used.
</ParamField>

### Response

`Agent`

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

<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" />

    <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 provisioned agent, with a summary of what was created                                                                                                                                                                                      |
| `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     | 10 requests per minute |

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url 'https://response.stateset.com/api/v1/agents/provision' \
    --header 'Authorization: Bearer YOUR_API_KEY' \
    --header 'Content-Type: application/json' \
    --data '{
    "name": "string",
    "template_id": "string",
    "type": "string",
    "description": "string",
    "instructions": "string",
    "goal": "string",
    "role": "string",
    "activated": true,
    "rules": [
      {
        "rule_name": "string",
        "rule_type": "string",
        "description": "string",
        "activated": true,
        "conditions": {
          "any": null,
          "all": null
        },
        "actions": []
      }
    ],
    "functions": [
      {
        "function_name": "string",
        "endpoint": "string",
        "method": "string",
        "description": "string",
        "activated": true,
        "parameters": [],
        "headers": {},
        "timeout": 1
      }
    ],
    "settings": {
      "model_name": "string",
      "model_provider": "string",
      "model_type": "string",
      "temperature": 1,
      "max_tokens": 1,
      "top_p": 1,
      "escalation_tag_name": "string",
      "escalation_team_id": "string",
      "agent_take_over_tag": "string"
    }
  }'
  ```
</RequestExample>

<ResponseExample>
  ```json 201 theme={null}
  {
    "object": "string",
    "id": "string",
    "name": null,
    "type": null,
    "description": null,
    "activated": true,
    "goal": null,
    "role": null,
    "updated_at": null,
    "instructions": null,
    "settings": {
      "object": "string",
      "configured": true
    }
  }
  ```
</ResponseExample>
