Search documentation

Search across all sections and endpoints

FormaTeX
Docsv1

API Reference

Complete reference for the FormaTeX REST API. Compile LaTeX documents to PDF with a single HTTP call.

Quick Example

bash
curl -X POST https://api.formatex.io/api/v1/compile \
  -H "X-API-Key: your-api-key" \
  -H "Content-Type: application/json" \
  -d '{"latex": "\\documentclass{article}\\begin{document}Hello!\\end{document}"}' \
  --output document.pdf

Authentication

Two auth methods: JWT tokens for account management, API keys for compilation.

MethodHeaderUsed For
JWT TokenAuthorization: Bearer <token>User management, billing, admin
API KeyX-API-Key: <key>Compilation endpoints

Users

Manage your profile and view usage statistics. All endpoints require JWT.

API Keys

Create and manage API keys for compilation. All endpoints require JWT.

Compilation

Compile LaTeX to PDF. All compilation endpoints require an API Key.

Companion File Uploads

All compile endpoints accept a files field for bundling images, bibliography files, custom classes, and other assets alongside the main document.

JSON + Base64 Mode

json
{
  "latex": "\\documentclass{article}\\begin{document}\\includegraphics{logo}\\end{document}",
  "engine": "pdflatex",
  "files": [
    { "path": "logo.png", "data": "<base64-encoded-content>" },
    { "path": "refs.bib", "data": "<base64-encoded-content>" }
  ]
}

Multipart mode also supported: Content-Type: multipart/form-data with each file as a files field and path set via the filename attribute.

PlanMax FilesMax File SizeMax Total
Free52 MB5 MB
Pro3015 MB100 MB
Max10030 MB300 MB
Enterprise30050 MB1 GB

Templates

Parameterized LaTeX documents with <<variable>> placeholders. Send data, get PDF — no LaTeX knowledge required for your API consumers.

How it works

  1. Browse the template library or create your own
  2. Send a compile request with variable values
  3. Receive a compiled PDF with all placeholders substituted

Variable schema

FieldTypeDescription
keystringVariable name used in placeholders
typestring | number | dateType validation applied to the value
requiredbooleanWhether the variable must be provided
defaultstringDefault value if not provided
descriptionstringHuman-readable description

Quick example

bash
curl -X POST https://api.formatex.io/api/v1/templates/cover-letter/compile \
  -H "X-API-Key: your-api-key" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{"variables": {"name": "Alice Martin", "company": "Acme Corp"}}' \
  --output cover-letter.pdf

Without the Accept: application/json header, the response is a raw PDF binary.

Public Templates

Curated templates available to all users. No authentication required to list or view. Compilation requires an API key.

User Templates

Create and manage your own parameterized templates. Requires JWT authentication. Available on Pro plan and above.

Webhooks

Register HTTP callbacks to receive real-time notifications on compilation, quota, and plan events. Requires JWT. Failed deliveries are automatically retried up to 5 times with exponential backoff.

EventTrigger
compilation.successCompilation completed successfully
compilation.failedCompilation failed (LaTeX error or timeout)
quota.warningUsage reached 80% of monthly quota
quota.exceededUsage reached 100% — compilations are blocked
plan.changedPlan upgraded, downgraded, or revoked

Event Payload

json
{
  "event": "compilation.success",
  "data": {
    "compilationId": "uuid",
    "engine": "pdflatex",
    "durationMs": 1240,
    "inputSizeBytes": 2048,
    "apiKeyPrefix": "a2e67d28...",
    "timestamp": "2026-02-20T14:30:00Z"
  }
}

If a secret is set, the payload is signed with HMAC-SHA256 delivered in the X-FormaTeX-Signature header.

Billing

Subscription management via Polar.sh. Requires JWT authentication.

Plans

View available plans and their limits. Public endpoint.

Plan Comparison

FeatureFreeProMaxEnterprise
Compilations/mo155002,00015,000
Timeout30s120s300s300s
Max Size1 MB10 MB25 MB50 MB
Compilation Runs13510
API Keys251550
EnginesAll 2All 4All 4All 4
At LimitHard blockSoft limitSoft limitSoft limit

MCP Server

Compile LaTeX directly from AI agents — Claude Desktop, Cursor, Claude Code, n8n, and more — with zero local TeX Live installation. Uses your FormaTeX API key for authentication.

Available Tools

fix_latexPrompt

Analyzes compilation errors, finds root causes, and returns corrected LaTeX source. Pass it your LaTeX source and error log.

“Use the fix_latex prompt to help me fix this error: [paste error log]”

PDF output: Compiled PDFs are returned as base64 text in the tool result. Ask your agent to decode and save it: “Save the PDF to document.pdf”. Claude Code writes the file directly; Claude Desktop provides a one-liner decode script.

Setup

How it works

Connect via URL to the hosted MCP server — no binary download. Ideal for teams sharing one MCP server, no-code platforms (n8n, Make.com), and cloud-based AI agents.

Hosted server

https://mcp.formatex.io/mcp

Configure your AI client

No binary needed — just add the URL and your API key:

json
{
  "mcpServers": {
    "formatex": {
      "url": "https://mcp.formatex.io/mcp",
      "headers": {
        "Authorization": "Bearer fex_your_api_key_here"
      }
    }
  }
}

Health check

bash
curl https://mcp.formatex.io/health
# → {"status":"ok","service":"formatex-mcp","version":"1.0.0"}

Troubleshooting

Errors

All errors return a consistent JSON format with an error message and optional context.

json
{
  "error": "human-readable error message",
  "plan": "free",
  "limit": 100,
  "used": 100
}

Status Codes

CodeMeaning
400Invalid request body
401Missing or invalid authentication
403Plan limit violated or account deactivated
404Resource not found
409Conflict (e.g., email already registered)
422Compilation failed
429Rate limit exceeded
503Billing not configured

Rate Limits

Endpoint GroupLimit
Auth20 req/min
User management60 req/min
Billing20 req/min
Admin60 req/min
Compilation100 req/min

Ready to start compiling?

Get your API key in 30 seconds. 15 free compilations every month.

One quick thing

We track anonymous usage — page views, feature usage, compilation events — to understand what works and what doesn't. No ads, no personal data, no third-party sharing.

Cookie policy