Skip to main content

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

MethodEndpointDescription
POST/spaces/{slug}/templatesCreate template
GET/spaces/{slug}/templatesList 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}/renderRender 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"
}
FieldTypeRequiredDescription
namestringTemplate display name
slugstringUnique slug within the space
categorystringCategory for filtering (e.g., recertification, notification)
contentstringJinja2 template body
descriptionstringHuman-readable description

Returns 409 if a template with the same slug already exists in the space.


List Templates

GET /spaces/{slug}/templates?category=recertification
ParameterTypeDescription
categorystringOptional 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

FieldTypeDescription
idUUIDTemplate identifier
space_idUUIDSpace scope
namestringDisplay name
slugstringUnique slug
categorystringCategory
contentstringJinja2 template body
descriptionstring | nullDescription
is_activeboolWhether the template is active
created_atstring | nullISO 8601 creation timestamp
updated_atstring | nullISO 8601 last update