Make
Make’s HTTP app calls the API, and its Webhooks app hears when a job finishes. The overview explains the parts these settings use.
Convert a file
Section titled “Convert a file”Add the HTTP app’s Make a request module after the module that has the file, and set:
| Setting | Value |
|---|---|
| URL | https://api.formatjet.com/v1/convert?conversion=word-to-pdf&response=job, with a slug from GET /v1/operations in place of word-to-pdf |
| Method | POST |
| Headers | Authorization: Bearer and your API key, such as Bearer fj_live_…. FormatJet-Client: make-http |
| Body content type | multipart/form-data, with one field named file of the File type, mapped from the module that has the file |
| Parse response | Yes |
| Timeout | At least 40 seconds: the API waits up to 30 for the conversion. Make allows up to 300 |
The answer is the job. When its status is completed, its outputs hold the files, each with a url that needs no key until its expires_at. Add the HTTP app’s Download a file module with the first output’s url, and map the file it gives into the next module (an email attachment, a storage upload).
To keep your key out of the module’s settings, use the API key authentication type with a keychain that sends it in the Authorization header, as Bearer fj_live_….
The same request in curl, asking for the file itself (response=file) rather than the job:
curl -sS --fail-with-body "https://api.formatjet.com/v1/convert?conversion=pdf-to-markdown&response=file" \ -H "Authorization: Bearer $FORMATJET_API_KEY" \ -H "FormatJet-Client: n8n-http" \ -F file=@report.pdf \ -o report.mdMake limits the size of files a scenario handles, by Make plan; the API’s own limits are on Limits.
Conversions that take longer
Section titled “Conversions that take longer”If a conversion hasn’t finished within 30 seconds, the answer is 202 and the job’s status is still queued or processing. For files that may take that long (scans read with OCR, long recordings), let the job tell a second scenario when it’s done: add a field named webhook (Text) to the body, with your custom webhook’s address from below. The first scenario can end there.
Start a scenario when a job finishes
Section titled “Start a scenario when a job finishes”- Start a scenario with the Webhooks app’s Custom webhook trigger, add a webhook, and copy its address (
https://hook.…make.com/…). - Either send each job’s events there with its
webhookfield, as above, or add the address as a webhook endpoint for every job you choose: in the dashboard’s Webhooks page, or with the request below. Narrow an endpoint withconversionsormetadata.
curl https://api.formatjet.com/v1/webhooks \ -H "Authorization: Bearer $FORMATJET_API_KEY" \ -H "Content-Type: application/json" \ -d '{"url": "https://hooks.example.com/formatjet/reports", "events": ["job.completed", "job.failed"], "conversions": ["pdf-to-markdown"], "metadata": {"workflow": "reports"}}'Make answers each event at once, which is what we need: we wait 10 seconds for an answer. The event’s data.job is the job, with its status, outputs and metadata.
Check it’s ours before you act on it: add a Make a request module with the method GET, the URL https://api.formatjet.com/v1/jobs/ followed by the event’s data.job.id, and your key, and use that answer in the rest of the scenario, never the event’s: a request that didn’t come from us can’t make the scenario act on a file or a status we didn’t give. It can still name one of your real jobs again if someone learns the webhook’s address, so keep the address private, and have the scenario skip a job it has already handled and one whose metadata isn’t this scenario’s. (Only the FormatJet-Signature header, there with the webhook’s Get request headers on, proves a request is ours: see Check the signature.)
An event can arrive twice, with the same id. A data store keyed on the job’s id lets a scenario skip a job it has handled, which covers both. Add a filter on the event’s mode too: test jobs’ events say test, and a scenario for real work should skip them.