Skip to main content

Templates

Manage your extraction templates programmatically via API key.

Endpoints

MethodPathDescription
GET/v1/templatesList your templates
POST/v1/templatesCreate a template
PUT/v1/templates/:idUpdate a template
DELETE/v1/templates/:idDelete a template

All endpoints require an x-api-key header. See Authentication.


List Templates

GET /v1/templates
x-api-key: your_api_key_here

Response 200 OK

[
{ "id": "tpl_abc123", "name": "Invoice" },
{ "id": "tpl_def456", "name": "Receipt" }
]

Create a Template

POST /v1/templates
x-api-key: your_api_key_here
Content-Type: application/json

Request body

FieldTypeRequiredDescription
namestringYesTemplate name
categorystringYesOne of the template categories
schemaobjectYesField extraction schema — see Schema format
descriptionstringNoHuman-readable description

Response 201 Created

{
"id": "tpl_abc123",
"name": "Invoice",
"description": "Extracts key invoice fields",
"category": "INVOICE",
"schema": { "...": "..." },
"createdAt": "2026-01-15T10:00:00.000Z",
"updatedAt": "2026-01-15T10:00:00.000Z"
}

Update a Template

PUT /v1/templates/:id
x-api-key: your_api_key_here
Content-Type: application/json

The request body is identical to Create a Template. All fields are required (full replacement, not a partial patch).

Response 200 OK

Returns the updated template object (same shape as the create response).

Error responses

StatusMeaning
400Invalid schema — see error message for the exact field path
403You do not own this template
404Template not found

Delete a Template

DELETE /v1/templates/:id
x-api-key: your_api_key_here

Response 204 No Content

Error responses

StatusMeaning
403You do not own this template
404Template not found

Schema format

The schema field defines which data to extract from each document. It must follow this exact shape:

{
"data": {
"<fieldName>": { "<field definition>" },
"<fieldName>": { "<field definition>" }
}
}

data is always the top-level key. Each key inside it is the name that will appear in the extraction result.

Field definition

Every field is an object with at minimum a type property.

PropertyTypeRequiredApplies toDescription
typestringYesallOne of the field types
descriptionstringNoallHint to the extraction engine about what this field contains
formatstringNostring onlySub-format hint — one of the string formats
itemTypestringYes when type is arrayarrayType of each item: string, number, boolean, date, or object
itemSchemaobjectNo when itemType is objectarray of objectsDescribes the shape of each object item — see Array of objects
propertiesobjectNoobjectNested field definitions — same structure as data

Field types

TypeDescriptionExample values
stringPlain text"INV-001", "John Doe"
numberNumeric value (including amounts and percentages)1250.00, 20
booleanTrue/false flagtrue, false
dateCalendar date"2026-01-15"
arrayList of values or objects["skill1", "skill2"]
objectGrouped sub-fields{ "name": "Acme", "vat": "FR123" }

String formats

Use format to give the extraction engine a stronger hint when a string field has a predictable shape.

ValueDescription
dateISO 8601 date (2026-01-15)
timeTime value (10:30)
emailEmail address
phonePhone number
urlWeb URL
addressPostal address
ibanIBAN bank account number

Scalar field examples

{
"data": {
"invoiceNumber": {
"type": "string",
"description": "Unique invoice identifier"
},
"invoiceDate": {
"type": "string",
"format": "date",
"description": "Date the invoice was issued"
},
"totalAmount": {
"type": "number",
"description": "Total amount due including taxes"
},
"isPaid": {
"type": "boolean",
"description": "Whether the invoice has been paid"
}
}
}

Object field

Use type: "object" to group related sub-fields under a single key.

{
"data": {
"vendor": {
"type": "object",
"description": "Vendor details",
"properties": {
"name": {
"type": "string",
"description": "Vendor company name"
},
"email": {
"type": "string",
"format": "email",
"description": "Vendor email address"
},
"vatNumber": {
"type": "string",
"description": "VAT identification number"
}
}
}
}
}

