Skip to main content

Templates API

Manage extraction templates programmatically. For the concepts — fields, sub-fields, and output modes — see the Templates guide.

Base path: /templates

MethodPathPurpose
GET/templatesList your templates
POST/templatesCreate a template
GET/templates/{id}Get one template
PUT/templates/{id}Update a template
DELETE/templates/{id}Delete a template
POST/templates/generateGenerate a template with AI
POST/templates/generate-from-imageGenerate a template from a sample document image

List templates

GET /templates
curl "https://netraocr.shivicx.com/api/v1/templates" \
-u "ak_live_xxxxxxxx:sk_live_xxxxxxxx"

Returns your templates. Use a template's id as the template_id on upload.


Create a template

POST /templates

A template is primarily a name plus a list of fields. Each field has a name, a description to guide extraction, and optional nested fields for sub-fields.

curl -X POST "https://netraocr.shivicx.com/api/v1/templates" \
-u "ak_live_xxxxxxxx:sk_live_xxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"name": "Vendor Invoice",
"fields": [
{ "name": "invoice_number", "description": "Unique invoice number" },
{ "name": "invoice_date", "description": "Date the invoice was issued" },
{ "name": "total", "description": "Grand total amount payable" },
{
"name": "line_items",
"description": "One entry per line on the invoice",
"fields": [
{ "name": "description", "description": "Item description" },
{ "name": "quantity", "description": "Units ordered" },
{ "name": "amount", "description": "Line total" }
]
}
]
}'

Response 200 OK

{
"template_id": "12",
"name": "Vendor Invoice",
"fields": [],
"created_at": "2026-06-16T10:00:00Z"
}
Plan limits

The number of fields and sub-fields per field is capped by your plan (Basic 5/5, Essential 15/10, Business unlimited). Exceeding a cap returns a validation error. See Templates guide.


Get a template

GET /templates/{id}
curl "https://netraocr.shivicx.com/api/v1/templates/12" \
-u "ak_live_xxxxxxxx:sk_live_xxxxxxxx"

Update a template

PUT /templates/{id}

Replaces the template definition. Send the full field list (same shape as create).

curl -X PUT "https://netraocr.shivicx.com/api/v1/templates/12" \
-u "ak_live_xxxxxxxx:sk_live_xxxxxxxx" \
-H "Content-Type: application/json" \
-d '{ "name": "Vendor Invoice v2", "fields": [ … ] }'

Delete a template

DELETE /templates/{id}
curl -X DELETE "https://netraocr.shivicx.com/api/v1/templates/12" \
-u "ak_live_xxxxxxxx:sk_live_xxxxxxxx"

Generate a template with AI

POST /templates/generate

Describe the document in natural language and let NetraOCR draft a template you can refine and save.

curl -X POST "https://netraocr.shivicx.com/api/v1/templates/generate" \
-u "ak_live_xxxxxxxx:sk_live_xxxxxxxx" \
-H "Content-Type: application/json" \
-d '{ "prompt": "A standard vendor invoice with line items, taxes, and totals" }'

The response contains a generated set of fields ready to review and create.


Generate a template from an image

POST /templates/generate-from-image

Uploads a sample document image and asks NetraOCR to draft a template from what it sees.

curl -X POST "https://netraocr.shivicx.com/api/v1/templates/generate-from-image" \
-u "ak_live_xxxxxxxx:sk_live_xxxxxxxx" \
-F "file=@sample-invoice.png"

The response has the same shape as /templates/generate: a draft name, description, and fields array that you can review and save.


Using a template

Pass the template's template_id on every OCR upload. OCR requires a selected template, and results are keyed to that template's fields:

curl -X POST "https://netraocr.shivicx.com/api/v1/ocr/upload?template_id=12" \
-u "ak_live_xxxxxxxx:sk_live_xxxxxxxx" \
-F "file=@invoice.pdf"

See OCR → Upload a document.