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_9808efd9bf000072c581da45b425d3c0

When 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

StatusMeaningWhat to do
200Success
202Accepted: the run has startedFollow it with Get a run
400The request isn't valid, such as an input that doesn't match the workflow, or a workflow to save that isn't validFix the request; the message names the problem. Don't retry as is.
401The API key is missing or invalidCheck the Authorization header and the key
402Lodol Local only: the installation needs a licenceAdd the licence in Settings
403The key lacks a scope, its creator's role doesn't allow the action, or the plan doesn't include itUse a key with the right scope, or change the creator's role
404What 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 seeCheck the ID
409A 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 readDepends on the error_code: see Error codes
422The Idempotency-Key was already used for a different request that Lodol still remembers or is still processingUse a new key for a new request
429Too many requests, or the month's runs are used upDepends on the error_code: see Error codes
500Something went wrong on Lodol's sideRetry with backoff

Error codes

These name a problem precisely, so your code can handle each its own way:

CodeStatusMeaningWhat to do
missing_api_key401No Authorization: Bearer … headerSend the key
invalid_api_key401The key is malformed, revoked or expiredCheck the key, or make a new one
missing_scope403The key was made without a scope this endpoint needsUse a key with the scope
permission_denied403The member who made the key isn't allowed to do thisChange their role, or use another member's key
api_key_owner_inactive403The member who made the key has left the workspace, or has no role in itMake a new key
item_view_only403The key's member can see this workflow but not run or change itAsk for edit access to it
workspace_ip_not_allowed403The workspace only accepts requests from certain networksSend the request from an allowed network
workspace_policy_unavailable403Lodol couldn't read the workspace's security policy to check the request against itRetry after a short wait: the request itself is fine
invalid_inputs400The run's inputs don't match what the workflow declares, or it takes noneFix the inputs; the message names the one at fault
workflow_not_runnable400The workflow is a draft, or isn't finished, or you asked to turn on or turn off one that runs only when it's startedPublish or fix it in Lodol
run_already_finished400Stop a run on a run that has already finishedNothing: the run is over. Get it to see how it ended
run_not_finished409Delete a run on a run that, or a run it started, hasn't finishedStop it, or wait for it to finish, then delete it
run_not_retryable409Retry a run on a run that can't be retried that way, such as one that didn't failThe message says why; some can still be retried from the start
invalid_workflow400A workflow to create or change isn't valid, uses something the key's member can't, or would lose all its stepsFix 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_browser400Connect an app on an app you connect by signing in, which takes a browserConnect it on the Apps page in Lodol, at the body's connect_url
credentials_rejected400Connect an app with credentials the app turned down. Nothing was savedCheck the credentials, and send them again
approval_already_answered409Answer an approval request on one someone already answeredNothing: read its decision to see the answer
approval_expired409Nobody answered the request in time: it closed, or its time limit answered itNothing: the step has moved on as it was set to
approval_withdrawn409The run was stopped, or its workflow deleted, before anyone answeredNothing: there's no run waiting for an answer
row_changed409Replace or remove a table row when the row has changed since you read itGet the value again and send the row as it is now
request_in_progress409A request with this Idempotency-Key is still being worked onRetry after the Retry-After header's seconds
idempotency_key_reused422This Idempotency-Key was already used for a different request that Lodol still remembers or is still processingUse a new key for a new request
rate_limited429Too many requests in the last minuteRetry after the Retry-After header's seconds
monthly_run_limit429The month's runs are used upRuns 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: true header.
  • Requests in flight return 409. If the first request with a key is still being processed, a second one gets 409 Conflict with Retry-After: 5.
  • A key belongs to one request. Reusing a key for a different request, such as the same workflow with different inputs, returns 422 while 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.

On this page