Errors and retries
The error codes the API returns and what to do about each, the request ID to quote to support, which requests are safe to retry, and how idempotency keys stop a retry from doing the work twice.
The API uses standard HTTP status codes. Every error has a JSON body with a message saying what went wrong, and a code naming the problem:
{
"error": "Run not found",
"error_code": "not_found"
}Decide what to do from error_code. It names the problem and never changes, while the wording of error is for people and may be improved. The error codes below list every one.
Request IDs
Every response, error or not, carries an X-Request-Id header naming the request:
X-Request-Id: req_9808efd9bf000072c581da45b425d3c0When something goes wrong and you contact Lodol's support, quote it: it finds the request in Lodol's records. Log it with any error you keep.
Status codes
| Status | Meaning | What to do |
|---|---|---|
200 | Success | |
202 | Accepted: the run has started | Follow it with Get a run |
400 | The request isn't valid, such as an input that doesn't match the workflow, or a workflow to save that isn't valid | Fix the request; the message names the problem. Don't retry as is. |
401 | The API key is missing or invalid | Check the Authorization header and the key |
402 | Lodol Local only: the installation needs a licence | Add the licence in Settings |
403 | The key lacks a scope, its creator's role doesn't allow the action, or the plan doesn't include it | Use a key with the right scope, or change the creator's role |
404 | What the request names, such as a workflow, run, connection or value, doesn't exist, was deleted, or isn't one the key's member can see | Check the ID |
409 | A request with the same Idempotency-Key is still being processed, a run to delete hasn't finished, a run can't be retried, an approval request has already been settled, or a table row changed since it was read | Depends on the error_code: see Error codes |
422 | The Idempotency-Key was already used for a different request that Lodol still remembers or is still processing | Use a new key for a new request |
429 | Too many requests, or the month's runs are used up | Depends on the error_code: see Error codes |
500 | Something went wrong on Lodol's side | Retry with backoff |
Error codes
These name a problem precisely, so your code can handle each its own way:
| Code | Status | Meaning | What to do |
|---|---|---|---|
missing_api_key | 401 | No Authorization: Bearer … header | Send the key |
invalid_api_key | 401 | The key is malformed, revoked or expired | Check the key, or make a new one |
missing_scope | 403 | The key was made without a scope this endpoint needs | Use a key with the scope |
permission_denied | 403 | The member who made the key isn't allowed to do this | Change their role, or use another member's key |
api_key_owner_inactive | 403 | The member who made the key has left the workspace, or has no role in it | Make a new key |
item_view_only | 403 | The key's member can see this workflow but not run or change it | Ask for edit access to it |
workspace_ip_not_allowed | 403 | The workspace only accepts requests from certain networks | Send the request from an allowed network |
workspace_policy_unavailable | 403 | Lodol couldn't read the workspace's security policy to check the request against it | Retry after a short wait: the request itself is fine |
invalid_inputs | 400 | The run's inputs don't match what the workflow declares, or it takes none | Fix the inputs; the message names the one at fault |
workflow_not_runnable | 400 | The workflow is a draft, or isn't finished, or you asked to turn on or turn off one that runs only when it's started | Publish or fix it in Lodol |
run_already_finished | 400 | Stop a run on a run that has already finished | Nothing: the run is over. Get it to see how it ended |
run_not_finished | 409 | Delete a run on a run that, or a run it started, hasn't finished | Stop it, or wait for it to finish, then delete it |
run_not_retryable | 409 | Retry a run on a run that can't be retried that way, such as one that didn't fail | The message says why; some can still be retried from the start |
invalid_workflow | 400 | A workflow to create or change isn't valid, uses something the key's member can't, or would lose all its steps | Fix it; the message says what. Validate a workflow checks without saving. A malformed request, such as an unknown field or a patch operation that can't be applied, gets invalid_request instead |
connect_in_browser | 400 | Connect an app on an app you connect by signing in, which takes a browser | Connect it on the Apps page in Lodol, at the body's connect_url |
credentials_rejected | 400 | Connect an app with credentials the app turned down. Nothing was saved | Check the credentials, and send them again |
approval_already_answered | 409 | Answer an approval request on one someone already answered | Nothing: read its decision to see the answer |
approval_expired | 409 | Nobody answered the request in time: it closed, or its time limit answered it | Nothing: the step has moved on as it was set to |
approval_withdrawn | 409 | The run was stopped, or its workflow deleted, before anyone answered | Nothing: there's no run waiting for an answer |
row_changed | 409 | Replace or remove a table row when the row has changed since you read it | Get the value again and send the row as it is now |
request_in_progress | 409 | A request with this Idempotency-Key is still being worked on | Retry after the Retry-After header's seconds |
idempotency_key_reused | 422 | This Idempotency-Key was already used for a different request that Lodol still remembers or is still processing | Use a new key for a new request |
rate_limited | 429 | Too many requests in the last minute | Retry after the Retry-After header's seconds |
monthly_run_limit | 429 | The month's runs are used up | Runs come back at resets_at; add runs or turn on extra runs in Billing to go on now |
The endpoints for connections, values, folders, the catalog, the Trash, and restoring, duplicating or turning on a workflow, its versions, next runs and settings, refuse anything else with 400 and the code invalid_request, saying why in error. That includes a field or query parameter they don't take.
Any other error has the code for its kind of problem: invalid_request (400), unauthorized (401), licence_required (402), forbidden (403), not_found (404), method_not_allowed (405), conflict (409), request_too_large (413), unprocessable_request (422), internal_error (500) or service_unavailable (503).
Common errors
Retry safely
Retry 5xx, 403 with the code workspace_policy_unavailable, 409 with the code request_in_progress, and 429 with the code rate_limited, waiting longer each time. When the response has a Retry-After header, wait that many seconds; otherwise back off exponentially. Don't retry other 4xx responses: the request itself needs fixing, or, like an approval request that's already been answered, there's nothing left to do. Nor 429 with monthly_run_limit, which clears only when the month's runs come back.
async function lodolRequest(url, options = {}, maxRetries = 3) {
for (let attempt = 0; ; attempt++) {
const response = await fetch(url, options);
const code = [403, 409, 429].includes(response.status)
? (await response.clone().json()).error_code
: null;
const retryable =
response.status >= 500 ||
['workspace_policy_unavailable', 'request_in_progress', 'rate_limited'].includes(code);
if (!retryable || attempt === maxRetries) return response;
const retryAfter = Number(response.headers.get('Retry-After'));
const seconds = retryAfter > 0 ? retryAfter : 2 ** attempt;
await new Promise((resolve) => setTimeout(resolve, seconds * 1000));
}
}Retry a request that starts a run or saves a workflow only with an idempotency key, or a timeout could do it twice.
Idempotency
Requests that do something accept an Idempotency-Key header: every POST, PUT, PATCH and DELETE except POST /workflows/validate and POST /connections/:id/test, which change nothing. Lodol remembers the response to the first request with each key that succeeds, and returns that same response to any later request with the same key, instead of doing the work again. A request that fails isn't remembered, so retrying it with the same key does the work.
curl -X POST https://api-prod.lodol.com/api/v1/workflows/665f1a2b3c4d5e6f7a8b9c0d/run \
-H "Authorization: Bearer $LODOL_API_KEY" \
-H "Idempotency-Key: order-1042-confirmation"- Make the key from what the run is for, such as your own order or event ID, so a retry of the same work always sends the same key. Keys can be up to 256 characters.
- Successful responses are kept for 24 hours. A repeated request in that time gets the first response back, with an
X-Idempotent-Replayed: trueheader. - Requests in flight return
409. If the first request with a key is still being processed, a second one gets409 ConflictwithRetry-After: 5. - A key belongs to one request. Reusing a key for a different request, such as the same workflow with different inputs, returns
422while Lodol remembers the key or the first request with it is still in flight.
Send a key with deletes too: deleting something that's already gone returns 404, but a repeat of a delete with the same key answers as the first did.
Authentication
Every request carries an API key. A key belongs to one workspace, its scopes say what it may do, and it can never do more than the member who created it.
Limits
How many requests a workspace can make each minute, the other limits your plan sets, and how to tell when you're close to them.