Generate Your First Document
In this tutorial, you'll generate your first PDF document using the Rynko API.
Prerequisites
- A Rynko account (sign up free)
- An API key (create one in Settings > API Keys)
Step 1: Get Your API Key
- Log in to your Rynko 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 RYNKO_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.rynko.dev/v1/documents/generate \
-H "Authorization: Bearer $RYNKO_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 @rynko/sdk
Then generate a document:
import { Rynko } from '@rynko/sdk';
const client = new Rynko({
apiKey: process.env.RYNKO_API_KEY
});
async function generateInvoice() {
// Queue document generation (async operation)
const job = await client.documents.generate({
templateId: 'YOUR_TEMPLATE_ID',
format: 'pdf',
variables: {
customerName: 'Acme Corporation',
invoiceNumber: 'INV-2025-001',
amount: 1250.00
}
});
console.log('Job queued:', job.jobId);
// Wait for completion to get download URL
const completed = await client.documents.waitForCompletion(job.jobId);
console.log('Document generated!');
console.log('Download URL:', completed.downloadUrl);
return completed;
}
generateInvoice();
Using Python
First, install the SDK:
pip install rynko
Then generate a document:
import os
from rynko import Rynko
client = Rynko(api_key=os.environ['RYNKO_API_KEY'])
# Queue document generation (async operation)
job = client.documents.generate(
template_id='YOUR_TEMPLATE_ID',
format='pdf',
variables={
'customerName': 'Acme Corporation',
'invoiceNumber': 'INV-2025-001',
'amount': 1250.00
}
)
print(f"Job queued: {job['jobId']}")
# Wait for completion to get download URL
completed = client.documents.wait_for_completion(job['jobId'])
print('Document generated!')
print(f"Download URL: {completed['downloadUrl']}")
Step 4: Download the Document
Once the job completes, you'll have a downloadUrl - a signed URL to download your generated PDF:
// Using fetch
const response = await fetch(completed.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
Initial Response (Queued)
When you first call the generate endpoint, you get a job in queued status:
{
"jobId": "job_abc123def456",
"status": "queued",
"statusUrl": "https://api.rynko.dev/api/v1/documents/jobs/job_abc123def456",
"estimatedWaitSeconds": 5
}
Completed Job
After polling or using waitForCompletion(), you get the completed job with the download URL:
{
"jobId": "job_abc123def456",
"status": "completed",
"format": "pdf",
"templateId": "tmpl_invoice",
"downloadUrl": "https://storage.rynko.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 Rynko!