Skip to main content
POST
/
api
/
v1
/
llm
/
extract
/
schema
Typescript (SDK)
import { SDK } from "@meetkai/mka1";

const sdk = new SDK({
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const result = await sdk.llm.extract.createSchema({
    extractionSchema: {
      name: "Invoice Extraction",
      description: "Schema for extracting invoice data from PDF documents",
      schema: {
        "type": "object",
        "properties": {
          "invoice_number": {
            "type": "string",
          },
          "vendor_name": {
            "type": "string",
          },
          "total_amount": {
            "type": "number",
          },
          "date": {
            "type": "string",
            "format": "date",
          },
        },
        "required": [
          "invoice_number",
          "total_amount",
        ],
      },
      metadata: {
        "document_type": "invoice",
      },
    },
  });

  console.log(result);
}

run();
{
  "success": true,
  "data": {
    "id": "schema_invoice_123",
    "name": "Invoice Extraction",
    "description": "Schema for extracting invoice data from PDF documents",
    "schema": {
      "type": "object",
      "properties": {
        "invoice_number": {
          "type": "string"
        },
        "vendor_name": {
          "type": "string"
        },
        "total_amount": {
          "type": "number"
        },
        "date": {
          "type": "string",
          "format": "date"
        }
      },
      "required": [
        "invoice_number",
        "total_amount"
      ]
    },
    "metadata": {
      "document_type": "invoice"
    },
    "createdAt": "2024-01-15T10:30:00Z",
    "updatedAt": "2024-01-15T10:30:00Z"
  }
}

Authorizations

Authorization
string
header
required

Authenticate with your MKA1 API key at the API gateway: Authorization: Bearer <mka1-api-key>. For multi-user server-side integrations, also send X-On-Behalf-Of to identify the end user making the request.

Headers

X-On-Behalf-Of
string

Optional external user identifier for multi-user server-side integrations. Use this when acting on behalf of one of your end users.

Body

application/json

Schema definition for creating a reusable extraction template. Extraction schemas define the structure and validation rules for data extraction from files.

name
string
required

Name of the extraction schema. Must be between 1 and 100 characters. Used to identify and reference the schema.

Required string length: 1 - 100
schema
object
required

JSON Schema object defining the structure of data to extract. Specifies the fields, types, and validation rules for the extracted data.

description
string

Optional description of the schema. Maximum 500 characters. Helps document the purpose and usage of the schema.

Maximum string length: 500
metadata
object

Optional metadata for the schema. Can store additional information like version, author, or custom properties.

Response

200 - application/json

OK

Response from creating a new extraction schema.

success
boolean
required

Indicates whether the schema creation was successful

data
object
required

The created extraction schema with generated ID and timestamps