Skip to main content

Templates API

Manage and retrieve your templates via the API.

List All Templates

Retrieve all templates associated with your account.

GET /api/v1/templates

Authentication

Include your API key using one of these methods:

Header:

x-api-key: YOUR_API_KEY

URL Parameter:

?api_key=YOUR_API_KEY

Example Request

curl -X GET "https://api.pdfgenstudio.com/api/v1/templates" \
-H "x-api-key: sk_live_abc123xyz"

Response

{
"success": true,
"message": "Templates retrieved successfully",
"data": [
{
"id": "cm1abc123def456",
"name": "Invoice Template",
"json": {
"pages": [...],
"variables": [...]
}
},
{
"id": "cm1xyz789ghi012",
"name": "Certificate Template",
"json": {
"pages": [...],
"variables": [...]
}
}
]
}

Response Fields

FieldTypeDescription
idstringUnique template identifier
namestringTemplate display name
jsonobjectSimplified template JSON with pages and variables

Get Template by ID

Retrieve a specific template by its ID.

GET /api/v1/templates/:id

Path Parameters

ParameterTypeRequiredDescription
idstringYesThe template ID

Example Request

curl -X GET "https://api.pdfgenstudio.com/api/v1/templates/cm1abc123def456" \
-H "x-api-key: sk_live_abc123xyz"

Response

{
"success": true,
"message": "Template retrieved successfully",
"data": {
"id": "cm1abc123def456",
"name": "Invoice Template",
"json": {
"pages": [
{
"id": "page_1",
"width": 595,
"height": 842,
"elements": [...]
}
],
"variables": [
{
"name": "customer_name",
"type": "text",
"defaultValue": "John Doe"
},
{
"name": "invoice_number",
"type": "text",
"defaultValue": "INV-001"
}
]
}
}
}

Response Fields

FieldTypeDescription
idstringUnique template identifier
namestringTemplate display name
jsonobjectSimplified template JSON
json.pagesarrayArray of page definitions with elements
json.variablesarrayTemplate variables that can be populated

Error Responses

Template Not Found

{
"success": false,
"error": "Not Found",
"message": "Template not found",
"statusCode": 404
}

Unauthorized

{
"success": false,
"error": "Unauthorized",
"message": "Invalid or missing API key",
"statusCode": 401
}

Usage with Template Renderer

Once you have the template ID, you can use it with the Template Renderer to generate PDFs:

curl -X POST "https://api.pdfgenstudio.com/api/v1/renderer/templates/cm1abc123def456" \
-H "x-api-key: sk_live_abc123xyz" \
-H "Content-Type: application/json" \
-d '{
"data": {
"elements": {
"customer_name": { "text": "Jane Smith" },
"invoice_number": { "text": "INV-2024-001" }
}
}
}' \
--output invoice.pdf
tip

Use the List Templates endpoint to discover available templates and their IDs, then use the Get Template endpoint to inspect the variables you can populate.