Limai Docs
API ReferenceDeployments

Tables

List and create a model's tables

List Tables

GET/api/v1/deployments/{deploymentId}/tables

Returns all tables and their columns for a model or deployment. A deployment pinned to a schema version returns the tables and columns that version froze; anything else returns the model's current schema.

Parameters

NameTypeInRequiredDescription
deploymentIdstringpathYesThe model's ID, or the ID of a deployment that points at it

Request

const res = await fetch(
"https://app.limai.io/api/v1/deployments/dep_abc123/tables",
{
  headers: {
    Authorization: "Bearer YOUR_API_TOKEN",
  },
}
);
const { data } = await res.json();

Response

Response200
{
  "modelId": "dep_abc123",
  "viaDeploymentId": "dpl_prod01",
  "data": [
    {
      "id": "tbl_001",
      "name": "Invoices",
      "instructions": "Extract invoice header fields",
      "isPrimary": true,
      "parentTableId": null,
      "wrapColumns": false,
      "columnCount": 5,
      "columns": [
        {
          "id": "col_001",
          "name": "Invoice Number",
          "type": "TEXT",
          "description": null,
          "isKey": true,
          "isList": false,
          "dateFormat": "EU",
          "measurementType": "LEVENSHTEIN",
          "excludedFromExtraction": false,
          "index": 0
        }
      ]
    }
  ]
}

Create Table

POST/api/v1/deployments/{deploymentId}/tables

Creates a new table in a model. The first table created becomes the primary table. Additional tables must specify a parentTableId pointing to the primary table.

A schema is edited on the model, so this endpoint takes a model's ID — the dep_abc123 in the examples below. A deployment ID is refused with a 409.

Parameters

NameTypeInRequiredDescription
deploymentIdstringpathYesThe model ID. Tables are created on models, not on deployments.
namestringbodyYesTable name
instructionsstringbodyNoExtraction instructions for this table. At most 10,000 characters.
parentTableIdstringbodyNoID of the primary table (required for child tables)
columnsarraybodyNoArray of column definitions

Each column object in the columns array supports:

NameTypeInRequiredDescription
namestringbodyYesColumn name
typestringbodyNoColumn type: TEXT, NUMBER, DATE, BOOLEAN, LABEL, MEASUREMENT(default: TEXT)
descriptionstringbodyNoColumn description for the extraction model
isKeybooleanbodyNoWhether this column is a key column(default: false)
isListbooleanbodyNoWhether this column accepts list values(default: false)
unitsarraybodyNoArray of {name} for NUMBER_WITH_UNIT columns
autoGenerateUnitsbooleanbodyNoLet extraction pick units from the document instead of a fixed list(default: false)

Column objects accept the same fields as Create Column. A NUMBER_WITH_UNIT column needs units or autoGenerateUnits: true; otherwise the whole request is rejected with a 400.

Request

const res = await fetch(
"https://app.limai.io/api/v1/deployments/dep_abc123/tables",
{
  method: "POST",
  headers: {
    Authorization: "Bearer YOUR_API_TOKEN",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    name: "Line Items",
    parentTableId: "tbl_001",
    columns: [
      { name: "Description", type: "TEXT" },
      { name: "Quantity", type: "NUMBER" },
      { name: "Unit Price", type: "NUMBER" },
    ],
  }),
}
);

Response

Response201
{
  "modelId": "dep_abc123",
  "viaDeploymentId": null,
  "id": "tbl_002",
  "name": "Line Items",
  "instructions": null,
  "isPrimary": false,
  "parentTableId": "tbl_001",
  "columns": [
    {
      "id": "col_010",
      "name": "Description",
      "type": "TEXT",
      "description": null,
      "isKey": false,
      "isList": false,
      "index": 0,
      "labels": [],
      "units": []
    }
  ]
}

Error Responses

A deployment ID in place of the model's:

Response409
{
  "error": "Schema and configuration are edited on the model, not on a deployment",
  "code": "POINTER_NOT_WRITABLE",
  "deploymentId": "dpl_prod01",
  "modelId": "dep_abc123"
}

A model that has never been configured:

Response400
{
  "error": "Deployment has no extraction schema"
}

On this page