---
title: "Save an extraction schema"
method: POST
path: "/v1/extraction-schemas"
tags: ["Documents"]
---

# Save an extraction schema

`POST /v1/extraction-schemas`

## Request

- Base URL: `https://console.nace.ai`
- URL: `https://console.nace.ai/v1/extraction-schemas`
- Auth: HTTP bearer
- TypeScript: <https://skmtc.dev/nace/apis/drex-api/docs/v1/extraction-schemas/post.ts> (a function with typed inputs; its response is checked against the schema)

Saves version 1 of a new schema under a generated `schema_id`. `POST /v1/documents/extract` can then name it with `schema_id` instead of sending `schema` inline. Free, and works at any balance.

- **Access:** only this account can see or use it.
- **Changes:** schemas can't be edited. Add a version instead.
- **Retention:** the schema, with every version, is kept until you delete it or close your account.
- **Retries:** a retried create saves a second schema.

## Request body

- object
  - `name` string, required
  - `description` string
  - `schema` object, required: The JSON Schema of the fields to extract, as `schema` takes it on an extract.

## Response `201`

The saved schema.

- ExtractionSchema
  - `schema_id` string, required: Stable id of the schema across its versions (`sch_...`).
  - `name` string, required
  - `description` string, nullable
  - `version` integer, required
  - `owner` 'account' | 'platform', required: `account` for a schema this account saved.
  - `created_at` string, date-time, required
  - `updated_at` string, date-time, required
  - `schema` object: The version's JSON Schema. Always present on a single schema, a version and a list of versions; `GET /v1/extraction-schemas` leaves it out.

## Other responses

- `401`: Missing or invalid API key (`authentication_error`, code `invalid_api_key`).
- `413`: The body is over 1 MB (`invalid_request_error`, code `payload_too_large`).
- `422`: The body is not a valid schema request, or the schema is not one Extract can use (`invalid_request_error`). Code `invalid_request` lists the fields that failed in `detail.errors`; code `invalid_schema` names the problem in `message`.
- `429`: Over the account's requests per minute for document routes, or the document service is throttling this account (`rate_limit_error`).
- `500`: Something failed on Drex's side (`internal_error`).
- `502`: The document service refused Drex's own request (`upstream_error`, code `ndi_refused_drex`). Retry later.
- `503`: The document service is unavailable (`service_unavailable`).

---

[API](https://skmtc.dev/nace/apis/drex-api.md) - [All operations](https://skmtc.dev/nace/apis/drex-api/llms.txt) - [OpenAPI document](https://skmtc.dev/nace/apis/drex-api/revisions/a0e62d925a61?raw)
