Skip to main content
All SNH AI APIs use conventional HTTP response codes and return structured error information. These conventions apply to every service.

HTTP Status Codes

Response Envelope

All successful responses use a standard envelope:
Include the correlation_id when contacting support.

Error Response Format

All error responses follow a consistent format:
For validation errors with multiple issues:

Common Error Scenarios

Authentication Errors (401)

/auth/token errors use the envelope {"error":{"code":"UNAUTHORIZED","message":"..."},"timestamp":"..."} (not FastAPI {"detail":"..."}). Resolution: Get a new token from /auth/token. See Authentication.

Validation Errors (400, 422)

Validation errors return field-level details so you can fix the request without guessing.
Resolution: Fix the request payload. Do not retry — these are not transient errors.

Optional cases[] count mismatch (422 on /evaluate)

Terms first (also in the Glossary): record.cases[] is an optional charge map: each row is { court_search_id, offense_id, is_excluded }. Use it when you need to attach your IDs or mark charges excluded. Omit cases or send cases: [] to evaluate every offense — the count gate does not run. When cases[] is non-empty, the distinct court-search-ID count and total offense-ID row count must exactly match the courts and offenses in the parsed XML or record_json. Partial maps are rejected with HTTP 422 and data.status: "validation_required". Trigger: Incomplete cases[] — for example 2 court search IDs and 3 offense rows when the record has 3 courts and 5 offenses. Do not drop excluded charges from the array; include them with is_excluded: true.
Do not retry HTTP 422 — fix the payload (complete cases[] or omit it).
See Evaluate → cases[] count reconciliation and Glossary → cases.

Partial Success (206)

When a processing stage degrades or fails, the API returns HTTP 206 with partial results:
  • data.status: "partial"
  • data.errors[] — error messages from the failed stage
  • data.degradation — per-stage status
  • data.decision — whatever decisions could still be produced

Server Errors (500)

Resolution: Retry with exponential backoff. See Retry Logic. For additional service-specific issues, see Troubleshooting.