Skip to content

Templates API - Browse & Create Templates

The Templates API lets you browse built-in templates, create custom templates for immediate use, and retrieve template details including schemas.

MethodEndpointDescription
GET/v1/templatesList all built-in templates
POST/v1/templatesCreate a custom template (24h TTL)
GET/v1/templates/:idGet template details and schema
GET/v1/templates/:id/schemaGet template JSON schema only
GET/v1/templates/:id/previewGet PNG thumbnail preview
POST/v1/templates/:id/validateValidate data against template schema

GET /v1/templates

List all available built-in templates with metadata and sample data.

HeaderRequiredDescription
AuthorizationYesBearer gk_your_api_key
ParameterTypeDescription
categorystringFilter by category: quote, invoice, receipt, report, letter, contract, certificate, proposal, shipping, resume, menu, event, packing, purchase-order
searchstringSearch in template name and description
stylestringFilter by style: modern, traditional, minimal, elegant
tagstringFilter by tag: modern, minimal, clean, bold, formal, ats-friendly, etc.
{
"templates": [
{
"id": "invoice-clean",
"name": "Clean Invoice",
"description": "Clear, structured invoice with line items, totals, and payment terms.",
"category": "invoice",
"style": "modern",
"tags": ["modern", "clean", "minimal"],
"sampleData": {
"invoice": { "number": "INV-2024-0042", "date": "January 20, 2024" },
"billTo": { "name": "Sarah Chen", "company": "Northwind Traders" },
"lineItems": [
{ "description": "Brand Identity Package", "quantity": 1, "rate": "4,500.00", "amount": "4,500.00" }
],
"totals": { "subtotal": "4,500.00", "total": "4,500.00" }
}
}
],
"count": 15
}
FieldTypeDescription
templatesarrayArray of template objects
templates[].idstringTemplate ID (use with /v1/create)
templates[].namestringHuman-readable name
templates[].descriptionstringTemplate description
templates[].categorystringDocument category
templates[].stylestringVisual style preset
templates[].tagsarraySearchable tags
templates[].sampleDataobjectExample data for the template
countnumberNumber of templates returned
Terminal window
# List all templates
curl https://api.glyph.you/v1/templates \
-H "Authorization: Bearer gk_your_api_key"
# Filter by category
curl "https://api.glyph.you/v1/templates?category=invoice" \
-H "Authorization: Bearer gk_your_api_key"
# Search templates
curl "https://api.glyph.you/v1/templates?search=professional" \
-H "Authorization: Bearer gk_your_api_key"
# Filter by style and tag
curl "https://api.glyph.you/v1/templates?style=modern&tag=minimal" \
-H "Authorization: Bearer gk_your_api_key"
const response = await fetch('https://api.glyph.you/v1/templates?category=invoice', {
headers: {
'Authorization': 'Bearer gk_your_api_key'
}
});
const { templates, count } = await response.json();
console.log(`Found ${count} invoice templates`);
for (const template of templates) {
console.log(`- ${template.name} (${template.id})`);
console.log(` Style: ${template.style}, Tags: ${template.tags.join(', ')}`);
}
import requests
response = requests.get(
'https://api.glyph.you/v1/templates',
params={'category': 'invoice'},
headers={'Authorization': 'Bearer gk_your_api_key'}
)
data = response.json()
print(f"Found {data['count']} invoice templates")
for template in data['templates']:
print(f"- {template['name']} ({template['id']})")

POST /v1/templates

Create a custom template for immediate use. The returned template ID (tpl_xxx) can be used with /v1/create to generate PDFs.

