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

# Validate a response using NSR-L rules + text signals.

> **Required scope:** write

**Required scope:** `write`

### Request body

`NSRValidateRequest`

<ParamField body="case_id" type="string">
  Optional validation case id (used when replaying test cases).
</ParamField>

<ParamField body="include_neural_signals" type="boolean">
  Include NSR Machine neural signals in the response.
</ParamField>

<ParamField body="inquiry" type="string" required>
  Customer inquiry text.
</ParamField>

<ParamField body="max_ngram" type="integer">
  Max n-gram length used for contains\_text assertions.
</ParamField>

<ParamField body="max_phrases" type="integer">
  Cap on total phrases asserted per text.
</ParamField>

<ParamField body="persist" type="boolean">
  Persist this validation run for history/auditing.
</ParamField>

<ParamField body="response" type="string" required>
  Draft response to validate.
</ParamField>

### Response

`NSRValidateResponse`

<ResponseField name="escalations" type="string[]" required>
  Escalation topics detected.
</ResponseField>

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

<ResponseField name="missing_links" type="string[]" required>
  Missing required links.
</ResponseField>

<ResponseField name="neural" type="object">
  <Expandable title="neural">
    <ResponseField name="confidence" type="number (double)" required>
      Inference confidence.
    </ResponseField>

    <ResponseField name="interpreted_confidence" type="number (double)">
      Interpreted class confidence (if any).
    </ResponseField>

    <ResponseField name="interpreted_output" type="object">
      <Expandable title="interpreted_output">
        <ResponseField name="type" type="string" required />
      </Expandable>
    </ResponseField>

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

    <ResponseField name="symbols" type="integer (int64)[]" required>
      Symbol sequence from the NSR Machine.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="program_version_id" type="string">
  Optional NSR-L program version id used for this validation.
</ResponseField>

<ResponseField name="response_invalid" type="boolean" required>
  Response is explicitly invalid (response\_invalid/1).
</ResponseField>

<ResponseField name="run_id" type="string">
  Optional persisted run id when stored.
</ResponseField>

<ResponseField name="topics" type="string[]" required>
  Topics detected in the inquiry.
</ResponseField>

<ResponseField name="valid" type="boolean" required>
  Overall validity (no violations/missing links/escalations and not response\_invalid).
</ResponseField>

<ResponseField name="violations" type="string[]" required>
  Prohibited phrases detected.
</ResponseField>

### Status codes

| Code  | Meaning                                            |
| ----- | -------------------------------------------------- |
| `200` | Validation result                                  |
| `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/validate' \
    --header 'X-API-Key: YOUR_API_KEY' \
    --header 'Content-Type: application/json' \
    --data '{
    "include_neural_signals": false,
    "inquiry": "Can I return my order?",
    "max_ngram": 6,
    "max_phrases": 2000,
    "response": "Hi, I'm Dottie. You can return within 30 days."
  }'
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "escalations": [
      "string"
    ],
    "execution_time_ms": 250,
    "missing_links": [
      "string"
    ],
    "neural": {
      "confidence": 7.5,
      "interpreted_confidence": 7.5,
      "interpreted_output": {
        "type": "null"
      },
      "output": {
        "type": "null"
      },
      "symbols": [
        1
      ]
    },
    "program_version_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
    "response_invalid": true,
    "run_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
    "topics": [
      "string"
    ],
    "valid": true,
    "violations": [
      "string"
    ]
  }
  ```
</ResponseExample>
