FlitDocs

Errors

When a request fails, data is null and errors says why. Branch on the HTTP status and the code. The text is for a person and may be reworded.

What an error looks like

This login has an action Flit does not know:

POST /api/v1/applications/$APP/audit-authentication
curl -s -X POST "$FLIT/api/v1/applications/$APP/audit-authentication" \
  -H "Authorization: Bearer $KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "id": "login_9001",
    "client_id": "user_42",
    "action": "signin"
  }'
400 Answer
{
  "data": null,
  "errors": [
    {
      "code": "in_choices",
      "path": "action",
      "context": {
        "choices": [
          "login",
          "login_failed",
          "password_reset_requested",
          "password_reset_completed",
          "password_change",
          "email_change",
          "phone_change",
          "two_factor_enabled",
          "two_factor_disabled",
          "new_device_login"
        ]
      },
      "text": "Must be one of the available choices"
    }
  ]
}
FieldWhat it tells you
codeWhat went wrong, as a stable word.
pathThe field of your request it is about, or null when it is about the request as a whole.
contextThe detail: the allowed values, the longest length, the limit you hit.
textA sentence for a log.

A request with several things wrong gets several errors at once, one for each field.

By status

StatusCodeWhat happened
400a validation code, with a pathA field is missing, the wrong kind, too long, or not one of the allowed values.
400parse_errorThe body is not a JSON object.
400app_ref_existThere is no application with the id in the URL. Unknown ids are a 400 here, not a 404.
401unauthenticatedNo Authorization header.
401invalid_credentialsThe key is unknown, mistyped or revoked, or a sign-in token has expired.
403forbiddenThe key is real, but not for this application: most often a test key sent to the live id. Also an API key used where only a signed-in person may act, such as creating keys.
403policy_loosening_forbiddenA key tried to relax a policy. A person has to.
404not_foundNo such endpoint.
409variousThe thing is not in a state for that: a trip already released, the limit of test applications reached.
413body_too_largeThe request is over 1 MB.
429rate_limit_exceededToo many requests. See below.
429sandbox_quota_exceededTest mode's daily limit is used up.
500server_errorFlit failed. Treat it as no decision.
503service_unavailableFlit cannot reach something it needs. Treat it as no decision.

Validation codes you will meet

CodeMeaning
in_choicesNot one of the allowed values, which are listed in context.choices.
dense_stringMust be text with something in it. The event's id and client_id.
too_longLonger than context.max_length.
void_or_decimalMust be a number, or left out.
void_or_ip_addressNot an IP address.
currency_codeNot a three-letter currency code.
uuidAn id in the URL is not a UUID.

A validation error means no decision was made and nothing was recorded. Fix the request; sending it again unchanged gets the same answer.

Rate limits

Limits are counted per calling address, which for decisions is your server's, over a sliding minute.

RequestsLimit
Decisions (audit-…)1,000 a minute. Raised on request for live applications.
Everything else under an application or organization100 a minute.
Signing in and tokens (/auth/…)5 a minute, then refused for five minutes.
Signing up5 an hour.

Every answer carries X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset, so you can slow down before you are told to. A 429 carries Retry-After, in seconds.

A rate-limit answer has a different body. It is {"ok": false, "errors": [{"code", "message", "context"}]}, with no data and message in place of text. Read the status and Retry-After, and do not rely on the body.

Request ids

Every answer has an X-Request-Id header. Log it. If you send your own X-Request-Id, of up to 64 letters, digits and . _ : -, Flit uses yours, so one id follows the request through both systems. Quote it, or a decision's audit_id, when you write to support.