Tables
List and create a model's tables
List Tables
/api/v1/deployments/{deploymentId}/tablesReturns 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
| Name | Type | In | Required | Description |
|---|---|---|---|---|
deploymentId | string | path | Yes | The 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
{
"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
/api/v1/deployments/{deploymentId}/tablesCreates 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
| Name | Type | In | Required | Description |
|---|---|---|---|---|
deploymentId | string | path | Yes | The model ID. Tables are created on models, not on deployments. |
name | string | body | Yes | Table name |
instructions | string | body | No | Extraction instructions for this table. At most 10,000 characters. |
parentTableId | string | body | No | ID of the primary table (required for child tables) |
columns | array | body | No | Array of column definitions |
Each column object in the columns array supports:
| Name | Type | In | Required | Description |
|---|---|---|---|---|
name | string | body | Yes | Column name |
type | string | body | No | Column type: TEXT, NUMBER, DATE, BOOLEAN, LABEL, MEASUREMENT(default: TEXT) |
description | string | body | No | Column description for the extraction model |
isKey | boolean | body | No | Whether this column is a key column(default: false) |
isList | boolean | body | No | Whether this column accepts list values(default: false) |
units | array | body | No | Array of {name} for NUMBER_WITH_UNIT columns |
autoGenerateUnits | boolean | body | No | Let 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
{
"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:
{
"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:
{
"error": "Deployment has no extraction schema"
}