Skip to content

Error handling

When a Flint request fails, your code has one decision to make: send the same request again, rebuild it from current state, or stop and change something first. Every error response answers that in remediation.retry, so one handler can cover every endpoint:

  • same_request: a throttle, an in-progress conflict, or most 5xx errors. Wait, then send the identical request with the same Idempotency-Key.
  • after_refresh: the resource changed under you. Read it and rebuild the request from what you read. next_steps says whether the request's key is free to reuse.
  • none: resending can't succeed. Fix the input, or do what next_steps says, such as finishing merchant setup or resolving a blocking resource.

Declined cards, failed refunds, and failed payouts aren't errors. They return 2xx and arrive as resource state and webhook events; see A declined card is not an error.

The error envelope#

Every failed request returns the same JSON shape under error. This request leaves out the custom line item's required name:

cURL
curl -X POST https://api.withflintpay.com/v1/orders \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "line_items": [
      {
        "type": "custom",
        "quantity": 1,
        "unit_price_money": { "amount": 400, "currency": "USD" },
        "fulfillment": { "requirement": "none" }
      }
    ]
  }'
Response
{
  "error": {
    "type": "validation_error",
    "code": "INVALID_REQUEST",
    "message": "line_items[0].name is required.",
    "param": "line_items[0].name",
    "error_source": "caller",
    "request_id": "req_01KWM63CW5B1NVAAJ4896D22Y3",
    "request_log_url": "/v1/api-request-logs/rlog_01KWM6NVEKA7XDC8QWD404FX06",
    "doc_url": "https://developers.withflintpay.com/docs/errors#invalid_request",
    "remediation": {
      "retry": "none",
      "next_steps": "Correct each input named by details[].param as its message says, then send the request again."
    },
    "details": [
      {
        "code": "REQUIRED",
        "param": "line_items[0].name",
        "message": "line_items[0].name is required."
      }
    ]
  }
}

The object has these ten properties and no others. Everything else Flint knows about the failure is in details.

FieldWhat it holds
typeCoarse category, set by the HTTP status. Always present. See Error types.
codeStable identifier for the failure, such as INVALID_REQUEST. Always present. Branch on this.
messageExplanation for your logs. Always present. Wording can change, so don't parse it or show it to buyers.
paramPath of the one input to change: a body path such as line_items[0].name or metadata.order_ref, a path or query parameter name, a header name such as Idempotency-Key, or body for the whole body. Present on every validation error, and on other errors whenever one input is responsible. See Validation errors.
detailsTyped facts about the failure. See Facts in details.
request_idFlint's ID for the request: req_ and 26 characters. The X-Request-Id response header carries the same value. Log it, and quote it to support.
request_log_urlPath of the request's log in the request logs API. Present when you call with an API key or OAuth access token that holds developer.request_logs.read or developer.request_logs.self.read. The detail endpoint waits up to three seconds for a recent request log to become available. Omitted when Flint's database was unavailable during the request, because the log can't be stored.
doc_urlThis code's entry in the error catalog: https://developers.withflintpay.com/docs/errors# and the lowercase code. Always present.
error_sourceWho has to act. Always present. See below.
remediationWhat to do next. Always present. See Remediation hints.

If you send your own X-Request-Id, Flint stores it on the request log as client_request_id. request_id and the response header are always Flint's ID. See Debugging.

error_source says who must act before the request can succeed. It depends only on code and details[0].reason, and the error catalog lists the value for each. Use it to route the failure, and code and details[0].reason to decide the fix:

error_source on error object
  • caller
    The request must change: its inputs, its credential, or how often you send it. This includes mistakes in your integration's requests and invalid input a buyer gave through your app.
  • merchant
    The merchant's account or stored configuration must change first, such as finishing onboarding or verification, changing a setting, or approving a review. Anyone with access to the account can make the change. Then send a new request.
  • merchant_endpoint
    An endpoint the merchant configured for Flint to call failed, timed out, or answered with an invalid response, such as a delivery rate callback or a workload identity issuer. Restore that endpoint, then send the request again.
  • flint
    Flint must act or is finishing work: a server failure, an outage of a service Flint relies on, or a condition Flint controls, such as an account review or a payment that needs reconciliation. Follow next_steps, and contact support with the request_id if it doesn't clear.

Warning: Branch on code, then reason

Codes and reasons are part of the contract; messages are not. For a code with reasons, such as ACTION_NOT_ALLOWED, FORBIDDEN, or MERCHANT_NOT_READY, branch on code and then on details[0].reason.

Facts in details#

Read facts from the details item they belong to, never from message.

  • On INVALID_REQUEST, each item is one failed input, with its own code, param, and message. See Validation errors.
  • On every other code, details[0] is the primary failure. It repeats the top-level code and param and carries the facts. Later items are more instances of the same condition, such as several out-of-stock lines.
  • details is present on every validation error and every error that carries a fact. It is absent when code, message, and param say everything, as on RATE_LIMIT_EXCEEDED.

A code carries only the facts its catalog entry lists. These are the ones most integrations read:

