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

# Test Function

> Automation endpoint used by voice agents and trusted clients to execute workflow actions or retrieve evaluation results.

Automation endpoint used by voice agents and trusted clients to execute workflow actions or retrieve evaluation results.

### Request body

`FunctionTestRequest`

<ParamField body="args" type="object" required>
  Function arguments as JSON
</ParamField>

<ParamField body="context" type="FunctionContextInput,null" />

<ParamField body="name" type="string" required>
  Function name to execute
</ParamField>

### Response

`FunctionTestResponse`

<ResponseField name="error" type="string,null">
  Error message (if failed)
</ResponseField>

<ResponseField name="ok" type="boolean" required>
  Whether the function executed successfully
</ResponseField>

<ResponseField name="result" type="object">
  Function result (if successful)
</ResponseField>

### Status codes

| Code  | Meaning                   |
| ----- | ------------------------- |
| `200` | Function executed         |
| `401` | Unauthorized              |
| `500` | Function execution failed |

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url 'https://api.voice.stateset.com/test-function' \
    --header 'Authorization: Bearer YOUR_API_KEY' \
    --header 'Content-Type: application/json' \
    --data '{
    "args": {
      "order_id": "12345"
    },
    "context": {
      "agent_name": "Front Desk",
      "authenticated": true,
      "customer_id": "cust-789",
      "customer_phone": "+15555555678",
      "org_id": "org-456",
      "session_id": "sess-abc123"
    },
    "name": "get_order"
  }'
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "ok": true,
    "result": {
      "order": {
        "id": "12345",
        "status": "shipped"
      }
    }
  }
  ```
</ResponseExample>
