DocuPotion API
Generate beautiful PDF documents programmatically with our simple REST API
Getting Started
DocuPotion provides a simple REST API to generate PDF documents from your templates. Follow these three steps to get started:
Create an account
You can sign up to create a DocuPotion account here.
Get your API Key
Generate an API Key in the API Integration tab of your DocuPotion dashboard.
Design a template
Use our drag and drop editor to design your PDF. You can find the drag and drop editor here.
Authentication
All API requests must include your API key in the Authorization header:
Authorization: Bearer YOUR_API_KEYSecurity Best Practice
Never expose your API key in client-side code. Always make API calls from your backend server.
Account
https://api.docupotion.com/v1/accountRetrieve your account details, including usage and document limits.
Headers
| Header | Value |
|---|---|
| Authorization | Bearer YOUR_API_KEY |
Success Response (200 OK)
{
"success": true,
"username": "alex@cranfordtech.com",
"documents_used": 108,
"documents_limit": 1500
}Response Fields
| Field | Type | Description |
|---|---|---|
| success | boolean | Whether the request was successful |
| username | string | The email address associated with your account |
| documents_used | number | Number of documents generated in the current billing period |
| documents_limit | number | Maximum number of documents allowed in the current billing period |
List Templates
https://api.docupotion.com/v1/templatesRetrieve a list of all templates associated with your account.
Headers
| Header | Value |
|---|---|
| Authorization | Bearer YOUR_API_KEY |
Success Response (200 OK)
{
"templates": [
{
"templateId": "h2h5rsap2rb3opc",
"templateName": "Invoice"
},
{
"templateId": "nr3k8ho5piy6lfq",
"templateName": "Meeting Notes Template"
}
]
}Response Fields
| Field | Type | Description |
|---|---|---|
| templates | array | List of templates in your account |
| templates[].templateId | string | Unique identifier for the template |
| templates[].templateName | string | Display name of the template |
Create Document
https://api.docupotion.com/v1/createGenerate a PDF document from a template with dynamic data. Returns the PDF as base64 encoded data or a presigned URL.
Headers
| Header | Value |
|---|---|
| Authorization | Bearer YOUR_API_KEY |
| Content-Type | application/json |
Request Format
Request Body
{
"templateId": "your_template_id",
"output": "base64", // "base64" or "url"
"expiration": 60, // minutes (1-10080)
"format": "pdf", // "pdf" or "png"
"s3_bucket": true, // optional: upload to your own S3
"s3_key": "path/to/file", // optional: custom S3 key
"data": {
// Your dynamic data here
// Must match template variables
}
}Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| templateId | string | Required | Your PDF template ID |
| output | string | Optional | Choose between 'base64' (default) or 'url'. When 'url' is selected, a presigned URL link to the PDF is returned instead of base64 data. When combined with s3_bucket, the file is uploaded to your own S3 bucket. |
| expiration | number | Optional | Duration in minutes (1-10080) for how long the presigned URL remains valid. Only applicable when output is set to 'url'. Works with both DocuPotion storage and your own S3 bucket. Default: 60 minutes. |
| format | string | Optional | Specify the file format. Options: 'pdf' (default) or 'png'. |
| data | object | Optional | Dynamic data for the template |
| s3_bucket | boolean | Optional | Set to true to upload to your own connected S3 bucket instead of DocuPotion storage. Requires output: "url". You must connect your S3 bucket in the DocuPotion dashboard before using this parameter. |
| s3_key | string | Optional | File path and name in S3 (without extension), e.g. invoices/2024/INV-001. If omitted, auto-generates as {templateId}-{timestamp}. Only used when s3_bucket is set. |
Response Format
Success Response (200 OK)
When output is 'base64' (default):
{
"success": true,
"base64": "JVBERi0xLjQK...."
}When output is 'url':
{
"success": true,
"url": "https://s3.amazonaws.com/bucket/file.pdf?..."
}Error Response
{
"success": false,
"error": "Not Found",
"message": "Template not found: 8qzsaaoxdrmdtvzf"
}Code Examples
const response = await fetch('https://api.docupotion.com/v1/create', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
templateId: 'your_template_id',
output: 'url', // Optional: 'base64' or 'url'
expiration: 60, // Optional: minutes (1-10080)
format: 'pdf', // Optional: 'pdf' or 'png'
data: {
name: 'John Doe',
invoice_number: 'INV-001',
items: [
{ description: 'Product A', quantity: 2, price: 50.00 },
{ description: 'Product B', quantity: 1, price: 75.00 }
],
total: 175.00
}
})
});
const result = await response.json();
console.log('PDF URL:', result.url);Error Handling
HTTP Status Codes
200Success
PDF generated successfully
400Bad Request
Invalid request parameters
400Bad Request
s3_bucket is only supported when output is 'url'
400Bad Request
S3 connection not found. Please connect your S3 bucket in the DocuPotion dashboard.
400Bad Request
S3 upload failed: access denied. Check your S3 connection in the DocuPotion dashboard.
401Unauthorized
Invalid or missing API key
404Not Found
Template ID not found
500Internal Server Error
Server error - please retry