FactSent withUse it to
reasonCodes that have reasons, such as ACTION_NOT_ALLOWED, FORBIDDEN, INVALID_CREDENTIAL, LIMIT_REACHED, and MERCHANT_NOT_READYPick the specific fix. ACTION_NOT_ALLOWED always has one.
resource_type, resource_idRESOURCE_NOT_FOUND, state refusals, and conflictsFind the resource the error is about. It can differ from the one in the path, such as the order that owns a payment intent.
current_status, supported_actionsACTION_NOT_ALLOWED and other state conflictsSee the resource's state as a GET returns it, and the actions it accepts now. An empty supported_actions means none.
current_versionVERSION_CONFLICT for a stale expected_versionRead the resource, rebuild the change, and send this value as expected_version.
current_api_versionVERSION_CONFLICT for a stale expected_api_version on a webhook endpoint or partner appConfirm the current pin, then send this value as expected_api_version.
blocking_resources, blocking_resource_countRESOURCE_IN_USE, OPERATION_IN_PROGRESS, PAYMENT_ATTEMPT_ACTIVE, PAYMENT_REVIEW_OPENResolve the listed resources, each a resource_type, resource_id, and optional status. A dependency refusal lists up to 25, and the count is the total. Only resource types your credential can read are listed and counted.
current_resourceALREADY_EXISTS, and some checkout conflictsUse the record that already holds the value or slot, such as the open checkout session on an order. Present only when your credential can read it.
maximum_money, minimum_money, available_quantity, minimum_quantityLIMIT_EXCEEDED, and PAYMENT_OPTION_UNAVAILABLE with reason amount_out_of_rangeKeep the value inside the bound.
conflicting_fieldsINVALID_REQUEST with detail code NOT_ALLOWEDThe other inputs param conflicts with. Remove param, or remove these.
selectable_resourcesINVALID_REQUEST on a field with a set of valid IDs, such as merchant_id for a developer credentialSubmit one of the returned resource_id values.
supported_api_versionsINVALID_REQUEST on Flint-Version, and API_VERSION_RETIREDSend one of these versions.
missing_scopes, scope_requirementINSUFFICIENT_SCOPESee which scopes the credential lacks. scope_requirement matches the operation's x-flint-required-scopes; missing_scopes leaves out a read scope when its write is also listed.
verified_at, verification_max_age_secondsIDENTITY_VERIFICATION_REQUIREDSee when the session last verified its identity and how long a verification lasts.

Buyer credentials don't receive merchant-only resources in blocking_resources or another customer's record in current_resource.

Remediation hints#

remediation tells you how to recover. retry comes from the same catalog as the error reference, and next_steps gives the instruction for this failure:

JSON
{
  "error": {
    "type": "authentication_error",
    "code": "INVALID_CREDENTIAL",
    "message": "Test mode API keys must be sandbox-bound before they can authenticate public API requests.",
    "error_source": "caller",
    "request_id": "req_01KWM6C5FWM375TEEYGRKAK7AN",
    "doc_url": "https://developers.withflintpay.com/docs/errors#invalid_credential",
    "remediation": {
      "retry": "none",
      "next_steps": "Create a key in the right mode. A test key is bound to one active sandbox, a live key is never bound to a sandbox, and a key holds only scopes its mode allows.",
      "next_actions": [
        {
          "action_type": "issue_developer_sandbox_test_key",
          "reason_code": "SANDBOX_BOUND_TEST_KEY_REQUIRED",
          "reason_message": "Create or use a sandbox-bound test key for the sandbox this request should target.",
          "required_fields": ["sandbox_id"]
        }
      ]
    },
    "details": [
      {
        "code": "INVALID_CREDENTIAL",
        "message": "Test mode API keys must be sandbox-bound before they can authenticate public API requests.",
        "reason": "mode_mismatch"
      }
    ]
  }
}

retry is always present and takes one of three values:

retry on error remediation
  • same_request
    Nobody has to act: time passing, or Flint finishing work already under way, clears the condition, and the expected wait is at most one hour. Send the identical request again after Retry-After when the response has it, otherwise with exponential backoff and jitter. If the request carried an Idempotency-Key, keep the same key. The retry can resume or replay the original request instead of running it again; see Idempotency.
  • after_refresh
    Your basis is stale. Read the resource the error names and rebuild the request from its current state. next_steps says whether the request's key is free to reuse.
  • none
    Someone has to act first, or you have to observe an outcome, or the wait is longer than an hour or has no known end. Don't retry automatically. Correct the request, or act on next_steps or next_actions, then send a new request. Read the outcome after a 5xx before sending anything new.

Trust retry over a guess from the status code. retry depends only on code and details[0].reason, never on the route or the request. A reason can only lower a code's same_request to none, and never raises none. For example, EXTERNAL_SERVICE_ERROR with reason outcome_unknown is none because you must read the resource to learn whether the operation took effect, and SERVICE_UNAVAILABLE with reason repair_required is none because Flint has to repair something first. The error catalog shows the value for each code and each reason that differs.

The other two fields:

  • next_steps: what to change or check before trying again. Flint uses the first of these that exists: an instruction written for the specific failure, the instruction for the details[0].reason, then the instruction for the code. On a validation error, the inputs to fix are the details[].param values.
  • next_actions: concrete steps, when Flint can name them. Each has an action_type, and can have a reason_code and reason_message, the url of the endpoint or page to use, its required_fields and required_scope, an expires_at, requires_human_confirmation, and a suggested_delay_milliseconds before acting.

next_steps also says what happened to the request's Idempotency-Key. A 4xx changed nothing, so a corrected request can reuse its key; see Retry after an error.

Follow-up actions#

An action can include target_resource: {resource_type, resource_id} when its url can't carry the target, such as a create endpoint. When present, send target_resource.resource_id in the request field named {resource_type}_id.

For example, trying to accept an inquiry returns a create_refund action with url: "/v1/refunds", required_fields: ["payment_intent_id"], required_scope: "commerce.refunds.write", and target_resource: {"resource_type": "payment_intent", "resource_id": "pi_1kmn0aExample"}. To concede the inquiry, send that Flint ID as payment_intent_id when creating the refund.

Because next_actions is structured, an agent can recover without a person reading the logs. See AI agents.

Error types#

The HTTP status sets type, so every error with the same status has the same type.

StatustypeWhat happenedUsual retry
400validation_errorThe request failed validation, or a processor refused itnone
401authentication_errorNo credential, or one Flint can't use: malformed, unknown, revoked, expired, or in the wrong modenone
403authorization_errorThe credential is valid but lacks a scope (INSUFFICIENT_SCOPE) or can't make this request (FORBIDDEN)none
404not_found_errorNo such resource for this merchant and mode (RESOURCE_NOT_FOUND), or no such route (ROUTE_NOT_FOUND)none
405, 410, 413, 415, 499protocol_errorWrong method (METHOD_NOT_ALLOWED), a retired API version, a body over the limit, a body that isn't JSON, or a request your client closed before Flint responded (REQUEST_CANCELED, seen only in request logs)none
409conflict_errorThe request conflicts with current state: a stale version, a taken value, a lifecycle rule, a bound, or an idempotency keyDepends on the code
429rate_limit_errorYou sent requests too fast. Always RATE_LIMIT_EXCEEDED, always with Retry-Aftersame_request
500internal_errorFlint failed while handling the requestsame_request
502external_service_errorA service Flint depends on failedsame_request
503unavailable_errorA service Flint needs, such as its database, is temporarily unavailablesame_request
504timeout_errorThe request ran out of time. The operation may still have completedsame_request
Any other error statusinternal_errorTreat as a Flint failuresame_request

