Templates API
Space-scoped content templates with Jinja2 rendering. Used for recertification requests, notifications, and other templated content.
All endpoints are scoped to a space via the
{slug}path parameter and require Space Admin permissions.
Endpoints Overview
| Method | Endpoint | Description |
|---|---|---|
POST | /spaces/{slug}/templates | Create template |
GET | /spaces/{slug}/templates | List templates |
GET | /spaces/{slug}/templates/{template_id} | Get template |
PATCH | /spaces/{slug}/templates/{template_id} | Update template |
DELETE | /spaces/{slug}/templates/{template_id} | Delete template |
POST | /spaces/{slug}/templates/{template_id}/render | Render preview |
Create Template
POST /spaces/{slug}/templates
Request Body
{
"name": "Recertification Notice",
"slug": "recert-notice",
"category": "recertification",
"content": "## Review Required\n\nPlease review **{{ product_name }}** ({{ product_type }}).\n\n**Criticality:** {{ criticality }}",
"description": "Template for recertification request descriptions"
}
| Field | Type | Required | Description |
|---|---|---|---|
name | string | ✅ | Template display name |
slug | string | ✅ | Unique slug within the space |
category | string | ✅ | Category for filtering (e.g., recertification, notification) |
content | string | — | Jinja2 template body |
description | string | — | Human-readable description |
Returns 409 if a template with the same slug already exists in the space.
List Templates
GET /spaces/{slug}/templates?category=recertification
| Parameter | Type | Description |
|---|---|---|
category | string | Optional filter by category |
Returns: TemplateResponse[]
Get Template
GET /spaces/{slug}/templates/{template_id}
Returns 404 if not found.
Update Template
PATCH /spaces/{slug}/templates/{template_id}
All fields are optional — only provided fields are updated.
{
"content": "Updated template with {{ new_variable }}",
"is_active": false
}
Returns 409 if the new slug conflicts with an existing template.
Delete Template
DELETE /spaces/{slug}/templates/{template_id}
Returns 204 No Content. Returns 404 if not found.
Render Preview
POST /spaces/{slug}/templates/{template_id}/render
Renders the template with the provided context variables. Useful for previewing templates before use.
Request Body
{
"context": {
"product_name": "Customer Orders",
"product_type": "Table",
"criticality": "High"
}
}
Response
{
"rendered": "## Review Required\n\nPlease review **Customer Orders** (Table).\n\n**Criticality:** High"
}
Returns 404 if the template is not found. Returns 400 if rendering fails (e.g., syntax error in template).
Response Model
TemplateResponse
| Field | Type | Description |
|---|---|---|
id | UUID | Template identifier |
space_id | UUID | Space scope |
name | string | Display name |
slug | string | Unique slug |
category | string | Category |
content | string | Jinja2 template body |
description | string | null | Description |
is_active | bool | Whether the template is active |
created_at | string | null | ISO 8601 creation timestamp |
updated_at | string | null | ISO 8601 last update |