DocuPotion API
Generate beautiful PDFs programmatically with our simple REST API
Getting Started
DocuPotion provides a simple REST API to generate PDFs from your templates. Follow these three steps to get started:
Create an account
You can sign up to create a DocuPotion account here.
Generate an API Key
Generate an API Key in the 'My Account' 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.
API Endpoints
https://api.docupotion.com/v1/createGenerate a PDF 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"
"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. |
| expiration | number | Optional | Duration in minutes (1-10080) for how long the presigned URL remains valid. Only applicable when output is set to 'url'. |
| format | string | Optional | Specify the file format. Options: 'pdf' (default) or 'png'. |
| data | object | Optional | Dynamic data for the template |
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
401Unauthorized
Invalid or missing API key
404Not Found
Template ID not found
500Internal Server Error
Server error - please retry