Templates API
Endpoints for managing Typst template files.
List Templates
GET /api/templates
Returns all templates. If a query parameter is provided, filters by search term.
Query Parameters
| Parameter | Type | Description |
|---|---|---|
q | string | Search query (optional) |
Example
bash
curl http://localhost:3000/api/templatesResponse
json
[
{
"name": "universal-template",
"type": "file",
"title": "Universal Report",
"description": "A general-purpose report template",
"exampleData": { "title": "Report", "body": "Content" }
},
{
"name": "student",
"type": "folder"
}
]Create Folder
POST /api/folders
Create a new template folder.
Request Body
json
{
"name": "academy"
}| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Folder name |
Get Template
GET /api/templates/:name
Get a template's Typst content.
Path Parameters
| Parameter | Description |
|---|---|
name | Template name (supports subfolder paths like student/student-card) |
Example
bash
curl http://localhost:3000/api/templates/student/student-cardResponse
Returns text/typst with the raw template content.
Create / Update Template
PUT /api/templates/:name
Create a new template or update an existing one.
Path Parameters
| Parameter | Description |
|---|---|
name | Template name (supports subfolder paths) |
Request
Send raw Typst content as the body with Content-Type: text/typst.
Example
bash
curl -X PUT http://localhost:3000/api/templates/my-report \
-H "Content-Type: text/typst" \
-d '#let data = json.decode(sys.inputs.at("data"))
= #data.title
#data.body'Optionally send JSON metadata:
bash
curl -X PUT "http://localhost:3000/api/templates/my-report?meta=1" \
-H "Content-Type: application/json" \
-d '{
"title": "My Report",
"description": "A sample report",
"exampleData": { "title": "Hello" }
}'Delete Template
DELETE /api/templates/:name
Delete a template.
Example
bash
curl -X DELETE http://localhost:3000/api/templates/my-reportResponse
204 No Content
List Folders
GET /api/folders
List all template folders.
Delete Folder
DELETE /api/folders
Delete a template folder.
Request Body
json
{
"name": "academy"
}