Preview
POST /api/preview
Compile inline Typst markup with JSON data and return a PDF preview.
Request Body
json
{
"templateContent": "#let data = json.decode(sys.inputs.at(\"data\"))\n= Hello, #data.name",
"data": {
"name": "World"
}
}| Field | Type | Required | Description |
|---|---|---|---|
templateContent | string | Yes | Typst markup content |
data | object | Yes | JSON data to inject as Typst variables |
variableName | string | No | Custom variable name (default: data) |
Example
bash
curl -X POST http://localhost:3000/api/preview \
-H "Content-Type: application/json" \
-d '\''{
"templateContent": "#let data = json.decode(sys.inputs.at(\"data\"))\n= Hello, #data.name",
"data": { "name": "World" }
}'\'' \
-o preview.pdfResponse
Returns application/pdf with the compiled PDF content.
Error Codes
| Code | Description |
|---|---|
400 | Missing or invalid templateContent or data fields |
413 | Payload too large (max 10 MB) |
429 | Rate limit exceeded for compilation |
500 | Typst compilation error |
Rate Limiting
This endpoint uses the stricter compilation rate limit: 1/4 of the general REPORTS_RATE_LIMIT.