Generate Your First Document
In this tutorial, you'll generate your first PDF document using the RenderDoc API.
Prerequisites
- A RenderDoc account (sign up free)
- An API key (create one in Settings > API Keys)
Step 1: Get Your API Key
- Log in to your RenderDoc dashboard
- Go to Settings > API Keys
- Click Create API Key
- Give it a name (e.g., "Development")
- Copy the key - you'll only see it once!
# Save your API key as an environment variable
export RENDERDOC_API_KEY="your_api_key_here"
Step 2: Create a Template
Before generating documents, you need a template:
- Go to Templates in the dashboard
- Click Create Template
- Choose PDF Template
- Use the drag-and-drop designer to create your layout
- Add text components with variables like
{{customerName}}and{{invoiceNumber}} - Click Save and note the template ID
For this tutorial, you can also use a sample template from the Template Gallery.
Step 3: Generate a Document
Using cURL
curl -X POST https://api.renderdoc.dev/v1/documents/generate \
-H "Authorization: Bearer $RENDERDOC_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"templateId": "YOUR_TEMPLATE_ID",
"format": "pdf",
"variables": {
"customerName": "Acme Corporation",
"invoiceNumber": "INV-2025-001",
"amount": 1250.00
}
}'
Using Node.js
First, install the SDK:
npm install @renderdoc/sdk
Then generate a document:
import { RenderDoc } from '@renderdoc/sdk';
const client = new RenderDoc({
apiKey: process.env.RENDERDOC_API_KEY
});
async function generateInvoice() {
const result = await client.documents.generate({
templateId: 'YOUR_TEMPLATE_ID',
format: 'pdf',
variables: {
customerName: 'Acme Corporation',
invoiceNumber: 'INV-2025-001',
amount: 1250.00
}
});
console.log('Document generated!');
console.log('Download URL:', result.downloadUrl);
return result;
}
generateInvoice();
Using Python
First, install the SDK:
pip install renderdoc
Then generate a document:
import os
from renderdoc import RenderDoc
client = RenderDoc(api_key=os.environ['RENDERDOC_API_KEY'])
result = client.documents.generate(
template_id='YOUR_TEMPLATE_ID',
format='pdf',
variables={
'customerName': 'Acme Corporation',
'invoiceNumber': 'INV-2025-001',
'amount': 1250.00
}
)
print('Document generated!')
print('Download URL:', result['downloadUrl'])
Step 4: Download the Document
The response includes a downloadUrl - a signed URL to download your generated PDF:
// Using fetch
const response = await fetch(result.downloadUrl);
const buffer = await response.arrayBuffer();
// Save to file
import fs from 'fs';
fs.writeFileSync('invoice.pdf', Buffer.from(buffer));
console.log('Saved to invoice.pdf');
Or simply open the URL in your browser to view the PDF.
Understanding the Response
{
"jobId": "job_abc123def456",
"status": "completed",
"format": "pdf",
"templateId": "tmpl_invoice",
"downloadUrl": "https://storage.renderdoc.dev/documents/abc123.pdf?signature=...",
"expiresAt": "2025-01-15T12:00:00Z"
}
| Field | Description |
|---|---|
jobId | Unique identifier for this generation job |
status | completed means the document is ready |
downloadUrl | Signed URL to download the PDF (expires in 24 hours) |
expiresAt | When the download URL expires |
Next Steps
Now that you've generated your first document:
- Create custom templates with the visual designer
- Generate Excel reports for spreadsheet data
- Batch generate documents for multiple records
- Set up webhooks for async notifications
Troubleshooting
"Template not found" error
Make sure you're using the correct template ID. You can find it in:
- The template's URL in the dashboard
- The template list API:
GET /api/v1/templates
"Missing required variables" error
Check your template's variable definitions. Required variables must be provided in the variables object.
"Quota exceeded" error
You've reached your monthly document generation limit. Upgrade your plan or wait for the next billing cycle.
Congratulations! You've generated your first document with RenderDoc!