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:

1

Create an account

You can sign up to create a DocuPotion account here.

2

Get your API Key

Generate an API Key in the API Integration tab of your DocuPotion dashboard.

3

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_KEY

Security Best Practice

Never expose your API key in client-side code. Always make API calls from your backend server.

Account

GEThttps://api.docupotion.com/v1/account

Retrieve your account details, including usage and document limits.

Headers

HeaderValue
AuthorizationBearer YOUR_API_KEY

Success Response (200 OK)

{
  "success": true,
  "username": "alex@cranfordtech.com",
  "documents_used": 108,
  "documents_limit": 1500
}

Response Fields

FieldTypeDescription
successbooleanWhether the request was successful
usernamestringThe email address associated with your account
documents_usednumberNumber of documents generated in the current billing period
documents_limitnumberMaximum number of documents allowed in the current billing period

List Templates

GEThttps://api.docupotion.com/v1/templates

Retrieve a list of all templates associated with your account.

Headers

HeaderValue
AuthorizationBearer YOUR_API_KEY

Success Response (200 OK)

{
  "templates": [
    {
      "templateId": "h2h5rsap2rb3opc",
      "templateName": "Invoice"
    },
    {
      "templateId": "nr3k8ho5piy6lfq",
      "templateName": "Meeting Notes Template"
    }
  ]
}

Response Fields

FieldTypeDescription
templatesarrayList of templates in your account
templates[].templateIdstringUnique identifier for the template
templates[].templateNamestringDisplay name of the template

Create Document

POSThttps://api.docupotion.com/v1/create

Generate a PDF document from a template with dynamic data. Returns the PDF as base64 encoded data or a presigned URL.

Headers

HeaderValue
AuthorizationBearer YOUR_API_KEY
Content-Typeapplication/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

ParameterTypeRequiredDescription
templateIdstringRequiredYour PDF template ID
outputstringOptionalChoose 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.
expirationnumberOptionalDuration 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.
formatstringOptionalSpecify the file format. Options: 'pdf' (default) or 'png'.
dataobjectOptionalDynamic data for the template
s3_bucketbooleanOptionalSet 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_keystringOptionalFile 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

200

Success

PDF generated successfully

400

Bad Request

Invalid request parameters

400

Bad Request

s3_bucket is only supported when output is 'url'

400

Bad Request

S3 connection not found. Please connect your S3 bucket in the DocuPotion dashboard.

400

Bad Request

S3 upload failed: access denied. Check your S3 connection in the DocuPotion dashboard.

401

Unauthorized

Invalid or missing API key

404

Not Found

Template ID not found

500

Internal Server Error

Server error - please retry