Skip to main content

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​

  1. Log in to your Rynko 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 RYNKO_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.rynko.dev/api/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/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": "invoice-template",
"downloadUrl": "https://storage.rynko.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/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!