API Documentation

Schema endpoints

List, create, and delete schemas in your account with the same API key used for extraction.

Schemas · Create

Create a schema via API

Endpoint

POSThttps://www.claix.dev/api/create-schema

Creates a schema on the API key account, ready for extraction or Agent mode endpoints. It matches dashboard creation, with type and definition validation.

Always call https://www.claix.dev/api/create-schema. Do not use the internal Supabase URL (https://yuhcusjiywsuzjwirarw.supabase.co/functions/v1/create-schema).

Intended for server-to-server integrations. It is not billed (no usage_logs row).

1. Authentication

Every request must include your API key. It is a personal server credential, distinct from any session token.

Option A — Dedicated header (recommended):

x-api-key: <YOUR_API_KEY>

Option B — Standard Authorization header:

Authorization: Bearer <YOUR_API_KEY>

Either one is sufficient. If you send both, x-api-key takes priority.

The system checks that the key exists, is active, and the account is not suspended. Failure returns 401.

2. Request format

Method: POST · Content-Type: application/json

FieldTypeRequiredDescription
namestringYesVisible schema name (max 200).
typestringYesexcel-json, json-excel, pdf-json, doc-json, or img-json.
schema_definitionobjectYesFields to extract. Each key is the output JSON name.
is_agent_modebooleanNoEnables Agent mode. If omitted but agent_definition is sent, it is assumed true.
agent_definitionobjectIf agent modeReasoning parameters. Required when is_agent_mode is true.
resumen_agentstringNoExtra instruction for the agent phase (max 500).

Each schema_definition field must look like:

{
  "nombre_dni": {
    "type": "string",
    "description": "full name printed on the ID card"
  }
}

Extraction types: string, integer, number, boolean. description is required.

Each agent_definition parameter uses boolean, string, closed, or integer. If type is closed, options must be a non-empty array:

{
  "calidad_foto": {
    "type": "closed",
    "options": ["buena calidad", "mala calidad", "ilegible", "perfecta"],
    "description": "Image quality and data legibility"
  }
}

The json-excel type does not support Agent mode.

3. How to build the call

  1. Have your API key ready.
  2. Send a JSON POST to https://www.claix.dev/api/create-schema.
  3. Include name, type, and schema_definition.
  4. For Agent mode, add is_agent_mode: true and agent_definition.
  5. Check the HTTP status: 201 means it was created.

4. Request examples

Use the panel on the right for cURL, JavaScript, Node.js, Python, PHP, and n8n examples.

5. Successful response

201 Created · Content-Type: application/json

{
  "success": true,
  "schema": {
    "id": "b980cfe7-61ef-4a5a-9724-881c8a5541e2",
    "name": "DNI cliente",
    "type": "img-json",
    "schema_definition": {
      "nombre_dni": {
        "type": "string",
        "description": "nombre de la persona del dni"
      },
      "numero_dni": {
        "type": "string",
        "description": "numero de dni"
      },
      "fecha_caducidad": {
        "type": "string",
        "description": "fecha de caducidad del dni"
      }
    },
    "is_agent_mode": true,
    "agent_definition": {
      "edad": {
        "type": "integer",
        "description": "Edad exacta de la persona pero restale 3"
      },
      "calidad_foto": {
        "type": "closed",
        "options": ["buena calidad", "mala calidad", "ilegible", "perfecta"],
        "description": "La calidad de la imagen y la legibilidad de sus datos"
      },
      "es_mayor_edad": {
        "type": "boolean",
        "description": "Es mayor de edad actualmente la persona del dni?"
      },
      "fecha_vencimiento": {
        "type": "string",
        "description": "Cuado le vence el dni y cuanto tiempo queda para ello"
      }
    },
    "resumen_agent": null,
    "created_at": "2026-08-17T13:10:00.000Z"
  }
}
FieldTypeDescription
successbooleanAlways true when HTTP is 201.
schemaobjectPersisted schema, including its UUID.
schema.iduuidUse later as schema_id for extraction.
schema.schema_definitionobjectNormalized definition.
schema.agent_definitionobject | nullNull when is_agent_mode is false.

6. Error codes

{
  "error": "Descripción legible del problema.",
  "detalle": "Información técnica adicional (solo presente en algunos casos)."
}

400 — Invalid payload: missing name/type/definition, unknown type, empty description, closed without options, or json-excel with Agent mode.

401 — Authentication failed: missing, unknown, or disabled key, or suspended account.

405 — Method other than POST. · 500 — Internal error.

7. Status code summary

CodeCategoryRetry?
201Created
400Client error (malformed data)No — fix the request first
401Authentication errorNo — fix credentials first
405Incorrect HTTP methodNo — fix the method first
500Internal server errorYes, with caution

8. Best practices

  • Use https://www.claix.dev/api/create-schema, never the Supabase URL.
  • type must match the extraction endpoint you will call later.
  • Clear descriptions improve AI accuracy for extraction and agent reasoning.
  • Never put your API key in frontend code or public repos.

Request examples

curl -X POST "https://www.claix.dev/api/create-schema" \
  -H "x-api-key: <TU_API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{  "name": "DNI cliente",  "type": "img-json",  "schema_definition": {    "nombre_dni": {      "type": "string",      "description": "nombre de la persona del dni"    },    "numero_dni": {      "type": "string",      "description": "numero de dni"    },    "fecha_caducidad": {      "type": "string",      "description": "fecha de caducidad del dni"    }  },  "is_agent_mode": true,  "agent_definition": {    "edad": {      "type": "integer",      "description": "Edad exacta de la persona pero restale 3"    },    "calidad_foto": {      "type": "closed",      "options": ["buena calidad", "mala calidad", "ilegible", "perfecta"],      "description": "La calidad de la imagen y la legibilidad de sus datos"    },    "es_mayor_edad": {      "type": "boolean",      "description": "Es mayor de edad actualmente la persona del dni?"    },    "fecha_vencimiento": {      "type": "string",      "description": "Cuado le vence el dni y cuanto tiempo queda para ello"    }  }}'