> ## Documentation Index
> Fetch the complete documentation index at: https://docs.olira.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Check schema

> Dry-runs a schema/mapping over sample payloads — no writes.

```python theme={null}
olira.check_schema(
    examples: list[dict],
    subtype: str | None = None,
    version: int | None = None,
    schema: dict | None = None,
    mapping: dict | None = None,
) -> SchemaCheckResult
```

**Requires scope:** `api:org-config`

Pass subtype (optionally with version) to check a stored or still-pending spec, or pass schema/mapping inline to check a candidate before registering it at all. Runs the same org gate, pure mapping engine, and platform-catalog gate the live ingest route uses, so a green check genuinely predicts what logging would accept.

## Parameters

<ParamField body="examples" type="list[dict]" required>
  Sample payloads to run through.
</ParamField>

<ParamField body="subtype" type="str | None" default="None">
  Load the active (or pinned version) schema/mapping for this subtype as the baseline.
</ParamField>

<ParamField body="version" type="int | None" default="None">
  Pin a specific version instead of the active one.
</ParamField>

<ParamField body="schema" type="dict | None" default="None">
  Inline schema, overriding or replacing the stored one.
</ParamField>

<ParamField body="mapping" type="dict | None" default="None">
  Inline mapping, overriding or replacing the stored one.
</ParamField>

## Returns

`SchemaCheckResult`

<ResponseField name="ok" type="bool">
  True only if every example passed.
</ResponseField>

<ResponseField name="results" type="list[SchemaCheckExampleResult]">
  Per-example outcome.
</ResponseField>

<ResponseField name="results[].input" type="dict">
  The example payload.
</ResponseField>

<ResponseField name="results[].ok" type="bool">
  Whether this example passed.
</ResponseField>

<ResponseField name="results[].mapped_events" type="list[dict]">
  Produced platform events (subtype + payload), if mapping succeeded.
</ResponseField>

<ResponseField name="results[].errors" type="list[str]">
  Schema/mapping/platform-catalog errors, if any.
</ResponseField>

## Raises

| Exception         | When                                                                                                                  |
| ----------------- | --------------------------------------------------------------------------------------------------------------------- |
| `AuthError`       | HTTP 401 or 403 — invalid API key or insufficient OAuth scope for this endpoint.                                      |
| `ValidationError` | HTTP 400, 404, or 422 — malformed JSON, unknown patient, or validation failure (message includes response excerpt).   |
| `ServerError`     | HTTP 409 (e.g. conflicting external identifier) or repeated 5xx after retries; includes status\_code when applicable. |
| `RateLimitError`  | HTTP 429 — rate limited; check retry\_after (seconds).                                                                |
| `NetworkError`    | Connection timeout, DNS failure, or read error after retries.                                                         |

<RequestExample>
  ```python Python theme={null}
  import olira

  olira.init(api_key="YOUR_API_KEY")
  result = olira.check_schema(
      examples=[{"reading_value": 42, "unit": "lux"}],
      schema={
          "type": "object",
          "required": ["reading_value"],
          "properties": {"reading_value": {"type": "number"}},
      },
      mapping={
          "targets": [
              {"target_subtype": "heart_rate_data", "field_mappings": [{"target": "avg_bpm", "source": "reading_value"}]},
          ],
      },
  )
  print(result.ok)
  ```

  ```http HTTP theme={null}
  POST /v1/schemas/check
  Authorization: Bearer YOUR_API_KEY
  Content-Type: application/json

  {
    "examples": [{"reading_value": 42, "unit": "lux"}],
    "payload_schema": {
      "type": "object",
      "required": ["reading_value"],
      "properties": {"reading_value": {"type": "number"}}
    },
    "mapping": {
      "targets": [
        {"target_subtype": "heart_rate_data", "field_mappings": [{"target": "avg_bpm", "source": "reading_value"}]}
      ]
    }
  }
  ```
</RequestExample>

<ResponseExample>
  ```python 200 theme={null}
  SchemaCheckResult(
      ok=True,
      results=[
          SchemaCheckExampleResult(
              input={"reading_value": 42, "unit": "lux"},
              ok=True,
              mapped_events=[
                  {"subtype": "heart_rate_data", "payload": {"avg_bpm": 42}, "metadata": {}, "idempotency_key": None},
              ],
              errors=[],
          ),
      ],
      error=None,
  )
  ```

  ```json 401 theme={null}
  {
    "error": true,
    "status_code": 401,
    "error_type": "authentication_error",
    "message": "Could not validate credentials",
    "details": [
      {
        "type": "authentication_error",
        "message": "Could not validate credentials"
      }
    ],
    "timestamp": "2026-05-06T12:00:00+00:00"
  }
  ```

  ```json 403 theme={null}
  {
    "error": true,
    "status_code": 403,
    "error_type": "authorization_error",
    "message": "Insufficient OAuth scope for this endpoint",
    "details": [
      {
        "type": "authorization_error",
        "message": "Insufficient OAuth scope for this endpoint"
      }
    ],
    "timestamp": "2026-05-06T12:00:00+00:00"
  }
  ```

  ```json 404 theme={null}
  {
    "error": true,
    "status_code": 404,
    "error_type": "not_found_error",
    "message": "Patient not found",
    "details": [
      {
        "type": "not_found_error",
        "message": "Patient not found"
      }
    ],
    "timestamp": "2026-05-06T12:00:00+00:00"
  }
  ```

  ```json 422 theme={null}
  {
    "error": true,
    "status_code": 422,
    "error_type": "validation_error",
    "message": "Request validation failed (1 error)",
    "details": [
      {
        "type": "missing",
        "message": "Field required",
        "field": "patient_id",
        "location": ["body", "patient_id"],
        "input_value": null
      }
    ],
    "timestamp": "2026-05-06T12:00:00+00:00"
  }
  ```

  ```json 429 theme={null}
  {
    "error": true,
    "status_code": 429,
    "error_type": "server_error",
    "message": "Rate limit exceeded",
    "details": [
      {
        "type": "rate_limit",
        "message": "Too many requests; retry after backoff"
      }
    ],
    "timestamp": "2026-05-06T12:00:00+00:00"
  }
  ```

  ```json 500 theme={null}
  {
    "error": true,
    "status_code": 500,
    "error_type": "internal_server_error",
    "message": "An internal server error occurred",
    "details": [
      {
        "type": "internal_server_error",
        "message": "An unexpected error occurred while processing your request"
      }
    ],
    "timestamp": "2026-05-06T12:00:00+00:00"
  }
  ```
</ResponseExample>