type is a closed set. A value outside this table is rare, because a new one arrives only as a breaking change, but handle it: log the request_id, fall back to the status class, and contact support. Flint never returns 402 or 422.

Codes and reasons#

The closed code set#

Flint publishes 39 top-level codes, plus four detail codes that appear only inside INVALID_REQUEST details: REQUIRED, INVALID_VALUE, UNKNOWN_FIELD, and NOT_ALLOWED. Each operation in the API reference lists the codes it can return, and the error catalog lists them all. Route-specific conditions don't get their own codes. A condition that needs a different response is a details[0].reason on one of these codes, so the changelog is where to look when a reason or code changes.

Reasons belong to their code, and each code's list grows over time. A reason you don't recognize isn't an error: give it the code's default handling. For ACTION_NOT_ALLOWED, that means reading current_status and supported_actions, as for unsupported_state.

Still keep a default branch keyed on HTTP status class and remediation.retry for any code your handler doesn't name.

Look up codes, facts, and reasons#

Three places describe what an error can contain, and all three come from the same catalog:

  • For an endpoint. Each endpoint in the API reference lists its codes under Errors, grouped by status. In the OpenAPI document, x-flint-error-codes on an operation lists its top-level codes, and the same extension on each error response lists the top-level codes that status can carry. ErrorDetailCode includes the four validation detail codes and the top-level codes that other details repeat. Each top-level code has one HTTP status. API_VERSION_RETIRED appears on operations only while a published API version is retired.
  • For a code. The error catalog entry shows the statuses the code can carry, its retry value and fix, and its facts, the extra properties its details items can have. A code marked "Appears only in details[]" is never the top-level code.
  • For a reason. A code's catalog entry lists each reason with its meaning, and shows a retry value or fix only where it differs from the code's. In the OpenAPI document, ErrorDetail.reason lists the same values as "When code is X, one of: ...".

Flint checks its responses against these lists. A fact or reason that a code's entry doesn't list is a Flint defect, so report it with the request_id. The reverse is normal: an entry can list a fact or reason that a given endpoint never returns.

Validation errors#

Every endpoint reports invalid input the same way: 400 INVALID_REQUEST. details has one item for each input at fault, each with a code, a param, and a message that says what to send. Handle this once for every endpoint by showing each message at its param.

Flint checks a request in two passes. First it checks the path, query parameters, and body against the endpoint's published request schema: one 400 INVALID_REQUEST lists every input that breaks the schema, up to 50, so you can fix them all at once. Rules that compare inputs with each other or with data Flint stores run only after the request passes the schema, and report the first rule that fails. Details are sorted by where the input is (path, then query, then body) and then by param, so the order doesn't depend on how your JSON library ordered the keys.

The top-level param is details[0].param. The top-level message is details[0].message, followed by a count when more inputs failed, such as "2 more inputs are invalid; see details." When the message already names several inputs, the count covers only the ones it doesn't name. Details don't carry remediation; the error's own remediation covers every input.

The detail code is one of four values:

Detail codeMeaning
REQUIREDAn input is missing or empty. This includes an input required only because of another, such as payment_return_url when payment_options includes affirm; an update that would leave the resource without a field it needs; and a PATCH that sends none of its fields. When at least one of several fields is required, param names the object that holds them, or body at the root, and message lists them all.
INVALID_VALUEFlint rejects the value: malformed, the wrong JSON type, null where the field can't be cleared, too long, out of range, duplicated, not an accepted value, or outside a set the resource publishes, such as a plan's billing intervals. It also covers a malformed page token, an unknown or over-limit expand path, and a field that should hold a Flint ID of one type but doesn't.
UNKNOWN_FIELDThe endpoint doesn't accept this body field or query parameter. Field names are case-sensitive. A wrong-case field usually gets the correct spelling in suggestions and the message; inside a line item's or charge's tax object it doesn't. Map keys, such as metadata keys, are free-form.
NOT_ALLOWEDThe value is well formed, but this request can't use it: inputs that can't be sent together (named in conflicting_fields), a field that doesn't apply to the chosen mode, a value the referenced resource doesn't support, such as a currency mismatch, or a field your credential may not send.

For example, if an order has no receipt email on file and you omit email when sending its receipt, a credential that may send email receives 400 INVALID_REQUEST with a REQUIRED detail at email: "email is required because this order has no receipt email on file." Send email in the corrected request. POST /v1/payment-intents/{payment_intent_id}/send-receipt returns the same response, with its own message when the payment intent has no order. A credential that cannot send email, such as a buyer session, gets 409 ACTION_NOT_ALLOWED with reason configuration_required instead, because it can't carry the missing address.

An unsupported limit query parameter returns UNKNOWN_FIELD at limit with suggestions: ["page_size"], so use page_size to set the page size. per_page also suggests page_size, and starting_after and cursor suggest page_token. A suggestion appears only when the route accepts that parameter.

