Skip to main content

Documents API

Generate PDF and Excel documents programmatically from your templates.

Overview

The Documents API allows you to:

  • Generate single documents from templates
  • Batch generate multiple documents
  • Track generation job status
  • Download generated documents via signed URLs

Authentication

All endpoints require authentication via API key:

Authorization: Bearer YOUR_API_KEY

Generate Document

Generate a single document from a template.

POST /api/v1/documents/generate

Request Body

FieldTypeRequiredDescription
templateIdstringYesTemplate ID (UUID, shortId, or slug)
formatstringYesOutput format: pdf or xlsx
variablesobjectNoTemplate variables
filenamestringNoCustom filename (without extension)
metadataobjectNoCustom metadata to attach

Example Request

curl -X POST https://api.renderdoc.dev/v1/documents/generate \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"templateId": "tmpl_invoice",
"format": "pdf",
"variables": {
"invoiceNumber": "INV-2025-001",
"customerName": "Acme Corporation",
"amount": 1250.00,
"lineItems": [
{"description": "Consulting", "quantity": 10, "price": 100},
{"description": "Development", "quantity": 5, "price": 50}
]
},
"filename": "invoice-2025-001"
}'

Response

{
"jobId": "job_abc123def456",
"status": "completed",
"format": "pdf",
"templateId": "tmpl_invoice",
"downloadUrl": "https://storage.renderdoc.dev/documents/abc123.pdf?signature=...",
"expiresAt": "2025-01-15T12:00:00Z"
}

Response Fields

FieldTypeDescription
jobIdstringUnique job identifier
statusstringJob status: pending, processing, completed, failed
formatstringOutput format
templateIdstringTemplate used
downloadUrlstringSigned URL to download document (when completed)
expiresAtstringWhen the download URL expires
errorstringError message (when failed)

Batch Generate

Generate multiple documents in a single request.

POST /api/v1/documents/generate/batch

Request Body

FieldTypeRequiredDescription
templateIdstringYesTemplate ID
formatstringYesOutput format: pdf or xlsx
documentsarrayYesArray of document specifications
documents[].variablesobjectYesVariables for this document
documents[].filenamestringNoCustom filename
documents[].metadataobjectNoCustom metadata

Example Request

curl -X POST https://api.renderdoc.dev/v1/documents/generate/batch \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"templateId": "tmpl_invoice",
"format": "pdf",
"documents": [
{
"variables": {"invoiceNumber": "INV-001", "customerName": "Acme Corp", "amount": 100},
"filename": "invoice-001"
},
{
"variables": {"invoiceNumber": "INV-002", "customerName": "Beta Inc", "amount": 200},
"filename": "invoice-002"
},
{
"variables": {"invoiceNumber": "INV-003", "customerName": "Gamma Ltd", "amount": 300},
"filename": "invoice-003"
}
]
}'

Response

{
"batchId": "batch_xyz789",
"status": "processing",
"totalDocuments": 3,
"completedDocuments": 0,
"failedDocuments": 0,
"createdAt": "2025-01-15T10:00:00Z"
}

Get Job Status

Check the status of a document generation job.

GET /api/v1/documents/jobs/:jobId

Example Request

curl https://api.renderdoc.dev/v1/documents/jobs/job_abc123def456 \
-H "Authorization: Bearer YOUR_API_KEY"

Response

{
"jobId": "job_abc123def456",
"status": "completed",
"format": "pdf",
"templateId": "tmpl_invoice",
"downloadUrl": "https://storage.renderdoc.dev/documents/abc123.pdf?signature=...",
"expiresAt": "2025-01-15T12:00:00Z",
"createdAt": "2025-01-15T10:00:00Z",
"completedAt": "2025-01-15T10:00:05Z"
}

Get Batch Status

Check the status of a batch generation.

GET /api/v1/documents/batches/:batchId

Example Request

curl https://api.renderdoc.dev/v1/documents/batches/batch_xyz789 \
-H "Authorization: Bearer YOUR_API_KEY"

Response

{
"batchId": "batch_xyz789",
"status": "completed",
"totalDocuments": 3,
"completedDocuments": 3,
"failedDocuments": 0,
"documents": [
{
"jobId": "job_001",
"status": "completed",
"downloadUrl": "https://storage.renderdoc.dev/documents/001.pdf?signature=..."
},
{
"jobId": "job_002",
"status": "completed",
"downloadUrl": "https://storage.renderdoc.dev/documents/002.pdf?signature=..."
},
{
"jobId": "job_003",
"status": "completed",
"downloadUrl": "https://storage.renderdoc.dev/documents/003.pdf?signature=..."
}
],
"createdAt": "2025-01-15T10:00:00Z",
"completedAt": "2025-01-15T10:00:15Z"
}

List Jobs

List all document generation jobs.

GET /api/v1/documents/jobs

Query Parameters

ParameterTypeDefaultDescription
pageinteger1Page number
limitinteger20Items per page (max 100)
statusstring-Filter by status
templateIdstring-Filter by template

Example Request

curl "https://api.renderdoc.dev/v1/documents/jobs?limit=10&status=completed" \
-H "Authorization: Bearer YOUR_API_KEY"

