Skip to main content
POST
/
extract
/
schemas
Create Schema
curl --request POST \
  --url https://api.contextual.ai/v1/extract/schemas \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "name": "<string>",
  "description": "<string>",
  "schema_definition": {
    "properties": {
      "company_name": {
        "description": "The name of the company exactly as it appears in the document",
        "type": "string"
      },
      "form_type": {
        "description": "The type of SEC form",
        "enum": [
          "10-K",
          "10-Q",
          "8-K",
          "S-1"
        ],
        "type": "string"
      },
      "trading_symbol": {
        "description": "The trading symbol of the company",
        "type": "string"
      },
      "zip_code": {
        "description": "The zip code of the company headquarters",
        "type": "integer"
      }
    },
    "required": [
      "company_name",
      "form_type",
      "trading_symbol",
      "zip_code"
    ],
    "type": "object"
  },
  "metadata": {}
}'
{
  "schema_id": "<string>",
  "name": "<string>",
  "description": "<string>",
  "schema_definition": {},
  "metadata": {},
  "created_at": "<string>",
  "updated_at": "<string>"
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json

Request model for creating a new extraction schema.

The schema_definition must be a valid JSON Schema that defines the structure of data to extract from documents. The system supports a subset of JSON Schema 2020-12 features optimized for document extraction.

name
string
required

Name of the schema

schema_definition
object
required

JSON Schema definition. Must be a valid JSON Schema that defines the structure of data to extract from documents. See the comprehensive schema guide in the API documentation for detailed examples and supported features.

Examples:
{
"properties": {
"company_name": {
"description": "The name of the company exactly as it appears in the document",
"type": "string"
},
"form_type": {
"description": "The type of SEC form",
"enum": ["10-K", "10-Q", "8-K", "S-1"],
"type": "string"
},
"trading_symbol": {
"description": "The trading symbol of the company",
"type": "string"
},
"zip_code": {
"description": "The zip code of the company headquarters",
"type": "integer"
}
},
"required": [
"company_name",
"form_type",
"trading_symbol",
"zip_code"
],
"type": "object"
}
description
string | null

Description of the schema

metadata
object | null

Additional metadata for the schema

Response

Successful Response

Response model for schema information.

schema_id
string
required

Unique ID of the schema

name
string
required

Name of the schema

schema_definition
object
required

JSON schema definition

metadata
object
required

Schema metadata

created_at
string
required

Timestamp when the schema was created

updated_at
string
required

Timestamp when the schema was last updated

description
string | null

Description of the schema