HeaderRequiredDescription
AuthorizationYesBearer gk_your_api_key
Content-TypeYesapplication/json
{
"name": "my-custom-invoice",
"html": "<html><head><style>body { font-family: sans-serif; padding: 40px; }</style></head><body><h1>Invoice #{{invoice_number}}</h1><p>Client: {{client.name}}</p><p>Total: ${{total}}</p></body></html>",
"schema": {
"invoice_number": { "type": "string" },
"client": { "type": "object" },
"total": { "type": "number" }
},
"description": "Custom invoice template for quick testing"
}
ParameterTypeRequiredDescription
namestringYesTemplate name (1-255 characters)
htmlstringYesMustache HTML template
schemaobjectNoJSON schema defining expected data fields (default: {})
descriptionstringNoHuman-readable description (max 1000 characters)
{
"success": true,
"id": "tpl_a1b2c3d4",
"name": "my-custom-invoice",
"createdAt": "2026-01-28T12:00:00.000Z",
"expiresAt": "2026-01-29T12:00:00.000Z",
"usage": {
"createEndpoint": "/v1/create",
"example": {
"templateId": "tpl_a1b2c3d4",
"data": "{ ...your data matching the schema... }"
}
},
"_links": {
"create": "/v1/create",
"template": "/v1/templates/tpl_a1b2c3d4"
}
}
FieldTypeDescription
successbooleanWhether creation succeeded
idstringTemplate ID (format: tpl_xxx) for use with /v1/create
namestringTemplate name
createdAtstringISO 8601 creation timestamp
expiresAtstringISO 8601 expiration timestamp (24 hours from creation)
usageobjectUsage instructions
_linksobjectHypermedia links for next actions
Terminal window
curl -X POST https://api.glyph.you/v1/templates \
-H "Authorization: Bearer gk_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"name": "quick-receipt",
"html": "<html><head><style>body { font-family: monospace; padding: 20px; } .total { font-size: 24px; font-weight: bold; }</style></head><body><h1>Receipt</h1><p>Date: {{date}}</p><p>Item: {{item}}</p><p class=\"total\">Total: ${{amount}}</p><p>Thank you for your purchase!</p></body></html>",
"schema": {
"date": { "type": "string" },
"item": { "type": "string" },
"amount": { "type": "number" }
},
"description": "Simple receipt for testing"
}'
const response = await fetch('https://api.glyph.you/v1/templates', {
method: 'POST',
headers: {
'Authorization': 'Bearer gk_your_api_key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: 'quick-receipt',
html: `
<html>
<head>
<style>
body { font-family: monospace; padding: 20px; }
.total { font-size: 24px; font-weight: bold; }
</style>
</head>
<body>
<h1>Receipt</h1>
<p>Date: {{date}}</p>
<p>Item: {{item}}</p>
<p class="total">Total: \${{amount}}</p>
<p>Thank you for your purchase!</p>
</body>
</html>
`,
schema: {
date: { type: 'string' },
item: { type: 'string' },
amount: { type: 'number' }
}
})
});
const result = await response.json();
console.log(`Template created: ${result.id}`);
console.log(`Expires: ${result.expiresAt}`);
// Now use it to generate a PDF
const pdfResponse = await fetch('https://api.glyph.you/v1/create', {
method: 'POST',
headers: {
'Authorization': 'Bearer gk_your_api_key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
templateId: result.id,
data: {
date: 'January 28, 2026',
item: 'Premium Subscription',
amount: 99.99
}
})
});
import requests
# Create the template
response = requests.post(
'https://api.glyph.you/v1/templates',
headers={
'Authorization': 'Bearer gk_your_api_key',
'Content-Type': 'application/json'
},
json={
'name': 'quick-receipt',
'html': '''
<html>
<head>
<style>
body { font-family: monospace; padding: 20px; }
.total { font-size: 24px; font-weight: bold; }
</style>
</head>
<body>
<h1>Receipt</h1>
<p>Date: {{date}}</p>
<p>Item: {{item}}</p>
<p class="total">Total: ${{amount}}</p>
<p>Thank you for your purchase!</p>
</body>
</html>
''',
'schema': {
'date': {'type': 'string'},
'item': {'type': 'string'},
'amount': {'type': 'number'}
}
}
)
result = response.json()
template_id = result['id']
print(f"Template created: {template_id}")
print(f"Expires: {result['expiresAt']}")
# Use the template to generate a PDF
pdf_response = requests.post(
'https://api.glyph.you/v1/create',
headers={
'Authorization': 'Bearer gk_your_api_key',
'Content-Type': 'application/json'
},
json={
'templateId': template_id,
'data': {
'date': 'January 28, 2026',
'item': 'Premium Subscription',
'amount': 99.99
}
}
)

