Skip to main content

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

  1. Log in to your RenderDoc dashboard
  2. Go to Settings > API Keys
  3. Click Create API Key
  4. Give it a name (e.g., "Development")
  5. 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:

  1. Go to Templates in the dashboard
  2. Click Create Template
  3. Choose PDF Template
  4. Use the drag-and-drop designer to create your layout
  5. Add text components with variables like {{customerName}} and {{invoiceNumber}}
  6. 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"
}
FieldDescription
jobIdUnique identifier for this generation job
statuscompleted means the document is ready
downloadUrlSigned URL to download the PDF (expires in 24 hours)
expiresAtWhen the download URL expires

Next Steps

Now that you've generated your first document:

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!