Templates support variable interpolation for consistent, dynamic document generation.
List templates
GET /format/v1/templates
Retrieve all format templates for your organization.
cURL
CLI
Typescript
Python
Go
curl https://api.case.dev/format/v1/templates?type=contract \
-H "Authorization: Bearer sk_case_YOUR_API_KEY"
Query parameters
Parameter Type Description typestring Filter by template type (e.g., contract, pleading, letter)
Response
{
"templates" : [
{
"id" : "tmpl_abc123" ,
"name" : "NDA Template" ,
"description" : "Standard non-disclosure agreement template" ,
"type" : "contract" ,
"variables" : [ "party1" , "party2" , "effectiveDate" , "jurisdiction" ],
"tags" : [ "confidentiality" , "standard" ],
"usageCount" : 42 ,
"createdAt" : "2024-01-15T10:30:00Z"
}
]
}
Create template
POST /format/v1/templates
Save a new format template for reuse.
cURL
CLI
Typescript
Python
Go
curl -X POST https://api.case.dev/format/v1/templates \
-H "Authorization: Bearer sk_case_YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Motion Template",
"description": "Standard motion format for California Superior Court",
"type": "pleading",
"content": "# {{motion_title}}\n\n**CASE NO.:** {{case_number}}...",
"variables": [
{ "name": "motion_title", "required": true },
{ "name": "case_number", "required": true }
],
"tags": ["motion", "california"]
}'
Request body
Field Type Required Description namestring Yes Template name descriptionstring No Description of the template typestring No Category: contract, pleading, letter, memo, etc. contentstring Yes Template content with {{variable}} placeholders variablesarray No Variable definitions with names, requirements, and defaults stylesobject No Default styles for this template tagsarray No Tags for organization
Get template
GET /format/v1/templates/{id}
Retrieve a specific template by ID.
cURL
CLI
Typescript
Python
Go
curl https://api.case.dev/format/v1/templates/tmpl_abc123 \
-H "Authorization: Bearer sk_case_YOUR_API_KEY"
Using templates
Reference saved templates when generating documents:
cURL
CLI
Typescript
Python
Go
# CLI (via cURL - no direct CLI command)
curl -X POST https://api.case.dev/format/v1/document \
-H "Authorization: Bearer $CASEDEV_API_KEY " \
-H "Content-Type: application/json" \
-d '{
"content": "",
"output_format": "pdf",
"options": {
"components": [{
"templateId": "tmpl_abc123",
"variables": {
"motion_title": "Motion for Summary Judgment",
"case_number": "2024-CV-12345",
"party_name": "John Doe",
"party_role": "Plaintiff",
"relief_sought": "summary judgment on all claims",
"facts": "On January 1, 2024...",
"argument": "Under California Code of Civil Procedure..."
}
}]
}
}'
Template usage is tracked automatically. The usageCount field shows how many times each template has been used, helping you identify your most valuable templates.
Variable validation
When using a template, the API validates that all required variables are provided:
cURL
CLI
Typescript
Python
Go
# CLI (via cURL - no direct CLI command)
# This will return a 400 error: "Missing required variables: case_number, party_name"
curl -X POST https://api.case.dev/format/v1/document \
-H "Authorization: Bearer $CASEDEV_API_KEY " \
-H "Content-Type: application/json" \
-d '{
"output_format": "pdf",
"options": {
"components": [{
"templateId": "tmpl_abc123",
"variables": {
"motion_title": "Motion for Summary Judgment"
}
}]
}
}'
Error codes
Status Description 400Invalid request or missing required variables 401Invalid or missing API key 404Template not found