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

# Give the agent an API-call tool

> The tool

### Path parameters

<ParamField path="id" type="string (uuid)" required>
  The agent id.
</ParamField>

### Request body

`CreateFunction`

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

<ParamField body="endpoint" type="string" required>
  Public http(s) URL. Private and metadata addresses are rejected.
</ParamField>

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

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

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

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

<ParamField body="headers" type="object" />

<ParamField body="timeout" type="integer" />

### Response

`Function`

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

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

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

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

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

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

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

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

### Status codes

| Code  | Meaning                                                                                                                                                                                                                                        |
| ----- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `201` | The tool                                                                                                                                                                                                                                       |
| `400` | Invalid request. `issues` names the offending field(s).                                                                                                                                                                                        |
| `401` | Missing, invalid, or expired API key.                                                                                                                                                                                                          |
| `403` | The key lacks a required scope.                                                                                                                                                                                                                |
| `404` | Not found, or not in the organization that owns the key.                                                                                                                                                                                       |
| `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 |

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url 'https://response.stateset.com/api/v1/agents/{id}/functions' \
    --header 'Authorization: Bearer YOUR_API_KEY' \
    --header 'Content-Type: application/json' \
    --data '{
    "function_name": "string",
    "endpoint": "string",
    "method": "string",
    "description": "string",
    "activated": true,
    "parameters": [
      {
        "name": "string",
        "type": "string",
        "description": "string",
        "required": true
      }
    ],
    "headers": {},
    "timeout": 1
  }'
  ```
</RequestExample>

<ResponseExample>
  ```json 201 theme={null}
  {
    "object": "string",
    "id": "string",
    "name": null,
    "endpoint": null,
    "method": null,
    "description": null,
    "activated": true,
    "agent_id": null
  }
  ```
</ResponseExample>
