Skip to content

Zapier, Make and n8n

Automation platforms can call the FormatJet API with their own HTTP tools: Webhooks by Zapier, Make’s HTTP app and n8n’s HTTP Request node. Each guide shows the settings:

You need an API key from the dashboard’s API page, sent as Authorization: Bearer fj_live_…. A test key (fj_test_…) runs real conversions for free while you build: see test mode.

Add a FormatJet-Client header naming the tool, such as zapier-webhooks, make-http or n8n-http. It’s optional. We count it with our usage figures, to learn which tools you use, and keep it nowhere else.

POST /v1/convert takes one file and answers with the converted file. Send it as multipart/form-data, the file in a file part (up to 25 MB), and say what to make in the query, as in the quickstart. Add response=file to get the file back whatever Accept header the platform sends: some ask for JSON first by default, which would get you the job instead. response=job asks for the job, with its download URL.

Terminal window
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.md

Some platforms pass files between steps as links rather than as files. Send the link instead: a url part in place of file, or POST /v1/jobs with "input": {"url": …}. We fetch it, up to your plan’s file size, so it must work without signing in: a shared or signed link does. Inputs has the rules.

POST /v1/convert waits up to 30 seconds. If the conversion hasn’t finished by then, the answer is 202 with the job, which carries on. A platform’s step has a time limit of its own, so wait lets the request answer sooner: set it a few seconds under the step’s limit. Then either:

  • Ask again. GET /v1/jobs/{id}?wait=… answers as soon as the job ends, or after up to 30 seconds, so a loop of these needs no pause.
  • Let the job tell you. Give it a webhook: a webhook part of POST /v1/convert, or a field of POST /v1/jobs. When the job ends, its event goes there, and the platform starts a second workflow with it.

This makes a job from a link, waits for it and downloads the output:

integrations-url.sh
#!/usr/bin/env bash
# Needs curl and jq.
set -euo pipefail
API=https://api.formatjet.com/v1
AUTH="Authorization: Bearer $FORMATJET_API_KEY"
# 1. A job from the file's address, as a platform that passes files as links makes it.
job=$(curl -sS --fail-with-body "$API/jobs" -H "$AUTH" -H "Content-Type: application/json" \
-H "FormatJet-Client: zapier-webhooks" \
-d '{"input": {"url": "https://formatjet.com/docs/samples/report.pdf"},
"steps": [{"op": "convert", "conversion": "pdf-to-markdown"}],
"metadata": {"workflow": "reports"}}')
id=$(jq -r .id <<< "$job")
# 2. Ask until it ends: each answer comes as soon as the job ends, or after 30 seconds.
status=$(jq -r .status <<< "$job")
until [[ $status == completed || $status == failed || $status == canceled ]]; do
job=$(curl -sS --fail-with-body "$API/jobs/$id?wait=30" -H "$AUTH")
status=$(jq -r .status <<< "$job")
done
[[ $status == completed ]] || { jq .error <<< "$job"; exit 1; }
# 3. Download the output with the key: the API redirects to the file's own URL, and curl
# leaves the key off when a redirect leads to another host.
curl -sS --fail-with-body -L "$API/jobs/$id/outputs/0" -H "$AUTH" -o report.md

Each output’s url works without your key until its expires_at: hand it to the next step as it is. Platforms that add your key to every request to api.formatjet.com can use GET /v1/jobs/{id}/outputs/0 instead (the first output; 1 for the second). It takes the key and redirects to the output’s URL, and HTTP clients leave the key off when a redirect leads to another host.

The platforms’ webhook triggers (Zapier’s Catch Hook, Make’s Custom webhook, n8n’s Webhook node) give you an address that starts a workflow when something is sent to it. There are two ways to send a job’s event there:

  • The job’s own webhook, as above: that job’s events only.
  • A webhook endpoint, made in the dashboard’s Webhooks page or with POST /v1/webhooks: every job of its mode, or only some. conversions takes up to 50 conversions, and metadata up to 5 values a job’s metadata must have. Give the jobs a workflow makes the same metadata, and its trigger hears only them.
Terminal window
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"}}'

Every event’s body is the job, as GET /v1/jobs/{id} shows it: see webhooks for its shape, retries and signature. On a platform:

  • Answer at once. We wait 10 seconds for a 2xx. The platforms’ triggers answer as soon as they have the request, unless you tell them to wait for the workflow, so leave that off.
  • The same event can come twice. Its id (and the FormatJet-Event-Id header) is the same each time. Better still, act once per job: skip a job ID the workflow has already handled.
  • Check mode. Events of jobs made with a test key say "mode": "test". A workflow for real work should skip them: a test job’s own webhook is signed with the same secret as a live job’s, so the signature alone doesn’t tell them apart.
  • Check it’s ours. Where the platform can compute an HMAC, check the FormatJet-Signature header with the endpoint’s secret, as in Check the signature. That’s the only check that proves we sent the request.
  • Where it can’t, read the job again with your key, GET /v1/jobs/{id} with the event’s data.job.id, and use that answer, never the event’s. The API shows only your own organization’s jobs, so a forged request can’t make the workflow 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 trigger’s address: keep that address private, act once per job, and skip jobs whose metadata isn’t this workflow’s.

When you set a trigger up, the platform asks for a sample to map fields from. Your last finished jobs, in the same shape as an event’s data.job, make good ones (up to 10 a page with view=job):

Terminal window
curl "https://api.formatjet.com/v1/jobs?status=completed,failed&view=job&limit=3" \
-H "Authorization: Bearer $FORMATJET_API_KEY"