Skip to content

POST /v1/preview

POST /v1/preview

Renders a template with your data and returns the HTML preview along with a session ID for subsequent modifications.

HeaderRequiredDescription
AuthorizationYesBearer gk_your_api_key
Content-TypeYesapplication/json
{
"template": "quote-modern",
"data": {
"client": {
"name": "John Smith",
"company": "Acme Corp",
"email": "john@acme.com",
"address": "123 Main St\nNew York, NY 10001"
},
"lineItems": [
{
"description": "Website Design",
"details": "Custom responsive design",
"quantity": 1,
"unitPrice": 3500,
"total": 3500
},
{
"description": "Development",
"quantity": 40,
"unitPrice": 150,
"total": 6000
}
],
"totals": {
"subtotal": 9500,
"discount": 500,
"tax": 720,
"taxRate": 8,
"total": 9720
},
"meta": {
"quoteNumber": "Q-2024-001",
"date": "January 15, 2024",
"validUntil": "February 15, 2024",
"notes": "Payment due within 30 days",
"terms": "Standard terms apply"
},
"branding": {
"logoUrl": "https://example.com/logo.png",
"companyName": "Design Studio",
"companyAddress": "456 Creative Ave\nSan Francisco, CA"
}
}
}
ParameterTypeRequiredDescription
templatestringNoBuilt-in template ID (e.g. "quote-modern"). Defaults to "quote-modern". Alias: templateId
templateIdstringNoAlias for template. Takes precedence when both are provided
savedTemplateIdstring (UUID)NoUUID of a custom template from /v1/templates/saved. Requires a registered API key
savedTemplateNamestringNoHuman-friendly name of a saved template (alternative to savedTemplateId). Resolved server-side
dataobjectYesDocument data object. Structure depends on the template
data.clientobjectYesClient information (for quote templates)
data.client.namestringYesClient name
data.client.companystringNoCompany name
data.client.emailstringNoEmail address
data.client.addressstringNoMailing address
data.lineItemsarrayYesList of line items
data.totalsobjectYesTotals and calculations
data.metaobjectNoDocument metadata
data.brandingobjectNoCompany branding
{
"html": "<!DOCTYPE html><html>...</html>",
"sessionId": "550e8400-e29b-41d4-a716-446655440000"
}
FieldTypeDescription
htmlstringRendered HTML document
sessionIdstringUUID for this editing session

400 Bad Request - Validation failed

{
"error": "Validation failed",
"code": "VALIDATION_ERROR",
"details": [
{
"path": ["data", "client", "name"],
"message": "Required"
}
]
}

401 Unauthorized - Invalid or missing API key

{
"error": "Missing Authorization header",
"code": "HTTP_ERROR"
}

500 Internal Server Error - Server error

{
"error": "Unknown error",
"code": "PREVIEW_ERROR"
}
Terminal window
curl -X POST https://api.glyph.you/v1/preview \
-H "Authorization: Bearer gk_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"template": "quote-modern",
"data": {
"client": {"name": "John Smith"},
"lineItems": [{"description": "Service", "quantity": 1, "unitPrice": 100, "total": 100}],
"totals": {"subtotal": 100, "total": 100}
}
}'
const response = await fetch('https://api.glyph.you/v1/preview', {
method: 'POST',
headers: {
'Authorization': 'Bearer gk_your_api_key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
template: 'quote-modern',
data: {
client: { name: 'John Smith' },
lineItems: [{ description: 'Service', quantity: 1, unitPrice: 100, total: 100 }],
totals: { subtotal: 100, total: 100 }
}
})
});
const { html, sessionId } = await response.json();
console.log('Session ID:', sessionId);
import requests
response = requests.post(
'https://api.glyph.you/v1/preview',
headers={
'Authorization': 'Bearer gk_your_api_key',
'Content-Type': 'application/json'
},
json={
'template': 'quote-modern',
'data': {
'client': {'name': 'John Smith'},
'lineItems': [{'description': 'Service', 'quantity': 1, 'unitPrice': 100, 'total': 100}],
'totals': {'subtotal': 100, 'total': 100}
}
}
)
data = response.json()
print(f"Session ID: {data['sessionId']}")

To list available templates:

Terminal window
curl https://api.glyph.you/v1/preview/templates \
-H "Authorization: Bearer gk_your_api_key"

Response:

{
"templates": [
{
"id": "quote-modern",
"name": "Modern Quote",
"description": "Clean, minimal quote template"
},
{
"id": "quote-professional",
"name": "Professional Quote",
"description": "Traditional business style"
},
{
"id": "quote-bold",
"name": "Bold Quote",
"description": "High-impact modern design"
}
]
}
  • Sessions are created when you call /v1/preview
  • Sessions expire after 1 hour of inactivity
  • Each session tracks the current HTML state and modification history
  • Sessions are tied to your API key for security