GET /v1/templates/:id

Get full template details including JSON schema and sample data. Works for both built-in templates and custom templates (IDs starting with tpl_).

HeaderRequiredDescription
AuthorizationYesBearer gk_your_api_key
ParameterTypeDescription
idstringTemplate ID (e.g., invoice-clean or tpl_a1b2c3d4)
{
"id": "invoice-clean",
"name": "Clean Invoice",
"description": "Clear, structured invoice with line items, totals, and payment terms.",
"type": "builtin",
"schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"invoice": {
"type": "object",
"properties": {
"number": { "type": "string" },
"date": { "type": "string" },
"dueDate": { "type": "string" }
}
},
"billTo": {
"type": "object",
"properties": {
"name": { "type": "string" },
"company": { "type": "string" }
}
},
"lineItems": {
"type": "array",
"items": {
"type": "object",
"properties": {
"description": { "type": "string" },
"quantity": { "type": "number" },
"rate": { "type": "string" },
"amount": { "type": "string" }
}
}
}
}
},
"sampleData": {
"invoice": { "number": "INV-2024-0042", "date": "January 20, 2024" },
"billTo": { "name": "Sarah Chen", "company": "Northwind Traders" },
"lineItems": [
{ "description": "Brand Identity Package", "quantity": 1, "rate": "4,500.00", "amount": "4,500.00" }
]
}
}
{
"id": "tpl_a1b2c3d4",
"name": "my-custom-invoice",
"description": "Custom invoice template for quick testing",
"type": "custom",
"html": "<html>...</html>",
"schema": {
"invoice_number": { "type": "string" },
"client": { "type": "object" },
"total": { "type": "number" }
},
"createdAt": "2026-01-28T12:00:00.000Z",
"expiresAt": "2026-01-29T12:00:00.000Z"
}
FieldTypeDescription
idstringTemplate ID
namestringTemplate name
descriptionstringTemplate description
typestringbuiltin or custom
schemaobjectJSON schema for data validation
sampleDataobjectExample data (built-in templates only)
htmlstringTemplate HTML (custom templates only)
createdAtstringCreation timestamp (custom templates only)
expiresAtstringExpiration timestamp (custom templates only)
Terminal window
# Get a built-in template
curl https://api.glyph.you/v1/templates/invoice-clean \
-H "Authorization: Bearer gk_your_api_key"
# Get a custom template
curl https://api.glyph.you/v1/templates/tpl_a1b2c3d4 \
-H "Authorization: Bearer gk_your_api_key"
const templateId = 'invoice-clean';
const response = await fetch(`https://api.glyph.you/v1/templates/${templateId}`, {
headers: {
'Authorization': 'Bearer gk_your_api_key'
}
});
const template = await response.json();
console.log(`Template: ${template.name}`);
console.log(`Type: ${template.type}`);
console.log(`Schema fields: ${Object.keys(template.schema.properties || template.schema).join(', ')}`);
import requests
template_id = 'invoice-clean'
response = requests.get(
f'https://api.glyph.you/v1/templates/{template_id}',
headers={'Authorization': 'Bearer gk_your_api_key'}
)
template = response.json()
print(f"Template: {template['name']}")
print(f"Type: {template['type']}")
# Use sampleData to generate a PDF immediately
if 'sampleData' in template:
print("Sample data available for testing")

GET /v1/templates/:id/schema

Get only the JSON schema for a built-in template. Useful for AI agents and validation tools.

HeaderRequiredDescription
AuthorizationYesBearer gk_your_api_key
ParameterTypeDescription
idstringBuilt-in template ID (e.g., invoice-clean)

Returns raw JSON Schema with Content-Type: application/schema+json.

{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"invoice": {
"type": "object",
"properties": {
"number": { "type": "string" },
"date": { "type": "string" }
}
},
"lineItems": {
"type": "array",
"items": { ... }
}
},
"required": ["invoice", "lineItems"]
}
Terminal window
curl https://api.glyph.you/v1/templates/invoice-clean/schema \
-H "Authorization: Bearer gk_your_api_key"