param is always set on a detail. It names the one input to change, and the same form works in every endpoint:

  • A body field uses its path from the body root, such as customer.email. An array item adds its index, such as line_items[0].name, and a map value adds its key, such as metadata.order_ref. A map key that has characters other than letters, digits, _, and - is quoted in brackets, such as metadata["a.b"]. A map key that is itself invalid, for example too long, names its entry.
  • A missing field uses the path where it belongs, such as billing_start.starts_at. An unknown field uses the path as you sent it, including its case. A discriminator that is missing or unknown, such as billing_start.type, names the discriminator. A field that belongs to another branch of a union is UNKNOWN_FIELD at that field.
  • Too many or too few items, entries, or properties names the collection, such as line_items or metadata. A repeated array entry names the later one, such as allowed_resolution_types[1].
  • Inputs that can't be sent together are NOT_ALLOWED at the one to remove, with the others in conflicting_fields, which never repeats param. When one of them selects a mode, such as a type, the detail names the other input and conflicting_fields names the selector: {"param": "shipment", "conflicting_fields": ["type"]} with the message "shipment can't be sent when type is digital." Otherwise the detail names the input that sorts last, in the same order as details: {"param": "scheduled_issue_at", "conflicting_fields": ["issue"]}. Each conflict is a separate detail, reported with the request's other shape failures. A field that is required only because of another, such as payment_return_url, is REQUIRED at the field you need to send.
  • A path parameter uses its route name, such as customer_id. A query parameter uses its name with no index, such as status, including when one value of a multi-value filter is wrong. A parameter that takes one value and is sent twice is INVALID_VALUE at its name. An unknown query parameter whose name has other characters, such as status[], is quoted: ["status[]"].
  • A failure of the whole body uses body: malformed JSON, a body that isn't an object, or a PATCH with no fields. A failure of one field never uses body.
  • If an operation publishes no request body, send no body or {}. Any JSON member is UNKNOWN_FIELD at that member, including a quoted first key such as ["é"]. OAuth protocol routes and declared non-JSON bodies keep their protocol behavior.
  • A header uses the header name with no prefix, such as Idempotency-Key, Flint-Version, or X-Request-Id.
  • A range that ends before it starts, such as created_before earlier than created_after, names the later bound.

The same form applies to other errors that set param. RESOURCE_NOT_FOUND names where the ID came from, such as order_id or line_items[0].variant_id. INSUFFICIENT_SCOPE and FORBIDDEN set param only when a request input names the refused thing, such as scopes[2] for a step-up scope a key creation tried to grant, or expand for an expansion your key can't read. Flint never uses [] placeholders, internal field names, or a location prefix such as header. in param.

Rules that catch integrations most often:

  • Exact values. Enum values must match exactly, with no case folding or trimming, so ACTIVE and " active" are rejected. A list filter that takes comma-separated values trims spaces around each value, so status=active, paused matches both.
  • Empty strings. "" is never a value or a clear. Leave a field out to keep it, send null to clear a field that can be cleared, or set a metadata key to null to delete it. The message says whether null clears the field. For an address in a country with no state or postal code, send null or leave those fields out.
  • Reserved metadata keys. Top-level metadata keys that start with flint_ are reserved and rejected. Flint never returns them, so metadata you read can be sent back unchanged.
  • Timestamps must be RFC 3339 date-times, such as 2026-01-31T15:04:05Z, and boolean query parameters must be true or false.
  • Credential-restricted fields. A field your credential may not send, such as a merchant-only field on a checkout or customer credential, or customer_id under /v1/me, is NOT_ALLOWED at that field. Sending checkout session headers together with an Authorization credential is also 400 NOT_ALLOWED, with both headers in conflicting_fields. 403 is only for a credential that can't call the endpoint at all.
  • expected_version. Missing where a write requires it is REQUIRED, and not a positive integer is INVALID_VALUE. A stale one is 409 VERSION_CONFLICT, not a validation error.
  • Idempotency-Key. Missing on a route that requires one is REQUIRED, and a key Flint rejects is INVALID_VALUE. See Which routes take a key.
  • X-Request-Id. A repeated header, or a value that isn't 1 to 128 visible ASCII characters, is INVALID_VALUE at X-Request-Id.
  • Flint-Version. An unknown version is INVALID_VALUE at Flint-Version (or api_version in a body), with the valid values in supported_api_versions. A retired version returns 410 API_VERSION_RETIRED instead.
  • Verification codes. A wrong code is INVALID_VALUE on the code field. Responses never reveal to someone guessing that a code was right: onboarding checks remaining attempts first and returns 409 LIMIT_REACHED with reason verification_attempts once they run out, even for a correct code, and checkout customer verification reports wrong, expired, replaced, and out-of-tries codes the same way.

After fixing the input, reuse its Idempotency-Key when the error says the request changed nothing.

Domain refusals#

Three domain codes ask the caller to do something other than correct a named input. Payment option and promotion refusals return 409; processor refusals return 400:

  • PAYMENT_OPTION_UNAVAILABLE: offer another payment option. details[0].reason says why. With amount_out_of_range, the amount is outside the option's limits, and payment_option and, above the maximum, maximum_money come with it.
  • PROMOTION_DECLINED: tell the buyer why the promotion didn't apply, from details[0].reason.
  • PAYMENT_PROCESSOR_REJECTED: the processor refused a request Flint accepted. Read the payment intent before you change anything, and don't send the same request again.

Every error code has one HTTP status. PAYMENT_OPTION_UNAVAILABLE and PROMOTION_DECLINED always return 409, because they depend on stored state. A malformed promotion code returns 400 INVALID_REQUEST with detail INVALID_VALUE at the code's parameter.

Conflicts and limits#

Most 409 errors need different handling from each other, so read remediation.retry and the code together.

A stale assertion versus a lost race. VERSION_CONFLICT (after_refresh) means the expected_version, or another expected_* field you sent, no longer matches. param names the field, and details[0] carries the current value, such as current_version. Read the resource, rebuild the change on its current state, and send it with the new value. next_steps says whether the request's key is free to reuse. Without param, Flint found the resource changed during a write that had no assertion; read current state before you retry, and check what applied if the write had started. CONCURRENT_MODIFICATION (same_request) means another write won a race while your basis was still current. Nothing changed, so resend the same request with the same key. A draft credit note whose creditable amounts changed since you read it returns VERSION_CONFLICT, not CONCURRENT_MODIFICATION, because the draft you hold is stale: read the credit note and rebuild the issue request from its current version. Versions and write fences covers both conflict responses.

Here is the rebuild for a customer note, where the conflict means another writer changed the note first:

JavaScript
async function appendCustomerNote(customerId, line) {
  for (let attempt = 1; attempt <= 3; attempt++) {
    const { data: customer } = await flintFetch(`/v1/customers/${customerId}`);
    try {
      return await flintFetch(`/v1/customers/${customerId}`, {
        method: "PATCH",
        headers: { "Idempotency-Key": crypto.randomUUID() },
        body: JSON.stringify({
          expected_version: customer.version,
          internal_note: [customer.internal_note, line].filter(Boolean).join("\n"),
        }),
      });
    } catch (err) {
      // Another writer changed the customer: read it again and rebuild.
      const stale = err instanceof FlintApiError && err.retry === "after_refresh";
      if (stale && attempt < 3) continue;
      throw err;
    }
  }
}