Response

{
"data": [
{
"jobId": "job_abc123",
"status": "completed",
"format": "pdf",
"templateId": "tmpl_invoice",
"createdAt": "2025-01-15T10:00:00Z"
}
],
"meta": {
"page": 1,
"limit": 10,
"total": 150,
"totalPages": 15
}
}

Export Jobs

Export document job logs to CSV or JSON format.

GET /api/v1/documents/jobs/export

Query Parameters

ParameterTypeDefaultDescription
formatstringcsvExport format: csv or json
startDatestring-Filter by start date
endDatestring-Filter by end date
statusstring-Filter by status

Response

Returns a file download with the exported data.


Retry Failed Job

Retry a failed document generation job.

POST /api/v1/documents/jobs/:jobId/retry

Path Parameters

ParameterTypeDescription
jobIdstringJob ID to retry

Response

{
"jobId": "job_new_abc123",
"status": "pending",
"message": "Job queued for retry"
}

Delete Job

Delete a single document job record.

DELETE /api/v1/documents/jobs/:jobId

Path Parameters

ParameterTypeDescription
jobIdstringJob ID to delete

Response

Returns 204 No Content on success.


Bulk Delete Jobs

Delete multiple document job records.

DELETE /api/v1/documents/jobs/bulk

Request Body

FieldTypeRequiredDescription
jobIdsarrayYesArray of job IDs to delete

Example Request

{
"jobIds": ["job_001", "job_002", "job_003"]
}

Response

{
"deleted": 3,
"message": "Jobs deleted successfully"
}

Bulk Retry Jobs

Retry multiple failed document generation jobs.

POST /api/v1/documents/jobs/bulk/retry

Request Body

FieldTypeRequiredDescription
jobIdsarrayYesArray of job IDs to retry

Example Request

{
"jobIds": ["job_001", "job_002", "job_003"]
}

Response

{
"queued": 3,
"message": "Jobs queued for retry"
}

Get Analytics

Get document generation analytics for your team.

GET /api/v1/documents/analytics

Query Parameters

ParameterTypeDescription
startDatestringFilter by start date (ISO format)
endDatestringFilter by end date (ISO format)

Example Request

curl "https://api.renderdoc.dev/api/v1/documents/analytics?startDate=2025-01-01&endDate=2025-01-31" \
-H "Authorization: Bearer YOUR_API_KEY"

Response

{
"totalDocuments": 1250,
"completedDocuments": 1200,
"failedDocuments": 50,
"byFormat": {
"pdf": 1000,
"xlsx": 250
},
"byDate": [
{"date": "2025-01-01", "count": 45},
{"date": "2025-01-02", "count": 52}
]
}

Job Statuses

StatusDescription
pendingJob is queued
processingDocument is being generated
completedDocument ready for download
failedGeneration failed (check error field)

Error Codes

CodeHTTPDescription
ERR_TMPL_001404Template not found
ERR_TMPL_002404Document template not found
ERR_TMPL_008400Template schema validation failed
ERR_VALID_002400Variable validation failed
ERR_QUOTA_003429Rate limit exceeded
ERR_QUOTA_008429Monthly document generation quota exceeded
ERR_QUOTA_011429Insufficient document credits
ERR_LIMIT_001400PDF page limit exceeded
ERR_LIMIT_003400Excel row limit exceeded
ERR_LIMIT_007400Loop iteration limit exceeded

See Error Codes for the complete error code reference.


Code Examples

Node.js

import { RenderDoc } from '@renderdoc/sdk';

const client = new RenderDoc({ apiKey: process.env.RENDERDOC_API_KEY });

const result = await client.documents.generate({
templateId: 'tmpl_invoice',
format: 'pdf',
variables: {
invoiceNumber: 'INV-2025-001',
customerName: 'Acme Corporation',
amount: 1250.00
}
});

console.log('Download URL:', result.downloadUrl);

Python

from renderdoc import RenderDoc

client = RenderDoc(api_key=os.environ['RENDERDOC_API_KEY'])

result = client.documents.generate(
template_id='tmpl_invoice',
format='pdf',
variables={
'invoiceNumber': 'INV-2025-001',
'customerName': 'Acme Corporation',
'amount': 1250.00
}
)

print('Download URL:', result['downloadUrl'])

Java

import com.renderdoc.RenderDoc;
import com.renderdoc.models.GenerateRequest;
import com.renderdoc.models.GenerateResult;

RenderDoc client = new RenderDoc(System.getenv("RENDERDOC_API_KEY"));

GenerateResult result = client.documents().generate(
GenerateRequest.builder()
.templateId("tmpl_invoice")
.format("pdf")
.variable("invoiceNumber", "INV-2025-001")
.variable("customerName", "Acme Corporation")
.variable("amount", 1250.00)
.build()
);

System.out.println("Download URL: " + result.getDownloadUrl());

Webhooks

Subscribe to document generation events:

EventDescription
document.generatedDocument successfully generated
document.failedDocument generation failed
batch.completedAll documents in batch completed

See Webhooks for setup instructions.