Your first API run
Run a Template on a file from a script and download the result.
What you need
- A saved Template, from Fix your first file.
- curl, or any HTTP client.
Steps
Create a key
From your Account page, press Create a key. Copy it now: it is shown only once.
Save it as an environment variable
Every sample on these pages reads the key from
DOCTRANSFORM_API_KEY, never from a literal in the command:export DOCTRANSFORM_API_KEY=dt_live_...List your Templates
Find the id of the Template you want to run.
curl "https://doctransform.xyz/api/v1/templates" \ -H "Authorization: Bearer $DOCTRANSFORM_API_KEY"Create a Run
Upload a file to run that Template on it.
curl -X POST "https://doctransform.xyz/api/v1/templates/tmpl_123/runs" \ -H "Authorization: Bearer $DOCTRANSFORM_API_KEY" \ -F "file=@/path/to/your/file.csv"Only a Run that returns a file uses one of your monthly exports.
Check its status
A quick Run answers
201with the result attached. A longer one answers202: pollGET /runs/{id}until its status is no longerrunning.curl "https://doctransform.xyz/api/v1/runs/run_abc" \ -H "Authorization: Bearer $DOCTRANSFORM_API_KEY"Download the result
Once the Run has succeeded, download its output:
curl "https://doctransform.xyz/api/v1/runs/run_abc/output" \ -H "Authorization: Bearer $DOCTRANSFORM_API_KEY" \ -o result.csv