A bound, a count, and a throttle. These look alike and need different handling:

  • LIMIT_EXCEEDED (409, none): a submitted or stored value is outside a bound computed from current state, such as a refund above what remains refundable. details[0] carries the bound, and param names the input to correct. A smaller request can succeed.
  • LIMIT_REACHED (none): a quota. A count stops every request of this kind, so a smaller request doesn't help. details[0].reason says which count, and whether to lower it, wait for its reset, or use another resource. details[0].limit is the count when it's fixed. When time alone frees capacity, such as a daily cap, details[0].resets_at is the RFC 3339 time it does. Waiting is allowed, but the next attempt is a new request, not a retry.
  • RATE_LIMIT_EXCEEDED (429, same_request): a throttle. You sent requests too fast over a window of at most an hour. Wait for Retry-After, which every 429 carries, and resend the same request.

Static limits on the request itself, such as a maximum string length, are 400 INVALID_VALUE.

A bound names the value to stay inside:

JSON
{
  "error": {
    "type": "conflict_error",
    "code": "LIMIT_EXCEEDED",
    "message": "amount_money exceeds the refundable amount.",
    "param": "amount_money",
    "error_source": "caller",
    "request_id": "req_01KWM7A2F9Q4N8TT5C0H3B6XJD",
    "doc_url": "https://developers.withflintpay.com/docs/errors#limit_exceeded",
    "remediation": {
      "retry": "none",
      "next_steps": "Adjust the request so the resulting value meets the bound in details. Use param when one input is responsible."
    },
    "details": [
      {
        "code": "LIMIT_EXCEEDED",
        "param": "amount_money",
        "message": "amount_money exceeds the refundable amount.",
        "maximum_money": { "amount": 1500, "currency": "USD" }
      }
    ]
  }
}

A throttle names only a wait, in the Retry-After header, from 1 to 3600 seconds:

JSON
{
  "error": {
    "type": "rate_limit_error",
    "code": "RATE_LIMIT_EXCEEDED",
    "message": "Rate limit exceeded.",
    "error_source": "caller",
    "request_id": "req_01KWM7B8M3V6R2YY9D1K4E7ZPA",
    "doc_url": "https://developers.withflintpay.com/docs/errors#rate_limit_exceeded",
    "remediation": {
      "retry": "same_request",
      "next_steps": "Wait for Retry-After, then resend the same request."
    }
  }
}

Resending the first request with the same amount fails again. Resending the second after Retry-After can succeed. A quota that has a resets_at looks like this:

JSON
{
  "error": {
    "type": "conflict_error",
    "code": "LIMIT_REACHED",
    "message": "The daily limit of demo sessions was reached.",
    "error_source": "caller",
    "request_id": "req_01KWM7C4T8W2S5ZZ6E3L9F1HQB",
    "doc_url": "https://developers.withflintpay.com/docs/errors#limit_reached",
    "remediation": {
      "retry": "none",
      "next_steps": "Create another demo session after resets_at."
    },
    "details": [
      {
        "code": "LIMIT_REACHED",
        "reason": "daily_demo_sessions",
        "message": "The daily limit of demo sessions was reached.",
        "limit": 10,
        "resets_at": "2026-11-01T12:00:00Z"
      }
    ]
  }
}

Rate limits covers route classes and quotas.

Refused actions#

409 ACTION_NOT_ALLOWED means the state of a resource refuses the action, such as a capture of a canceled payment or a change to an archived product. Branch on details[0].reason, which is always present. remediation.retry is none for every reason, because the same request fails until the state changes, and next_steps says what to do. An expired report download also returns this 409 code. Only API_VERSION_RETIRED returns 410.

details[0] names the resource that refuses with resource_type and resource_id, which can differ from the resource in the path. It also carries:

  • current_status, when the refusal depends on a lifecycle status, exactly as a GET returns it.
  • supported_actions, when the resource publishes them. A refused payment intent always carries them, possibly [].
  • param, when one request field is the refused part.

These reasons apply to any resource:

reasonThe state that refuses the actionWhat to do
already_appliedThe resource already reflects the action's result.Nothing. Read the resource to confirm.
terminal_statusThe status is final and accepts no more actions of this kind.Create a new resource if you still need one, or follow next_actions.
status_not_reachedThe action becomes available at a later status.Complete the step the resource is waiting on, or wait for it.
in_progressAn operation that waits on a buyer or on an outcome you must observe decides what can happen next, such as a payment that may have succeeded but isn't applied yet, or a buyer's pending subscription collection payment.Wait for it to finish, through webhooks or a read, then send a new request. An immediate retry fails the same way. A step Flint is running with no one else to act is OPERATION_IN_PROGRESS instead.
archivedThe resource is archived.Restore it if its route supports that, or use an active resource.
provider_action_unsupportedThe payment method's next step cannot open as a URL.Continue confirmation with client_action_type: "stripe". The action type remains unlocked.
field_lockedThe field named by param can't change in the current state.Leave the field out, or create a new resource with the value.
not_offeredThe resource doesn't offer this action or option.Choose an offered one, or use a resource that supports it.
configuration_requiredThe resource named by resource_type and resource_id needs configuration first.Update that resource as the message describes, then send the request again.
unsupported_stateAny other state that doesn't allow the action. Always carries current_status.Read the resource and choose an action its state allows, from supported_actions when present.

Payment intents and orders add these:

reasonThe state that refuses the actionWhat to do
managed_by_ownerThe owner needs its own command for this payment.Follow next_actions: pay_order for several order payments together, collect_invoice for an invoice, or create_subscription_payment_retry for a subscription. current_resource names the owner.
authorization_expiredThe authorization passed authorization_expires_at before capture. Nothing was charged.Cancel the payment intent to release the hold now, or let Flint release it, then collect a new payment.
reconciliation_requiredFlint must reconcile the payment or the order's payments. error_source is flint.Don't retry or start another payment. Tell the buyer something like "This payment needs review. Don't try to pay again. Contact the merchant." From your server, read the order and its payments, or the payment intent. If it stays unresolved, contact support with the request_id and the resource ID.

