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"
}
}| Field | Type | Required | Description |
|---|---|---|---|
content | string | Yes | Typst markup content |
data | object | Yes | JSON 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.pdfResponse
Returns application/pdf with the compiled PDF content.
Error Codes
| Code | Description |
|---|---|
400 | Missing or invalid content or data fields |
413 | Payload too large (content or data exceeds limits) |
429 | Rate limit exceeded for compilation |
500 | Typst compilation error |
Rate Limiting
This endpoint uses the stricter compilation rate limit: 30 requests per 60-second window.