Piloterr

Start a run

Start a run, know what it may cost before anything is billed, and send a request again without doing it twice.

Start a run with POST /v1/projects/{id}/runs:

curl -X POST https://dataflow.piloterr.com/v1/projects/PROJECT_ID/runs \
  -H "x-api-key: YOUR_API_KEY"

The answer is 202 with the run, queued. Before queuing it, Dataflow checks that:

  • Dataflow is not switched off, for everyone or for your workspace (403 dataflow_disabled, 403 account_dataflow_disabled);
  • the project is neither archived nor disabled (409 project_archived, 409 project_disabled);
  • the project has no other run queued, started, paused, finalizing or cancelling: a project runs one at a time (409 run_in_progress, with the other run's id in error.details.run_id);
  • the endpoint can still be used (409 endpoint_not_eligible) and the uploaded input still exists (409 input_missing);
  • the run fits your workspace's limits (409 rows_limit_exceeded, 409 concurrent_runs_limit);
  • your balance covers what the run may spend (402 insufficient_credits, with required and available in error.details): every row at the endpoint's credit cost or, when the project's max_cost_per_run is lower, the cap plus one row. For an endpoint billed per result or per GB, a row's cost is only known from its answer: the check counts each row at its minimum, credit_cost, and error.details has estimated: true. Add ?force=true to start anyway: the run pauses when credits run out.

When the run cannot be queued, the answer is 503 queue_unavailable and nothing was started: try again in a moment.

A URL or search input is read again first, before the credit check. A search's calls are billed like any call: they are in the run's search_credits, count in its credits and its max_cost_per_run, and the balance checked is what is left after them. When the URL cannot be read, the search fails or finds nothing, a column the mapping uses is gone, or the key the search runs with cannot be used (the project's own key, or the managed Dataflow key when it is inactive), the answer is still 202, but with a run that is already failed, with reason source_unreachable, mapping_invalid or api_key_invalid (see Statuses). Check status in the answer. When your workspace runs out of credits during the search, the answer is 402 insufficient_credits with error.details.stage: "search", and no run is created: force does not help, top up first.

Know the cost before a run

A project shows no estimated cost: what a run spends depends on its rows, which a URL or search input only gets when the run starts. Two checks tell you before anything is billed:

  • Before you create the project, POST /v1/inputs/{id}/check counts, for a file or a list, the rows a run would skip as invalid (never called nor billed) and the valid ones. For an endpoint billed per call, a run costs at most valid × the endpoint's credit_cost (from GET /v1/endpoints); rows answered with an error other than 404 cost nothing. Billed per result or per GB, that is only its minimum: the answers set the rest, and max_cost_per_run caps it.
  • When you start it, the launch checks your balance against what the run may spend and answers 402 insufficient_credits with required and available in error.details (above), before a single call. Nothing is started.

The dashboard shows both on the last step of a new project.

Send a request again safely

A network error can leave you without the answer to a request that went through. To send it again without starting a second run or creating a second project, give it an Idempotency-Key header: any value of 1 to 255 printable ASCII characters, unique per request, such as a UUID.

curl -X POST https://dataflow.piloterr.com/v1/projects/PROJECT_ID/runs \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Idempotency-Key: 5b0f6c1e-8c1d-4a8e-9d4f-2f0a7c1e9b33"
  • It works on POST /v1/projects, POST /v1/projects/{id}/runs, POST /v1/projects/{id}/duplicate, POST /v1/templates/{id}/projects, POST /v1/inputs, POST /v1/inputs/uploads and POST /v1/runs/{id}/retry-failed. Elsewhere it is ignored.
  • A key belongs to your workspace and to the exact path it was sent on: the same key on POST /v1/projects/A/runs and on POST /v1/projects/B/runs is two requests, and another workspace's keys never meet yours.
  • The answer is kept 24 hours. The same key sent again within that time, with the same body and query string, gets the same answer, status and body, with the header Idempotent-Replayed: true, and nothing is done again.
  • The same key with another body, another query string (adding ?force=true, for example) or on another path answers 422 idempotency_key_reused: use a new key for a new request. An uploaded file counts as the same body when its name, type and bytes are the same.
  • While the first request is still being answered, the same key answers 409 idempotency_key_in_progress: wait a moment and send it again.
  • 4xx answers are kept and replayed like the others, 409 and 429 aside: a 402 insufficient_credits or a 422 comes back as it was, even once you topped up or fixed the cause. Send the corrected request with a new key.
  • 5xx, 409 and 429 answers are not kept: sending the key again tries the request anew. So does a request without the header.
  • A key that is empty, longer than 255 characters or not printable ASCII answers 422 validation_failed with details[0].path Idempotency-Key.

On this page