For a payment intent, already_applied answers a new request whose result is already in place, such as capturing a captured payment. A retry with the original Idempotency-Key and body replays the original response instead.

Other reasons name one condition with its own fix, such as merchant_managed_email, on_hold, and credit_note_tax_reconciliation_required. The error catalog lists every reason with its next steps.

Merchant readiness#

409 MERCHANT_NOT_READY means the merchant must finish something before this operation, and details[0].reason says what. error_source tells you who acts:

  • The merchant acts (error_source: merchant), with retry none. For example, onboarding_required and requirements_due mean completing or updating account information; see Going live. billing_suspended, on payout requests only, clears once no currency has 25 units or more of the Flint balance past due, such as when it's paid; see Merchant billing.
  • Flint acts (error_source: flint), with retry none. platform_review clears when Flint finishes its review. For processing_not_enabled, account_setup_repair_required, and account_setup_unavailable, contact Flint support with the request_id.
  • A wait with no clock, with retry none. capability_pending means a payment capability is still activating: read readiness.capabilities on GET /v1/merchant until it's active, then send a new request. platform_funding_unavailable means the operation needs funds that Flint is restoring (error_source: flint). It doesn't stop card payments or saving payment methods. The merchant doesn't need to change anything. Try the blocked operation later as a new request.

The error catalog lists every reason. PAYMENT_OPTION_UNAVAILABLE shares many of these reasons, with the same meaning.

Payment requests use MERCHANT_NOT_READY whenever the merchant or Flint must act before payments can proceed. For example, processor_not_configured means the environment has no active processor account, capability_blocked means the processor hasn't activated a payment capability, and tax_category_required means live payments are paused until the merchant chooses a supported automatic tax category. PAYMENT_PROCESSING_UNAVAILABLE is kept for causes expected to clear on their own.

For buyer account payments, processing_restricted means the store cannot take payments right now. Keep the account readable and show the store's payment message beside the refused action. Cancellation, pause, keeping a subscription, skipping a cycle, and changes to addresses or delivery that do not charge still work for restricted and suspended stores. A closed store keeps receipts and order history readable, while its commerce changes return ACTION_NOT_ALLOWED with reason terminal_status. See Customer accounts.

Error codes to handle by name#

