Templates
Manage your extraction templates programmatically via API key.
Endpoints
| Method | Path | Description |
|---|---|---|
GET | /v1/templates | List your templates |
POST | /v1/templates | Create a template |
PUT | /v1/templates/:id | Update a template |
DELETE | /v1/templates/:id | Delete 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
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Template name |
category | string | Yes | One of the template categories |
schema | object | Yes | Field extraction schema — see Schema format |
description | string | No | Human-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
| Status | Meaning |
|---|---|
400 | Invalid schema — see error message for the exact field path |
403 | You do not own this template |
404 | Template not found |
Delete a Template
DELETE /v1/templates/:id
x-api-key: your_api_key_here
Response 204 No Content
Error responses
| Status | Meaning |
|---|---|
403 | You do not own this template |
404 | Template 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.
| Property | Type | Required | Applies to | Description |
|---|---|---|---|---|
type | string | Yes | all | One of the field types |
description | string | No | all | Hint to the extraction engine about what this field contains |
format | string | No | string only | Sub-format hint — one of the string formats |
itemType | string | Yes when type is array | array | Type of each item: string, number, boolean, date, or object |
itemSchema | object | No when itemType is object | array of objects | Describes the shape of each object item — see Array of objects |
properties | object | No | object | Nested field definitions — same structure as data |
Field types
| Type | Description | Example values |
|---|---|---|
string | Plain text | "INV-001", "John Doe" |
number | Numeric value (including amounts and percentages) | 1250.00, 20 |
boolean | True/false flag | true, false |
date | Calendar date | "2026-01-15" |
array | List of values or objects | ["skill1", "skill2"] |
object | Grouped 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.
| Value | Description |
|---|---|
date | ISO 8601 date (2026-01-15) |
time | Time value (10:30) |
email | Email address |
phone | Phone number |
url | Web URL |
address | Postal address |
iban | IBAN 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
| Value | Description |
|---|---|
INVOICE | Invoices and billing documents |
RECEIPT | Purchase receipts |
ID_DOCUMENT | Identity documents (passport, driver's license, …) |
CONTRACT | Contracts and agreements |
MEDICAL_RECORD | Medical reports and health records |
RESUME | CVs and resumes |
CUSTOM | Any 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);