API Documentation
Integrate DocServant into your systems to extract structured data from documents.
How the DocServant API works
DocServant uses a template-first approach to document extraction:
- Templates define the structure of extracted data
- Templates are created once in DocServant Studio
- The API processes documents against a template
- All processing is asynchronous
- Results are delivered via webhooks
Templates
Templates are the foundation of DocServant's extraction model. Every API request references a template ID.
What templates define
- The fields to extract from documents
- Data types and formats for each field
- How fields map to spreadsheet columns
- Validation rules and transformations
Creating templates
Templates are created and managed in DocServant Studio. Upload a sample document, define your columns, and the template is ready to use via the API.
Quick Start
The typical workflow for integrating DocServant:
Create a template in DocServant Studio
Upload a sample document, define columns, and configure extraction settings.
Generate an API key
Go to the Developers section in your account to create and manage API keys.
Send documents to the API with a template ID
POST documents to /jobs referencing your template.
Receive structured results via webhook
Configure a webhook endpoint to receive job completion notifications with output URLs.
Authentication
All API requests must include your API key in the Authorization header using the Bearer scheme.
Authorization: Bearer sk_live_your_api_key_hereRate Limits
Rate limits are applied per API key and vary by plan. Exceeding your rate limit will result in a 429 Too Many Requests response. Check the X-RateLimit-Remaining header to monitor your usage.
Jobs
Jobs represent document processing requests. When you submit a document, a job is created and enters the processing queue. Jobs progress through these statuses:
queued— Job is waiting to be processedprocessing— Document is being analyzed and data extractedcompleted— Extraction finished successfullyfailed— An error occurred during processing
Outputs
Completed jobs produce two output formats:
- JSON output — Structured data ideal for programmatic use
- XLSX output — Ready-to-use spreadsheet file
Both outputs are accessible via signed URLs that expire after 24 hours.
Endpoints
All endpoints are relative to the base URL:
https://api.docservant.com/v1Submit a Job
/jobsSubmit a document for extraction using a specified template.
Request Fields
| Field | Type | Description |
|---|---|---|
templateId* | string | The ID of the template to use for extraction |
file* | file | The document file (PDF, DOCX, PNG, JPG) |
callbackUrl | string | Optional webhook URL for this specific job |
Response Example
{
"jobId": "job_abc123def456",
"status": "queued",
"templateId": "tpl_xyz789",
"createdAt": "2026-01-15T10:30:00Z"
}cURL Example
curl -X POST https://api.docservant.com/v1/jobs \
-H "Authorization: Bearer sk_live_your_api_key" \
-F "templateId=tpl_xyz789" \
-F "file=@invoice.pdf"Get Job Status
/jobs/{jobId}Check the status of a job and retrieve outputs when complete.
Response Example
{
"jobId": "job_abc123def456",
"status": "completed",
"templateId": "tpl_xyz789",
"createdAt": "2026-01-15T10:30:00Z",
"completedAt": "2026-01-15T10:30:45Z",
"outputs": {
"jsonUrl": "https://storage.docservant.com/outputs/job_abc123.json?token=...",
"xlsxUrl": "https://storage.docservant.com/outputs/job_abc123.xlsx?token=..."
}
}For failed jobs, the response includes an error field with details:
{
"jobId": "job_abc123def456",
"status": "failed",
"error": {
"code": "EXTRACTION_FAILED",
"message": "Unable to extract data from document. The file may be corrupted or in an unsupported format."
}
}Webhooks
Why webhooks?
Document processing is asynchronous — extraction may take seconds to minutes depending on document complexity. Rather than polling the API, webhooks notify your server when jobs complete.
- Results may take time to generate
- Webhooks are the primary delivery mechanism
- Webhooks are sent for both success and failure states
Configure your webhook endpoint in the Developers section after signing in.
Events
job.completed— Fired when a job finishes successfullyjob.failed— Fired when a job fails
Payload Example
{
"event": "job.completed",
"jobId": "job_abc123def456",
"templateId": "tpl_xyz789",
"status": "completed",
"completedAt": "2026-01-15T10:30:45Z",
"outputs": {
"jsonUrl": "https://storage.docservant.com/outputs/job_abc123.json?token=...",
"xlsxUrl": "https://storage.docservant.com/outputs/job_abc123.xlsx?token=..."
}
}For failed jobs:
{
"event": "job.failed",
"jobId": "job_abc123def456",
"templateId": "tpl_xyz789",
"status": "failed",
"error": {
"code": "EXTRACTION_FAILED",
"message": "Unable to extract data from document."
}
}Webhook Security
All webhook requests are signed so you can verify they're from DocServant. Each request includes these headers:
X-DocServant-Signature: sha256=a1b2c3d4e5f6...
X-DocServant-Timestamp: 1705312245To verify the signature, compute an HMAC-SHA256 of the timestamp and request body using your webhook secret, then compare it to the signature header. Reject requests with timestamps older than 5 minutes to prevent replay attacks.
Error Handling
Jobs may fail due to unreadable documents, invalid templates, or processing errors. Failed jobs return a webhook event with error details. Clients should handle retries where appropriate.
HTTP Status Codes
| Code | Meaning |
|---|---|
200 | Success |
400 | Bad request — Check your request body or parameters |
401 | Unauthorized — Invalid or missing API key |
403 | Forbidden — API access disabled for this template |
404 | Not found — Job or template doesn't exist |
429 | Rate limited — Too many requests, slow down |
500 | Server error — Something went wrong on our end |
Rate Limits by Plan
| Plan | Requests/minute | Requests/day |
|---|---|---|
| Free | 10 | 100 |
| Pro | 100 | 5,000 |
| Business | 500 | 50,000 |
Examples
Extract Invoices into JSON
Submit an invoice for extraction and fetch the structured JSON output:
# Submit the invoice
curl -X POST https://api.docservant.com/v1/jobs \
-H "Authorization: Bearer sk_live_your_api_key" \
-F "templateId=tpl_invoices" \
-F "file=@invoice.pdf"
# Response: { "jobId": "job_abc123", "status": "queued" }
# Poll for completion (or use webhooks)
curl https://api.docservant.com/v1/jobs/job_abc123 \
-H "Authorization: Bearer sk_live_your_api_key"
# When status is "completed", fetch the JSON output
curl "https://storage.docservant.com/outputs/job_abc123.json?token=..."Bulk Upload and Append to Workbook
When you submit multiple documents with the same template, each job produces its own output files. To consolidate results, fetch individual JSON outputs and merge them in your application, or download each XLSX and combine sheets programmatically.
# Submit multiple documents
for file in invoices/*.pdf; do
curl -X POST https://api.docservant.com/v1/jobs \
-H "Authorization: Bearer sk_live_your_api_key" \
-F "templateId=tpl_invoices" \
-F "file=@$file"
doneHandle Webhook Callback (Node.js)
const express = require('express');
const crypto = require('crypto');
const app = express();
app.use(express.json());
app.post('/webhooks/docservant', (req, res) => {
const signature = req.headers['x-docservant-signature'];
const timestamp = req.headers['x-docservant-timestamp'];
// Verify signature
const payload = timestamp + '.' + JSON.stringify(req.body);
const expected = 'sha256=' + crypto
.createHmac('sha256', process.env.WEBHOOK_SECRET)
.update(payload)
.digest('hex');
if (signature !== expected) {
return res.status(401).send('Invalid signature');
}
// Process the event
const { event, jobId, outputs } = req.body;
if (event === 'job.completed') {
console.log(`Job ${jobId} completed!`);
// Fetch outputs.jsonUrl and process the data
}
res.status(200).send('OK');
});Changelog
January 2026
Webhooks Added
Real-time notifications for job completion and failure events.
December 2025
API v1 Released
Initial release of the DocServant API with job submission and status endpoints.