Skip to content

Templates API ​

Endpoints for managing Typst template files.

List Templates ​

GET /api/templates

Returns all templates with their metadata. If a query parameter is provided, filters by search term.

Query Parameters ​

ParameterTypeDescription
qstringSearch query (optional)

Example ​

bash
curl http://localhost:3000/api/templates

Response ​

json
[
  {
    "name": "universal-template",
    "type": "file",
    "title": "Universal Report",
    "description": "A general-purpose report template",
    "exampleData": { "title": "Report", "body": "Content" }
  },
  {
    "name": "student",
    "type": "folder"
  }
]

Get Template ​

GET /api/templates/:name

Get a template'''s Typst content and metadata.

Path Parameters ​

ParameterDescription
nameTemplate name (supports subfolder paths like student/student-card)

Example ​

bash
curl http://localhost:3000/api/templates/student/student-card

Response ​

json
{
  "content": "#let data = json.decode(sys.inputs.at(\"data\"))...",
  "title": "Student Card",
  "description": "Compact student information card",
  "exampleData": { "name": "Alice Johnson" }
}

Create / Update Template ​

PUT or POST /api/templates/:name

Create a new template or update an existing one.

Path Parameters ​

ParameterDescription
nameTemplate name (supports subfolder paths)

Request Body ​

json
{
  "content": "#let data = json.decode(sys.inputs.at(\"data\"))\n= #data.title",
  "title": "My Report",
  "description": "A sample report template",
  "exampleData": {
    "title": "Hello",
    "body": "World"
  }
}
FieldTypeRequiredDescription
contentstringYesTypst template content (max 1,000,000 chars)
titlestringNoDisplay title for the template metadata
descriptionstringNoDescription for the template metadata
exampleDataobjectNoExample JSON data for preview

Example ​

bash
curl -X PUT http://localhost:3000/api/templates/my-report \
  -H "Content-Type: application/json" \
  -d '\''{
    "content": "#let data = json.decode(sys.inputs.at(\"data\"))\n= #data.title",
    "title": "My Report",
    "description": "A sample report"
  }'\''

Delete Template ​

DELETE /api/templates/:name

Delete a template.

Example ​

bash
curl -X DELETE http://localhost:3000/api/templates/my-report

Response ​

204 No Content


Folders ​

List Folders ​

GET /api/folders

List all template folder names.

Create Folder ​

POST /api/folders

json
{
  "name": "academy"
}

Delete Folder ​

DELETE /api/folders/:name

Delete a template folder (recursive).

bash
curl -X DELETE http://localhost:3000/api/folders/academy

Design and Dev by David Lam