1.  [Documentation](/en/docs)
2.  [API](/en/docs/api/quickstart)
3.  Your first API run

# 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](/en/docs/getting-started/quickstart).
*   curl, or any HTTP client.

## Steps

1.  ### Create a key
    
    From your [Account page](/account#api-keys), press **Create a key**. Copy it now: it is shown only once.
    
2.  ### 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_...
    
    Copy
    
3.  ### 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"
    
    Copy
    
4.  ### 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"
    
    Copy
    
    Only a Run that returns a file uses one of your monthly exports.
    
5.  ### Check its status
    
    A quick Run answers `201` with the result attached. A longer one answers `202`: poll `GET /runs/{id}` until its status is no longer `running`.
    
        curl "https://doctransform.xyz/api/v1/runs/run_abc" \
          -H "Authorization: Bearer $DOCTRANSFORM_API_KEY"
    
    Copy
    
6.  ### 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
    
    Copy
    

## Next steps

[RunsImmediate answers, polling and safe retries.](/en/docs/api/runs)[WebhooksGet told when a Run finishes, instead of asking.](/en/docs/api/webhooks)[API referenceEvery endpoint with its request and response.](/en/docs/api/reference)
