Skip to content

Preview

POST /api/preview

Compile inline Typst markup with JSON data and return a PDF preview.

Request Body

json
{
  "content": "#let data = json.decode(sys.inputs.at(\"data\"))\n= Hello, #data.name",
  "data": {
    "name": "World"
  }
}
FieldTypeRequiredDescription
contentstringYesTypst markup content
dataobjectYesJSON data to inject as Typst variables

Example

bash
curl -X POST http://localhost:3000/api/preview \
  -H "Content-Type: application/json" \
  -d '{
    "content": "#let data = json.decode(sys.inputs.at(\"data\"))\n= Hello, #data.name",
    "data": { "name": "World" }
  }' \
  -o preview.pdf

Response

Returns application/pdf with the compiled PDF content.

Error Codes

CodeDescription
400Missing or invalid content or data fields
413Payload too large (content or data exceeds limits)
429Rate limit exceeded for compilation
500Typst compilation error

Rate Limiting

This endpoint uses the stricter compilation rate limit: 30 requests per 60-second window.

Design and Dev by David Lam