Beyond INVALID_REQUEST, these are the codes most integrations handle explicitly. The error catalog has every code with its statuses, facts, reasons, and fix.

  • HTTP 409
    The payment option can't be used for this merchant, amount, or checkout. Offer another option. details[0].reason says why and sets the retry.
  • HTTP 409
    The promotion didn't apply. Show the buyer why, from details[0].reason.
  • HTTP 400
    The processor refused a request Flint accepted. Read the payment intent, and don't send the same request again.
  • HTTP 401
    No credential was sent. Send the key or session credential the endpoint accepts as Authorization: Bearer <token>.
  • HTTP 401
    Flint can't use the credential. details[0].reason is malformed, unknown, revoked, expired, session_ended, mode_mismatch, or wrong_credential_type; treat one you don't recognize like unknown. malformed with param naming a header such as X-API-Key means the credential was sent outside Authorization. malformed means Flint cannot identify the type; wrong_credential_type means the type is recognized but this route does not accept it. Recognized credentials include auth_type; wrong-type failures also include accepted_auth_types. Expired CLI, partner, onboarding and dashboard tokens report expired; withdrawn CLI authorization, partner grants and onboarding access report revoked. Refresh a token that expired or obtain a new active credential after revocation. See Authentication.
  • HTTP 403
    details[0].missing_scopes lists the scopes, and details[0].reason the remedy. scope_not_granted: the credential lacks a scope this endpoint needs; retry with a credential that holds it. scope_not_held: the credential tried to grant, or manage a key holding, scopes it doesn't hold; leave them out or use a larger credential. install_scope_not_granted: a partner app install wasn't granted the scope; only the merchant can approve it. A key can't add scopes to itself.
  • HTTP 403
    The credential is valid but can't make this request. Branch on details[0].reason. merchant_role_insufficient or organization_role_insufficient means someone with a higher role must act. request_blocked means Flint's firewall matched a security rule. Check the path, query, headers, and body for attack patterns, such as private-address URLs, path traversal, or scripts, and reduce oversized fields before retrying. If the request is legitimate, contact Flint support. live_mode_required and test_mode_required mean the request needs a key in the other mode, such as a test key for test clocks. Flint checks test_mode_required before scopes, so adding scopes to a live key doesn't help.
  • HTTP 404
    An ID in the path, query, or body doesn't exist for this merchant in this mode. param names where the ID came from, and details[0] carries resource_type and resource_id. Check you aren't mixing test and live keys.
  • HTTP 404
    No route matches the path. Check the path, and remove any trailing slash.
  • HTTP 409
    VERSION_CONFLICTRefresh, then retry
    Your expected_version or other expected_* value is stale, or the resource changed during the write. Read it, rebuild the change, and send the current value from details[0]. Follow the key instruction in next_steps.
  • HTTP 409
    CONCURRENT_MODIFICATIONRetry the same request
    Another write won a race while your basis was still current. Nothing changed. Resend the same request with the same key.
  • HTTP 409
    The resource's state refuses the action. Branch on details[0].reason; see Refused actions.
  • HTTP 409
    Other records stop the change, such as an open order that sells a product you're deleting. Resolve the details[0].blocking_resources, then send the request again to find any that remain.
  • HTTP 409
    A unique value or exclusive slot is taken, such as a SKU or an order's open checkout session. param names the field and details[0].current_resource the record that has it. Use that record or send a different value.
  • HTTP 409
    The key was already used on this operation with another target or different parameters. Use a new key for new work, and reuse a key only for an identical retry. See Replay, conflict, or in progress.
  • HTTP 409
    IDEMPOTENCY_KEY_IN_PROGRESSRetry the same request
    The original request with this key is still running. Resend with the same key after Retry-After, or with backoff and jitter. See Replay, conflict, or in progress.
  • HTTP 409
    OPERATION_IN_PROGRESSRetry the same request
    Flint is finishing other work on the resource, such as a payment it's processing. Resend the same request with the same key after Retry-After, or with backoff when the header is absent. details[0].blocking_resources can name the work.
  • HTTP 409
    A value is outside a bound from current state. Correct the input named by param to fit the bound in details[0]. When param is absent, read the named resource and resolve its capacity first.
  • HTTP 409
    A quota: a count stops every request of this kind. details[0].reason says whether to lower the count, wait for its reset, or use another resource. details[0].limit is the count when it's fixed, and details[0].resets_at is when time alone frees capacity. Waiting doesn't help unless resets_at is present or the reason says the count resets.
  • HTTP 409
    A payment attempt on the order or invoice is still active; details[0] names it with its current_status. Resume, capture, or cancel it. Never start a second payment while the first can still succeed.
  • HTTP 409
    An open risk review blocks the capture. Resolve the review in details[0].blocking_resources, read the payment again, and capture only if the authorization is still valid.
  • HTTP 409
    The merchant must finish a readiness step. See Merchant readiness.
  • HTTP 409
    Eligible stock can't cover the whole demand. Each short demand has a detail with quantities and the applicable order line, bundle component, or reservation line ID. Buyer credentials omit inventory_item_id. See Shortage details. Change the demand, restock, or change the routing source.
  • HTTP 409
    DELIVERY_REQUOTE_REQUIREDRefresh, then retry
    The delivery quote or selection expired, moved, or was revoked, as details[0].reason says. Create a new quote, select an option, and send the request again with a new key. For caller_rates_required, create the quote with basis_delivery_quote_id and the requested method_results.
  • HTTP 409
    Repeated wrong gift card codes require a human check. Show the challenge from next_actions to the buyer, then resend the same request with its proof in Flint-Gift-Card-Challenge.
  • HTTP 410
    The Flint-Version you sent has retired. Send one from details[0].supported_api_versions. See API versions.
  • HTTP 413
    The body is over 1 MiB, or the lower limit an endpoint names. Split the write, such as adding an order's line items in batches.
  • HTTP 429
    RATE_LIMIT_EXCEEDEDRetry the same request
    Wait for Retry-After, then resend the same request. Flint-Rate-Limited-Reason names the limit. See Rate limits.
  • HTTP 500
    INTERNAL_ERRORRetry the same request
    Flint failed. Resend the same request with the same key and backoff, and contact support with the request_id if it persists. With reason repair_required, retry is none: wait for Flint's repair. A completed image ingestion that needs a new attempt returns 409 ACTION_NOT_ALLOWED with reason image_ingestion_restart_required.
  • HTTP 500
    Flint can't confirm what the original request did. Follow the read in next_actions to learn the outcome before sending anything under a new key. See Recovery reads.
  • HTTP 502
    EXTERNAL_SERVICE_ERRORRetry the same request
    A service Flint depends on, such as the tax service or card processor, failed. Resend with the same key and backoff. With reason outcome_unknown, retry is none: read the resource to learn whether the operation took effect.
  • HTTP 503
    SERVICE_UNAVAILABLERetry the same request
    A service the request needs is temporarily unavailable. Resend with the same key and backoff. Before effects, a brief database outage, timeout, or failover has no reason and carries a short Retry-After; wait that long before resending. An uncertain database write uses reason outcome_unknown: keep the original key and read the outcome first. With reason outcome_unknown or repair_required, retry is none.
  • HTTP 503
    PAYMENT_PROCESSING_UNAVAILABLERetry the same request
    Payments can't be processed for this merchant environment right now, for a cause expected to clear on its own. Resend with backoff when remediation.retry is same_request. The API also recognizes platform_funding_unavailable with retry none for compatibility; low Flint funding no longer blocks card payments. When the merchant or Flint must act first, payments return MERCHANT_NOT_READY; see Merchant readiness.
  • HTTP 504
    REQUEST_TIMEOUTRetry the same request
    The request ran out of time, and the write may have completed. Resend with the same key, so a completed write is replayed rather than repeated.

Response headers#

HeaderWhenMeaning
X-Request-IdEvery responseFlint's ID for the request, the same as error.request_id. Log it on success too.
Retry-AfterEvery 429, in-progress 409, and some 503 responsesWhole seconds to wait, at least 1 (1 to 3600 on a 429). Always sent on a 429. On other same_request errors, sent when Flint knows or can bound the wait. Without it, a same_request retry uses exponential backoff and jitter. Only same_request errors carry it.
Flint-Rate-Limited-Reason429Which limit was hit, such as credential, merchant, or global_ip.
RateLimit-Policy, RateLimitMerchant credentials, once the route-class limiter has runQuotas, remaining requests, and reset times. See Quota headers. On a 429, honor Retry-After first.
Idempotency-ReplayedReplayed idempotent writestrue means this is the stored original response, not a new execution.
Flint-ModeRequests Flint authenticated on an existing routetest or live, useful when diagnosing mixed-up keys. Absent on 401, on 404 ROUTE_NOT_FOUND and 405 METHOD_NOT_ALLOWED, and on a 429 whose Flint-Rate-Limited-Reason is global_ip.

Write one error handler#

Parse errors in one place so the rest of your code works with typed errors:

JavaScript
class FlintApiError extends Error {
  constructor(status, headers, body) {
    const e = body?.error ?? {};
    super(e.message ?? `Flint API error (HTTP ${status})`);
    this.name = "FlintApiError";
    this.status = status;
    this.type = e.type;
    this.code = e.code;
    this.param = e.param;
    this.details = e.details ?? [];
    this.reason = this.details[0]?.reason;
    this.remediation = e.remediation;
    this.requestId = e.request_id ?? headers.get("X-Request-Id");
    const retryAfter = Number(headers.get("Retry-After"));
    this.retryAfterMs = retryAfter > 0 ? retryAfter * 1000 : undefined;
    // Without an envelope, fall back to the status class.
    this.retry =
      e.remediation?.retry ?? (status === 429 || status >= 500 ? "same_request" : "none");
  }
}

