Quickstart
This converts a Word document to PDF in one request. It takes a few minutes and costs nothing: test keys run real conversions for free.
-
Make a test key. Sign in to the dashboard, open API keys and choose Make a key, with Test as its mode. Copy the key: it’s shown once. Then make it available to your code:
Terminal window export FORMATJET_API_KEY=fj_test_… -
Get a file to convert. Any Word document will do, or our sample:
Terminal window curl -O https://formatjet.com/docs/samples/report.docx -
Convert it. Send the file to
POST /v1/convertwith the format you want (to=pdf). The TypeScript and Python use our SDKs: install one first withnpm install @formatjet/sdkorpip install formatjet.Terminal window curl "https://api.formatjet.com/v1/convert?to=pdf" \-H "Authorization: Bearer $FORMATJET_API_KEY" \-F file=@report.docx \-o report.pdfquickstart.ts import { readFile, writeFile } from 'node:fs/promises';import { FormatJet } from '@formatjet/sdk';const formatjet = new FormatJet(); // reads FORMATJET_API_KEYconst result = await formatjet.convert({ data: await readFile('report.docx'), filename: 'report.docx' },{ to: 'pdf' },);await writeFile('report.pdf', result.file.data);quickstart.py from formatjet import FormatJetformatjet = FormatJet() # reads FORMATJET_API_KEYresult = formatjet.convert("report.docx", to="pdf")result.file.save("report.pdf")The TypeScript runs as it is on Node.js 22.18 or later (
node quickstart.ts) or Bun; the Python needs Python 3.11 or later. -
Open
report.pdf. That’s the converted file.
What happened
Section titled “What happened”The API detected that the file is a DOCX from its bytes, ran it through the Word to PDF conversion and answered with the PDF. The answer’s headers say what it did:
| Header | What it says |
|---|---|
FormatJet-Credits |
Credits charged: 0 with a test key |
FormatJet-Engine |
The engine and its version |
FormatJet-Job-Id |
The job behind the request, which GET /v1/jobs/{id} shows |
FormatJet-Request-Id |
Quote it if you contact us |
If something is wrong, the answer is a problem document instead of the file, with a code your code can branch on. With curl, it’s written to report.pdf: open it in a text editor to read it.
- Test keys take files up to 1 MB and run 100 jobs a day. Make a live key (
fj_live_…) to convert larger files on your plan’s credits: limits has the numbers. POST /v1/converttakes files up to 25 MB. For larger files, files at a URL, or to be told when a conversion ends, use jobs.GET /v1/operationslists every conversion with its options; the reference shows the fields.- The SDKs also upload larger files, wait for jobs, retry safely and check webhook signatures.