Array of scalars

Use type: "array" with a scalar itemType to extract a list of simple values.

{
"data": {
"skills": {
"type": "array",
"itemType": "string",
"description": "List of skills"
},
"scores": {
"type": "array",
"itemType": "number",
"description": "List of scores"
}
}
}

Array of objects

When itemType is "object", use itemSchema.properties to describe each object in the list.

{
"data": {
"lineItems": {
"type": "array",
"itemType": "object",
"description": "Billed products or services",
"itemSchema": {
"properties": {
"description": {
"type": "string",
"description": "Product or service description"
},
"quantity": {
"type": "number",
"description": "Quantity"
},
"unitPrice": {
"type": "number",
"description": "Unit price"
},
"total": {
"type": "number",
"description": "Line total"
}
}
}
}
}
}

Complete example — Invoice template

{
"name": "Invoice",
"category": "INVOICE",
"description": "Extracts key fields from invoices",
"schema": {
"data": {
"invoiceNumber": {
"type": "string",
"description": "Unique invoice identifier"
},
"invoiceDate": {
"type": "string",
"format": "date",
"description": "Date the invoice was issued"
},
"dueDate": {
"type": "string",
"format": "date",
"description": "Payment due date"
},
"currency": {
"type": "string",
"description": "Currency code (e.g. EUR, USD)"
},
"subtotal": { "type": "number", "description": "Amount before taxes" },
"taxAmount": { "type": "number", "description": "Total tax amount" },
"totalAmount": { "type": "number", "description": "Total amount due" },
"vendor": {
"type": "object",
"description": "Vendor information",
"properties": {
"name": { "type": "string", "description": "Vendor name" },
"address": { "type": "string", "description": "Vendor address" },
"vatNumber": { "type": "string", "description": "Vendor VAT number" }
}
},
"lineItems": {
"type": "array",
"itemType": "object",
"description": "List of billed items",
"itemSchema": {
"properties": {
"description": { "type": "string", "description": "Item description" },
"quantity": { "type": "number", "description": "Quantity" },
"unitPrice": { "type": "number", "description": "Unit price" },
"total": { "type": "number", "description": "Line total" }
}
}
}
}
}
}

Template Categories

ValueDescription
INVOICEInvoices and billing documents
RECEIPTPurchase receipts
ID_DOCUMENTIdentity documents (passport, driver's license, …)
CONTRACTContracts and agreements
MEDICAL_RECORDMedical reports and health records
RESUMECVs and resumes
CUSTOMAny other document type

Node.js SDK

import { Parselyze } from 'parselyze';

const parselyze = new Parselyze('plz_your_api_key_here');

// List templates
const templates = await parselyze.templates.list();

// Create a template
const template = await parselyze.templates.create({
name: 'Invoice',
category: 'INVOICE',
description: 'Extracts key fields from invoices',
schema: {
data: {
invoiceNumber: { type: 'string', description: 'Invoice number' },
invoiceDate: { type: 'string', format: 'date', description: 'Invoice date' },
totalAmount: { type: 'number', description: 'Total amount due' },
vendor: {
type: 'object',
description: 'Vendor details',
properties: {
name: { type: 'string', description: 'Vendor name' },
vatNumber: { type: 'string', description: 'VAT number' },
},
},
lineItems: {
type: 'array',
itemType: 'object',
description: 'Billed items',
itemSchema: {
properties: {
description: { type: 'string', description: 'Item description' },
quantity: { type: 'number', description: 'Quantity' },
unitPrice: { type: 'number', description: 'Unit price' },
total: { type: 'number', description: 'Line total' },
},
},
},
},
},
});

// Update a template (full replacement)
const updated = await parselyze.templates.update(template.id, {
name: 'Invoice v2',
category: 'INVOICE',
schema: {
data: {
invoiceNumber: { type: 'string', description: 'Invoice number' },
totalAmount: { type: 'number', description: 'Total amount due' },
},
},
});

// Delete a template
await parselyze.templates.delete(template.id);