Comprehensive developer guide to integrating with DocPayload's powerful APIs
Our REST API provides programmatic access to DocPayload's enterprise-grade document generation capabilities. Build, manage, and generate documents directly from your applications.
All API requests require secure authentication using API keys or JWT tokens passed in the Authorization header.
https://api.docpayload.com/v1
The Document Definition is a powerful JSON object that describes your PDF layout, styles, and content with enterprise-grade flexibility.
Use bracket notation for inline text styling:
{
"p": "[b]Welcome to Acme Corp Onboarding[/b]",
"style": "roundedTitleStyle"
}
{
"p": "We are delighted to have you join our team. [i]Your skills and experience will be a valuable addition to our company.[/i] Please read the instructions below carefully.",
"style": "solidBorderStyle"
}
Supports: [b]bold[/b], [i]italic[/i], [ib]bold+italic[/ib], [fontcolor, red]colored text[/fontcolor], [fontsize, 14]size[/fontsize], [sub, -5]subscript[/sub], [sup, 7]superscript[/sup]
Example with chemical formulas: Water (H[sub, -5]2[/sup]O) and Carbon Dioxide (CO[sup, 7]2[/sup])
Embed form elements directly in text content:
// Text Input Fields
"p": "First Name: [textfield, firstName,
'Enter your first name', 180|16]"
"p": "Email: [textfield, email,
'Enter your email address', 190|16]"
// Dropdown Selection
"p": "Department: [choicefield, department,
HR | Engineering | Marketing | Sales, 1, 160|16]"
// Checkbox Fields
"p": "Policy: [checkbox, policyAck,
'I have read and understood the policies', 12|12]"
Each border side can have different properties with sophisticated customization:
"roundedTitleStyle": {
"padding": 10,
"fontSize": 18,
"bold": true,
"color": "#000000",
"borderTop": {
"width": 2,
"color": "#FF5733",
"opacity": 1.0,
"type": "SOLID",
"radiusTopLeft": 10
},
"borderRight": {
"width": 1.5,
"color": "#FFC300",
"opacity": 0.8,
"type": "DASHED",
"radiusTopRight": 10
},
"borderBottom": {
"width": 2,
"color": "#DAF7A6",
"opacity": 1.0,
"type": "DOTTED",
"radiusBottomRight": 10
},
"borderLeft": {
"width": 1.5,
"color": "#FF33A1",
"opacity": 0.9,
"type": "SOLID",
"radiusBottomLeft": 10
}
}
Border types: SOLID, DASHED, DOTTED with individual opacity, width, color, and corner radius per side
Create structured tables with form fields and different cell styles:
{
"table": {
"widths": [50, 50],
"rows": [
[
{ "p": "Personal Information",
"style": "headerStyle" },
{ "p": "Contact Details",
"style": "headerStyle" }
],
[
{ "p": "First Name: [textfield, firstName,
'Enter name', 180|16]",
"style": "tableCellStyle" },
{ "p": "Email: [textfield, email,
'Enter email', 190|16]",
"style": "tableCellStyle" }
]
],
"style": "tableStyle"
}
}
Define reusable styles with comprehensive properties:
"styles": {
"roundedTitleStyle": {
"padding": 10,
"fontSize": 18,
"bold": true,
"color": "#000000",
"borderTop": {
"width": 2, "color": "#FF5733",
"type": "SOLID", "radiusTopLeft": 10
}
},
"headerStyle": {
"backgroundColor": "#E2EAF4",
"bold": true
}
}
{
"styles": {
"headerStyle": { "fontSize": 22, "bold": true, "color": "#0a74da" },
"bodyStyle": { "fontSize": 14, "color": "#333", "lineHeight": 1.5 },
"tableStyle": { "border": "1pt solid #ccc", "textAlign": "center" },
"tableHeaderStyle": { "bold": true, "backgroundColor": "#f0f0f0" }
},
"document": {
"pageSize": "A4",
"content": [
{ "h1": "You’re Invited!", "style": "headerStyle" },
{ "p": "Please confirm: [textfield, attendance, '', 150|20]", "style": "bodyStyle" },
{
"ul": {
"symbol": "–",
"style": "bodyStyle",
"items": [
{ "p": "Select role: [choicefield, role, 'Admin | Editor | Viewer', 100|20]" },
{ "p": "Agree to terms: [checkbox, agreeTerms, '', 12|12]" }
]
}
},
{
"table": {
"style": "tableStyle",
"widths": ["25%", "25%", "25%", "25%"],
"rows": [
[
{ "h1": "Field", "style": "tableHeaderStyle" },
{ "h1": "Value", "style": "tableHeaderStyle" },
{ "h1": "Notes", "style": "tableHeaderStyle" },
{ "h1": "Extra", "style": "tableHeaderStyle" }
],
[
{ "p": "[textfield, name, '', 140|20]" },
{ "p": "User avatar: [img, avatar.png, 24|24]" },
{ "p": "Upload before event" },
{ "p": "Additional info" }
]
]
}
}
]
}
}
[textfield, name, placeholder, width|height] — Text input fields[choicefield, name, option1 | option2 | option3, selectedIndex, width|height] — Dropdown selections[checkbox, name, label, width|height] — Checkbox inputs[b]bold[/b], [i]italic[/i], [ib]bold+italic[/ib][fontcolor, red]colored text[/fontcolor], [fontsize, 14]sized text[/fontsize][sub, -5]subscript[/sub], [sup, 7]superscript[/sup] with positioningReal-world Example: The sample demonstrates a complete employee onboarding form with sophisticated styling, multiple form field types, rich text formatting with chemical formulas, and professional table layouts - all defined in a single JSON structure that generates a fully interactive PDF document.
GET /documents — List all documentsPOST /documents — Create a new documentGET /documents/{id} — Get document detailsPUT /documents/{id} — Update documentDELETE /documents/{id} — Delete documentGET /templates — List all templatesPOST /templates — Create a new templateGET /templates/{id} — Get template detailsPOST /generate — Generate document from templateGET /generate/{id}/status — Check generation status