Skip to content
Convertly

Convert files with the API

Start a conversion with curl, wait for it to finish and download the result. Real endpoints, field names and limits, with an optional API key.

Everything the website does goes through a small REST API, and you can use it from scripts. A conversion takes three calls: start it, wait until it is done, download the result. The full list of endpoints is on the API reference page.

The examples use curl. Set the base URL once. The right value is shown at the top of the API reference page; the one below is the address of a server running on your own computer.

API=http://localhost:5481/api/v1

The top of the API reference page, with the base URL and the three calls

1. See what a format can become

Ask which formats a spreadsheet can be turned into, and which settings each conversion accepts:

curl $API/formats/xlsx/targets

The answer lists every target with its status (ready means it works now) and an options object with the settings and their allowed values. For CSV these are sheet and delimiter (comma, semicolon or tab).

2. Start the conversion

Send the file as a multipart form with the fields file and to. The settings go in options, as a JSON string:

ID=$(curl -s -F "file=@report.xlsx" -F "to=csv" -F 'options={"delimiter":"semicolon"}' $API/jobs | jq -r .id)
echo $ID

The server answers 201 with the job as JSON; the line above keeps its id in ID (it uses jq; without it, read the id from the answer yourself). The fields to know are id, status (starts as queued), progress (0 to 100), from, to, originalName, outputName, error and expiresAt.

3. Wait until it is done

Ask for the job until status is done. It can also end as failed, with the reason in error, or cancelled. A failed conversion is not an HTTP error. This loop (it needs jq) waits for you:

while true; do
  STATUS=$(curl -s $API/jobs/$ID | jq -r .status)
  case $STATUS in queued|processing) sleep 1 ;; *) break ;; esac
done
curl -s $API/jobs/$ID | jq '{status, error, outputName}'

If you prefer not to poll, GET /jobs/$ID/events streams the same job object each time it changes and closes when the job ends.

4. Download the result

curl -OJ $API/jobs/$ID/download

The download answers 409 with the code JOB_NOT_READY until the job is done. To save under another name, add ?name=report-semicolon.csv. To cancel a job and delete its files now, use curl -X DELETE $API/jobs/$ID.

Optional: use an API key

Without a key, your requests count as a guest, by IP address. With a key they count against your account's plan.

Log in, open the dashboard, find "API keys", type a name for the key and press "Create key". Copy the key at once: it is shown only one time. Then send it with every request:

curl -H "Authorization: Bearer cvk_your_key" -F "file=@report.xlsx" -F "to=csv" $API/jobs

The API keys box on the dashboard, with a new key shown once

Good to know

  • Every error answers with the same shape: { "error": { "code": "...", "message": "..." } }. Check the code; the API reference lists them all.
  • You can start 60 new conversions per 10 minutes from one address. After that you get RATE_LIMITED.
  • A file can be up to 500 MB on the server, and your plan's own limit can be lower. When the daily number of conversions for your plan is used up you get QUOTA_EXCEEDED.
  • Results are deleted one hour after they are ready.
  • Changing your password removes your API keys, so create new ones afterwards.

Try it now