async function flintFetch(path, options = {}) {
  const res = await fetch(`https://api.withflintpay.com${path}`, {
    ...options,
    headers: {
      "Content-Type": "application/json",
      Authorization: `Bearer ${process.env.FLINT_API_KEY}`,
      ...options.headers,
    },
  });
  const text = await res.text();
  let body = null;
  try {
    body = text ? JSON.parse(text) : null;
  } catch {
    // Not JSON, such as a proxy's error page: handled by the status fallback.
  }
  if (!res.ok) throw new FlintApiError(res.status, res.headers, body);
  return body;
}

Validation errors get their own branch, because they map to form fields:

JavaScript
try {
  await flintFetch("/v1/orders", { method: "POST", body: JSON.stringify(payload) });
} catch (err) {
  if (err instanceof FlintApiError && err.code === "INVALID_REQUEST") {
    for (const issue of err.details) showFieldError(issue.param, issue.message);
    return;
  }
  throw err;
}

With the Node or PHP SDK, a failed call throws SdkError with the code, status, and request ID already parsed, and the SDK runs the retry loop below for you.

Retry without double-charging#

A timeout or dropped connection doesn't tell you whether a write happened. An Idempotency-Key makes the retry safe: Flint replays or resumes the original request instead of running it twice. Idempotency has the rules for keys.

Retrying a write after a timeoutResponse
Your serverFlintPOST /v1/refunds with Idempotency-Key: refund-2098refund created, but the response is lost to a timeoutthe same POST, body, and keythe original refund, with Idempotency-Replayed: true
  1. Your server sends POST /v1/refunds with Idempotency-Key: refund-2098 to Flint
  2. Flint returns refund created, but the response is lost to a timeout to Your server
  3. Your server sends the same POST, body, and key to Flint
  4. Flint returns the original refund, with Idempotency-Replayed: true to Your server

Four rules keep retries safe:

  1. Resend unchanged only when remediation.retry is same_request, or when a network failure left you with no response at all.
  2. Honor Retry-After when it's present. Otherwise use exponential backoff with jitter, and cap both attempts and total time.
  3. Send an Idempotency-Key on every write you might retry, and keep it for every retry. Resend after a network failure only for reads and for writes that carry a key.
  4. On after_refresh, read the resource and rebuild the request. Follow the key instruction in next_steps.
JavaScript
// Wrap only reads and writes that carry an Idempotency-Key.
async function withRetries(send, { attempts = 4, deadlineMs = 60_000 } = {}) {
  const deadline = Date.now() + deadlineMs;
  let delayMs = 500;
  for (let attempt = 1; ; attempt++) {
    try {
      return await send();
    } catch (err) {
      // No response at all (a network error) is safe to resend with the same key.
      const networkError = !(err instanceof FlintApiError);
      const retryable = networkError || err.retry === "same_request";
      const waitMs = err.retryAfterMs ?? delayMs + Math.random() * delayMs;
      const outOfTime = Date.now() + waitMs > deadline;
      if (!retryable || attempt === attempts || outOfTime) throw err;
      await new Promise((resolve) => setTimeout(resolve, waitMs));
      delayMs = Math.min(delayMs * 2, 30_000);
    }
  }
}

const idempotencyKey = `order:${cart.id}`; // your own record names the action
await withRetries(() =>
  flintFetch("/v1/orders", {
    method: "POST",
    headers: { "Idempotency-Key": idempotencyKey },
    body: JSON.stringify(payload),
  }),
);

When the retries end without an answer, keep the key and see Handle an unresolved outcome.

A declined card is not an error#

A declined card doesn't fail the request. Flint has no 402 status and no payment error type. Every route that starts, confirms, captures, or retries a payment returns 2xx with the resulting resource, and a decline or block is in its last_payment_error: on a payment intent, an order or invoice payment attempt, or a subscription payment retry. A block by a risk rule or the processor's fraud screening has last_payment_error.code payment_blocked; tell the buyer the payment didn't go through, without naming the rule.

A 4xx means Flint refused the request before any payment was attempted, and a 5xx means Flint couldn't get an answer. If you only handle thrown errors, declines are invisible to you. Declines and payment attempts has the full table and the recovery model.

Payment outcomes reach you two ways:

  • Webhook events, the source of truth for money movement. Subscribe to the failure events for each flow you run, not only the success events. See Webhooks.
  • Resource state, when you read the resource. An order reports payment_status and settlement_amounts.paid_money; a refund reports status failed with a failure_reason.

Three rules follow:

  1. A 2xx from a create call isn't a payment. Creating a checkout session, invoice, or payment intent starts a payment; only events and resource state finish one.
  2. Mark orders paid from order.paid, not from a redirect or a create response.
  3. Show buyers your own retry-friendly message. Decline reasons are for your logs and dashboards.

If you drive order payment yourself instead of using hosted checkout, POST /v1/orders/{order_id}/pay returns data.order_payment_attempt with its last_payment_error and is_resumable. A processing attempt may already have charged the buyer. Wait for events or read it again while Flint resolves or applies the outcome; no merchant resume is required. To exercise these paths before launch, use the test cards that force declines and authentication.

Production checklist#

  • Log request_id, type, code, details[0].reason, and param on every failed response.
  • Alert on your 5xx and 429 rates, and on spikes in 401 and 403, which usually mean a rotated or misconfigured key.
  • Cap retry attempts and total time, and add jitter, so an outage doesn't turn your workers into a thundering herd.
  • Keep a default branch for codes you don't name, keyed on status class and remediation.retry, and treat an unknown reason as its code's default.
  • Subscribe to the failure webhooks for every payment flow you run, and test each handler.
  • Trace a request_id yourself with Debugging before contacting support, and quote it when you do.

Next steps#

Error codesEvery code with its statuses, retry value, facts, reasons, and fix.IdempotencyThe six rules for keys, which routes take one, and recovery reads.Declines and payment attemptsRead payment outcomes and recover from declines.Card decline codesWhat each issuer decline means and what to tell the buyer.

The CLI maps the same failure classes to stable exit codes, so a script can branch on them without parsing output.

Was this helpful?