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 most5xxerrors. Wait, then send the identical request with the sameIdempotency-Key.after_refresh: the resource changed under you. Read it and rebuild the request from what you read.next_stepssays whether the request's key is free to reuse.none: resending can't succeed. Fix the input, or do whatnext_stepssays, 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 -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" }
}
]
}'
{
"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.
| Field | What it holds |
|---|---|
type | Coarse category, set by the HTTP status. Always present. See Error types. |
code | Stable identifier for the failure, such as INVALID_REQUEST. Always present. Branch on this. |
message | Explanation for your logs. Always present. Wording can change, so don't parse it or show it to buyers. |
param | Path 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. |
details | Typed facts about the failure. See Facts in details. |
request_id | Flint'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_url | Path 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_url | This code's entry in the error catalog: https://developers.withflintpay.com/docs/errors# and the lowercase code. Always present. |
error_source | Who has to act. Always present. See below. |
remediation | What 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 objectWarning: 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 owncode,param, andmessage. See Validation errors. - On every other code,
details[0]is the primary failure. It repeats the top-levelcodeandparamand carries the facts. Later items are more instances of the same condition, such as several out-of-stock lines. detailsis present on every validation error and every error that carries a fact. It is absent whencode,message, andparamsay everything, as onRATE_LIMIT_EXCEEDED.
A code carries only the facts its catalog entry lists. These are the ones most integrations read:
| Fact | Sent with | Use it to |
|---|---|---|
reason | Codes that have reasons, such as ACTION_NOT_ALLOWED, FORBIDDEN, INVALID_CREDENTIAL, LIMIT_REACHED, and MERCHANT_NOT_READY | Pick the specific fix. ACTION_NOT_ALLOWED always has one. |
resource_type, resource_id | RESOURCE_NOT_FOUND, state refusals, and conflicts | Find 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_actions | ACTION_NOT_ALLOWED and other state conflicts | See the resource's state as a GET returns it, and the actions it accepts now. An empty supported_actions means none. |
current_version | VERSION_CONFLICT for a stale expected_version | Read the resource, rebuild the change, and send this value as expected_version. |
current_api_version | VERSION_CONFLICT for a stale expected_api_version on a webhook endpoint or partner app | Confirm the current pin, then send this value as expected_api_version. |
blocking_resources, blocking_resource_count | RESOURCE_IN_USE, OPERATION_IN_PROGRESS, PAYMENT_ATTEMPT_ACTIVE, PAYMENT_REVIEW_OPEN | Resolve 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_resource | ALREADY_EXISTS, and some checkout conflicts | Use 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_quantity | LIMIT_EXCEEDED, and PAYMENT_OPTION_UNAVAILABLE with reason amount_out_of_range | Keep the value inside the bound. |
conflicting_fields | INVALID_REQUEST with detail code NOT_ALLOWED | The other inputs param conflicts with. Remove param, or remove these. |
selectable_resources | INVALID_REQUEST on a field with a set of valid IDs, such as merchant_id for a developer credential | Submit one of the returned resource_id values. |
supported_api_versions | INVALID_REQUEST on Flint-Version, and API_VERSION_RETIRED | Send one of these versions. |
missing_scopes, scope_requirement | INSUFFICIENT_SCOPE | See 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_seconds | IDENTITY_VERIFICATION_REQUIRED | See 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:
{
"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 remediationTrust 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 thedetails[0].reason, then the instruction for thecode. On a validation error, the inputs to fix are thedetails[].paramvalues.next_actions: concrete steps, when Flint can name them. Each has anaction_type, and can have areason_codeandreason_message, theurlof the endpoint or page to use, itsrequired_fieldsandrequired_scope, anexpires_at,requires_human_confirmation, and asuggested_delay_millisecondsbefore 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.
| Status | type | What happened | Usual retry |
|---|---|---|---|
400 | validation_error | The request failed validation, or a processor refused it | none |
401 | authentication_error | No credential, or one Flint can't use: malformed, unknown, revoked, expired, or in the wrong mode | none |
403 | authorization_error | The credential is valid but lacks a scope (INSUFFICIENT_SCOPE) or can't make this request (FORBIDDEN) | none |
404 | not_found_error | No such resource for this merchant and mode (RESOURCE_NOT_FOUND), or no such route (ROUTE_NOT_FOUND) | none |
405, 410, 413, 415, 499 | protocol_error | Wrong 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 |
409 | conflict_error | The request conflicts with current state: a stale version, a taken value, a lifecycle rule, a bound, or an idempotency key | Depends on the code |
429 | rate_limit_error | You sent requests too fast. Always RATE_LIMIT_EXCEEDED, always with Retry-After | same_request |
500 | internal_error | Flint failed while handling the request | same_request |
502 | external_service_error | A service Flint depends on failed | same_request |
503 | unavailable_error | A service Flint needs, such as its database, is temporarily unavailable | same_request |
504 | timeout_error | The request ran out of time. The operation may still have completed | same_request |
| Any other error status | internal_error | Treat as a Flint failure | same_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-codeson an operation lists its top-level codes, and the same extension on each error response lists the top-level codes that status can carry.ErrorDetailCodeincludes the four validation detail codes and the top-level codes that other details repeat. Each top-level code has one HTTP status.API_VERSION_RETIREDappears 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
retryvalue and fix, and its facts, the extra properties itsdetailsitems can have. A code marked "Appears only indetails[]" is never the top-levelcode. - 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.reasonlists the same values as "When code isX, 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 code | Meaning |
|---|---|
REQUIRED | An 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_VALUE | Flint 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_FIELD | The 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_ALLOWED | The 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 asline_items[0].name, and a map value adds its key, such asmetadata.order_ref. A map key that has characters other than letters, digits,_, and-is quoted in brackets, such asmetadata["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 asbilling_start.type, names the discriminator. A field that belongs to another branch of a union isUNKNOWN_FIELDat that field. - Too many or too few items, entries, or properties names the collection, such as
line_itemsormetadata. A repeated array entry names the later one, such asallowed_resolution_types[1]. - Inputs that can't be sent together are
NOT_ALLOWEDat the one to remove, with the others inconflicting_fields, which never repeatsparam. When one of them selects a mode, such as atype, the detail names the other input andconflicting_fieldsnames 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 asdetails:{"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 aspayment_return_url, isREQUIREDat 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 asstatus, including when one value of a multi-value filter is wrong. A parameter that takes one value and is sent twice isINVALID_VALUEat its name. An unknown query parameter whose name has other characters, such asstatus[], is quoted:["status[]"]. - A failure of the whole body uses
body: malformed JSON, a body that isn't an object, or aPATCHwith no fields. A failure of one field never usesbody. - If an operation publishes no request body, send no body or
{}. Any JSON member isUNKNOWN_FIELDat 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, orX-Request-Id. - A range that ends before it starts, such as
created_beforeearlier thancreated_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
ACTIVEand" active"are rejected. A list filter that takes comma-separated values trims spaces around each value, sostatus=active, pausedmatches both. - Empty strings.
""is never a value or a clear. Leave a field out to keep it, sendnullto clear a field that can be cleared, or set a metadata key tonullto delete it. The message says whethernullclears the field. For an address in a country with no state or postal code, sendnullor 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 betrueorfalse. - Credential-restricted fields. A field your credential may not send, such as a merchant-only field on a checkout or customer credential, or
customer_idunder/v1/me, isNOT_ALLOWEDat that field. Sending checkout session headers together with anAuthorizationcredential is also400 NOT_ALLOWED, with both headers inconflicting_fields.403is only for a credential that can't call the endpoint at all. expected_version. Missing where a write requires it isREQUIRED, and not a positive integer isINVALID_VALUE. A stale one is409 VERSION_CONFLICT, not a validation error.Idempotency-Key. Missing on a route that requires one isREQUIRED, and a key Flint rejects isINVALID_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, isINVALID_VALUEatX-Request-Id.Flint-Version. An unknown version isINVALID_VALUEatFlint-Version(orapi_versionin a body), with the valid values insupported_api_versions. A retired version returns410 API_VERSION_RETIREDinstead.- Verification codes. A wrong code is
INVALID_VALUEon the code field. Responses never reveal to someone guessing that a code was right: onboarding checks remaining attempts first and returns409 LIMIT_REACHEDwith reasonverification_attemptsonce 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].reasonsays why. Withamount_out_of_range, the amount is outside the option's limits, andpayment_optionand, above the maximum,maximum_moneycome with it.PROMOTION_DECLINED: tell the buyer why the promotion didn't apply, fromdetails[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:
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, andparamnames 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].reasonsays which count, and whether to lower it, wait for its reset, or use another resource.details[0].limitis the count when it's fixed. When time alone frees capacity, such as a daily cap,details[0].resets_atis 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 forRetry-After, which every429carries, 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:
{
"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:
{
"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:
{
"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 aGETreturns 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:
reason | The state that refuses the action | What to do |
|---|---|---|
already_applied | The resource already reflects the action's result. | Nothing. Read the resource to confirm. |
terminal_status | The 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_reached | The action becomes available at a later status. | Complete the step the resource is waiting on, or wait for it. |
in_progress | An 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. |
archived | The resource is archived. | Restore it if its route supports that, or use an active resource. |
provider_action_unsupported | The payment method's next step cannot open as a URL. | Continue confirmation with client_action_type: "stripe". The action type remains unlocked. |
field_locked | The field named by param can't change in the current state. | Leave the field out, or create a new resource with the value. |
not_offered | The resource doesn't offer this action or option. | Choose an offered one, or use a resource that supports it. |
configuration_required | The resource named by resource_type and resource_id needs configuration first. | Update that resource as the message describes, then send the request again. |
unsupported_state | Any 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:
reason | The state that refuses the action | What to do |
|---|---|---|
managed_by_owner | The 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_expired | The 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_required | Flint 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 retrynone. For example,onboarding_requiredandrequirements_duemean 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 retrynone.platform_reviewclears when Flint finishes its review. Forprocessing_not_enabled,account_setup_repair_required, andaccount_setup_unavailable, contact Flint support with therequest_id. - A wait with no clock, with retry
none.capability_pendingmeans a payment capability is still activating: readreadiness.capabilitiesonGET /v1/merchantuntil it's active, then send a new request.platform_funding_unavailablemeans 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.
Response headers#
| Header | When | Meaning |
|---|---|---|
X-Request-Id | Every response | Flint's ID for the request, the same as error.request_id. Log it on success too. |
Retry-After | Every 429, in-progress 409, and some 503 responses | Whole 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-Reason | 429 | Which limit was hit, such as credential, merchant, or global_ip. |
RateLimit-Policy, RateLimit | Merchant credentials, once the route-class limiter has run | Quotas, remaining requests, and reset times. See Quota headers. On a 429, honor Retry-After first. |
Idempotency-Replayed | Replayed idempotent writes | true means this is the stored original response, not a new execution. |
Flint-Mode | Requests Flint authenticated on an existing route | test 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:
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:
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.
- Your server sends POST /v1/refunds with Idempotency-Key: refund-2098 to Flint
- Flint returns refund created, but the response is lost to a timeout to Your server
- Your server sends the same POST, body, and key to Flint
- Flint returns the original refund, with Idempotency-Replayed: true to Your server
Four rules keep retries safe:
- Resend unchanged only when
remediation.retryissame_request, or when a network failure left you with no response at all. - Honor
Retry-Afterwhen it's present. Otherwise use exponential backoff with jitter, and cap both attempts and total time. - Send an
Idempotency-Keyon 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. - On
after_refresh, read the resource and rebuild the request. Follow the key instruction innext_steps.
// 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_statusandsettlement_amounts.paid_money; a refund reportsstatusfailedwith afailure_reason.
Three rules follow:
- A
2xxfrom 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. - Mark orders paid from
order.paid, not from a redirect or a create response. - 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, andparamon every failed response. - Alert on your
5xxand429rates, and on spikes in401and403, 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 unknownreasonas its code's default. - Subscribe to the failure webhooks for every payment flow you run, and test each handler.
- Trace a
request_idyourself with Debugging before contacting support, and quote it when you do.
Next steps#
Error codesIdempotencyDeclines and payment attemptsCard decline codesThe CLI maps the same failure classes to stable exit codes, so a script can branch on them without parsing output.