Skip to main content

Gen API Quickstart

Generate your first document from a template in under 5 minutes.

Prerequisites

  • A Propper account with API access
  • API credentials from the dashboard

Step 1: Get an Access Token

Exchange your client credentials for an access token with document generation scopes.

curl -X POST "https://auth.propper.ai/oauth2/token" \
-H "Content-Type: application/json" \
-d '{
"grant_type": "client_credentials",
"client_id": "YOUR_CLIENT_ID",
"client_secret": "YOUR_CLIENT_SECRET",
"scope": "docgen:read docgen:write"
}'

Response:

{
"access_token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...",
"token_type": "Bearer",
"expires_in": 3600,
"scope": "docgen:read docgen:write"
}
tip

Tokens expire in 1 hour. Cache them and refresh before expiry.

Step 2: Create a Template

Create a document template with merge field placeholders.

curl -X POST "https://api.propper.ai/v1/docgen/templates" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Invoice Template",
"description": "Standard invoice for customers",
"content": "<h1>Invoice</h1><p>Customer: {{customerName}}</p><p>Amount: {{amount}}</p><p>Date: {{date}}</p>",
"format": "HTML"
}'

Response:

{
"id": "tmpl_abc123",
"name": "Invoice Template",
"description": "Standard invoice for customers",
"format": "HTML",
"status": "ACTIVE",
"version": 1,
"createdAt": "2024-01-15T10:00:00Z"
}

Step 3: Generate a Document

Generate a document by providing merge data for the template placeholders.

curl -X POST "https://api.propper.ai/v1/docgen/documents" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"templateId": "tmpl_abc123",
"mergeData": {
"customerName": "Acme Corp",
"amount": "$1,500.00",
"date": "2024-01-15"
},
"outputFormat": "PDF"
}'

Response:

{
"id": "doc_xyz789",
"templateId": "tmpl_abc123",
"status": "GENERATED",
"outputFormat": "PDF",
"createdAt": "2024-01-15T10:01:00Z"
}

Step 4: Download the Document

Download the generated document.

curl "https://api.propper.ai/v1/docgen/documents/doc_xyz789/download" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-o invoice.pdf

echo "Downloaded: invoice.pdf"

Common Mistakes

Don't forget these

1. Missing merge data fields

// Wrong - missing fields referenced in template
{ mergeData: { customerName: 'Acme Corp' } }

// Correct - all template placeholders provided
{ mergeData: { customerName: 'Acme Corp', amount: '$1,500.00', date: '2024-01-15' } }

2. Invalid output format

// Wrong - unsupported format
{ outputFormat: 'DOCX' }

// Correct - supported formats
{ outputFormat: 'PDF' }
{ outputFormat: 'HTML' }

3. Using wrong scope

# Wrong - read scope can't generate documents
scope: "docgen:read"

# Correct - write scope needed for generation
scope: "docgen:read docgen:write"

What's Next?