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

# Evaluate a program with optional arguments

> **Required scope:** write

**Required scope:** `write`

### Request body

`ProgramEvaluateRequest`

<ParamField body="args" type="SemanticValueRequest[]">
  Optional arguments to bind as variables
</ParamField>

<ParamField body="children" type="SemanticValueRequest[]">
  Optional child values for `child` lookups
</ParamField>

<ParamField body="program" type="ProgramRequest" required />

### Response

`ProgramEvaluateResponse`

<ResponseField name="depth" type="integer" required>
  Program depth
</ResponseField>

<ResponseField name="execution_time_ms" type="integer (int64)" required>
  Evaluation time in milliseconds
</ResponseField>

<ResponseField name="output" type="SemanticValueResponse" required>
  <Expandable title="SemanticValueResponse">
    <ResponseField name="type" type="string" required />
  </Expandable>
</ResponseField>

### Status codes

| Code  | Meaning                                            |
| ----- | -------------------------------------------------- |
| `200` | Program evaluated                                  |
| `400` | Invalid request                                    |
| `401` | Unauthorized — missing or invalid credentials      |
| `403` | Forbidden — the key/token lacks the required scope |
| `429` | Rate limited — see Retry-After / X-RateLimit-Reset |

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url 'https://api.nsr.stateset.com/api/v1/nsr/programs/evaluate' \
    --header 'X-API-Key: YOUR_API_KEY' \
    --header 'Content-Type: application/json' \
    --data '{
    "args": [
      {
        "type": "null"
      }
    ],
    "children": [
      {
        "type": "null"
      }
    ],
    "program": {
      "index": 1,
      "type": "var"
    }
  }'
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "depth": 1,
    "execution_time_ms": 250,
    "output": {
      "type": "null"
    }
  }
  ```
</ResponseExample>