GET /v1/templates/:id/preview

Get a PNG thumbnail preview of a built-in template rendered with sample data. Thumbnails are 400x300 pixels and cached for 24 hours.

HeaderRequiredDescription
AuthorizationYesBearer gk_your_api_key
ParameterTypeDescription
idstringBuilt-in template ID (e.g., invoice-clean)

Returns PNG image data with Content-Type: image/png.

Terminal window
curl https://api.glyph.you/v1/templates/invoice-clean/preview \
-H "Authorization: Bearer gk_your_api_key" \
--output preview.png
<img
src="https://api.glyph.you/v1/templates/invoice-clean/preview"
alt="Invoice template preview"
width="400"
height="300"
/>

POST /v1/templates/:id/validate

Validate your data against a template’s JSON schema before generating a PDF. Returns errors for missing required fields and type mismatches.

HeaderRequiredDescription
AuthorizationYesBearer gk_your_api_key
Content-TypeYesapplication/json
ParameterTypeDescription
idstringTemplate ID
{
"data": {
"invoice": { "number": "INV-001" },
"lineItems": [
{ "description": "Consulting", "quantity": 1 }
]
}
}
{
"valid": true,
"templateId": "invoice-clean",
"errors": [],
"warnings": [
{ "field": "invoice.date", "message": "Optional field not provided" },
{ "field": "invoice.dueDate", "message": "Optional field not provided" }
]
}
FieldTypeDescription
validbooleanWhether data passes validation (no errors)
templateIdstringTemplate ID validated against
errorsarrayRequired field or type errors
warningsarrayOptional fields not provided
Terminal window
curl -X POST https://api.glyph.you/v1/templates/invoice-clean/validate \
-H "Authorization: Bearer gk_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"data": {
"invoice": { "number": "INV-001" },
"billTo": { "name": "John Doe" },
"lineItems": [
{ "description": "Consulting", "quantity": 1, "rate": "150.00", "amount": "150.00" }
],
"totals": { "subtotal": "150.00", "total": "150.00" }
}
}'
const data = {
invoice: { number: 'INV-001' },
billTo: { name: 'John Doe' },
lineItems: [{ description: 'Consulting', quantity: 1 }]
};
const response = await fetch('https://api.glyph.you/v1/templates/invoice-clean/validate', {
method: 'POST',
headers: {
'Authorization': 'Bearer gk_your_api_key',
'Content-Type': 'application/json'
},
body: JSON.stringify({ data })
});
const result = await response.json();
if (result.valid) {
console.log('Data is valid, proceeding with PDF generation');
} else {
console.log('Validation errors:', result.errors);
}

IDNameCategoryDescription
quote-modernModern QuotequoteClean, minimal quote with sans-serif fonts
quote-boldBold QuotequoteHigh-impact modern design
quote-professionalProfessional QuotequoteTraditional business style
invoice-cleanClean InvoiceinvoiceStructured invoice with line items
receipt-minimalMinimal ReceiptreceiptCompact receipt layout
report-coverReport Cover PagereportProfessional cover page
contract-simpleSimple ContractcontractClean service agreement
certificate-modernModern CertificatecertificateElegant certificate of achievement
letter-businessBusiness LetterletterProfessional business letter
proposal-basicBasic ProposalproposalProject proposal with timeline
shipping-labelShipping LabelshippingStandard 4x6 shipping label
resumeProfessional ResumeresumeATS-friendly resume template
menuRestaurant MenumenuElegant restaurant menu
event-ticketEvent TicketeventConcert/event ticket with barcode
packing-slipPacking SlippackingWarehouse packing slip
purchase-orderPurchase Orderpurchase-orderFormal procurement document

{
"error": "Validation failed",
"code": "VALIDATION_ERROR",
"details": [
{ "path": ["name"], "message": "Template name is required" }
]
}
{
"error": "Template 'invalid-id' not found",
"code": "TEMPLATE_NOT_FOUND"
}
{
"error": "Template not found or expired",
"code": "TEMPLATE_NOT_FOUND"
}
{
"error": "Failed to create template",
"code": "TEMPLATE_CREATION_ERROR"
}