Error Handling

How the FlexFactor API reports errors: the HTTP status code, the error response body, the operations that fail with HTTP 200, and the retry rule for each status code.


How to read a response

The FlexFactor API reports a problem in one of two places. Check both on every call.

  1. The HTTP status code. A 4xx code means that FlexFactor rejected the request and did not perform the operation. A 5xx code means that the request failed. In most cases FlexFactor did not perform the operation, but after a 500 the outcome can be unknown. Before you retry a capture, void, or refund that returned 500, confirm the order with GET /v1/orders/{id}. The response body describes the error — see Error response body.
  2. The response body of an HTTP 200. An HTTP 200 means that FlexFactor processed the request. It does not mean that the transaction was approved, captured, voided, or refunded. The outcome is in the body — see Operations that fail with HTTP 200.

The shared response envelope and the mapping between HTTP status codes, result, and status are defined in Workflows §3.5.


Error response body

An error response carries problem details. The body of a 401 or a 500 can be empty; the status-code table on each endpoint page states the body.

PropertyTypeMeaning
typestringA link to the HTTP specification section for the status code.
titlestringA short description of the error.
statusintegerThe HTTP status code.
detailstringAn explanation of this occurrence of the error. Optional
errorsobjectMaps each field name to an array of messages. A field with several errors has several messages. Optional
traceIdstringA correlation ID. Include it when you contact support.

Example: a /capture whose amount does not match the order.

{
  "type": "https://tools.ietf.org/html/rfc9110#section-15.5.1",
  "title": "One or more validation errors occurred.",
  "status": 400,
  "errors": {
    "Amount": ["Amount mismatch. Please provide the correct amount (9900)"]
  },
  "traceId": "00-64a5cf4492a4f17b5751dce5120fe708-631875e92558b83a-01"
}

The errors object is not present on every error response. If it is absent, read title and detail for the description of the error.

Error body formats

A 400 uses one of five body formats. Every other error status uses Format A, plain text, a JSON string, or no body, with 2 exceptions: a 500 from /void can carry the void envelope, and a 500 from /cancel can carry the two-field cancel body. The status-code table on each endpoint page states which body each status carries. Error Messages by Endpoint names the format of each 400.

FormatShapeReturned by
AProblem details: type, title, status, errors, traceId. A request-level error, such as an empty body, uses the key "" in errorsEvery endpoint except /evaluate
BProblem details without type/oauth2/token when the credentials are not valid
CA flat object that maps each field name to its messages, with the trace ID as an entry named TraceId. No status or title/evaluate only
DA JSON string, not an objectThe path-based POST /v1/orders/{id}/refund when amount and amountToRefund disagree
EThe refund envelope with status: FAILED, success: false, and errorsThe path-based POST /v1/orders/{id}/refund when the credential type does not allow the operation, or when the refund failed before it ran

In Format A and Format C, keys for validation rules are PascalCase whatever casing you sent, for example Amount on /capture and General on /refund. Keys for parser errors and query parameters repeat the name as you sent it, for example idempotencyKey or pageSize.

The errors array in an HTTP 200 response

The response envelope that the POST endpoints return with HTTP 200 also has a field named errors. It is a different structure from the problem-details errors object: an array of objects, empty on success. Each item is serialized positionally.

ItemTypeMeaning
item1stringMessage
item2stringKey, usually the field name
item3stringError code, for example REFUND_FAILED
item4booleanFriendly flag: true when the message is safe to show to an end user
{
   "status": "FAILED",
   "success": false,
   "errors": [
      { "item1": "{failure reason}", "item2": "{error key}", "item3": "{error code}", "item4": true }
   ]
}

Validation messages are for developers

The messages in a 400 body name fields and parser positions. Log them and correct the request; do not show them to a cardholder. In the envelope, the item4 flag marks the messages that are safe to show to an end user.


HTTP status codes

Response CodeDescription
200 OKFlexFactor processed the request. Read the response body for the outcome of the operation.
201 CreatedResource created successfully.
204 No ContentThe request succeeded and no response body is returned.
400 Bad RequestThe request failed validation. Parse the errors object for field-level details. Do not retry the same payload.
401 UnauthorizedThe bearer token is missing, invalid, or expired. A token is valid for 30 minutes. Invalid appKey or appSecret on /oauth2/token return 400, not 401.
403 ForbiddenAccess to the requested resource is denied.
404 Not FoundThe target resource does not exist, for example an unknown order ID or an order that belongs to another merchant. The body is problem details (type, title, status, detail). A path {id} that is not a GUID returns 404 with an empty body.
405 Method Not AllowedThe method you supplied is not allowed for that resource, for example a PUT method on a read-only resource.
409 ConflictAn idempotent request is still in progress, or an idempotency key was reused with a different payload. See Idempotency.
500 Internal Server ErrorAn error occurred that could not be handled by the application.
502 Bad GatewayAn invalid response was received by the server.
503 Service UnavailableThe server is temporarily unable to handle this request. See Retry strategy.
504 Gateway TimeoutThe upstream server did not respond in time.

Operations that fail with HTTP 200

FlexFactor returns HTTP 200 for an operation that it processed but that did not succeed. Key your logic on the field in the table, not on the HTTP status code.

EndpointField to readA failed or unconfirmed outcome looks likeWhat to do
POST /v1/evaluatestatus, then resultstatus: DECLINED. The rescue was declined when result is Success. The evaluation did not complete when result is Failed. success stays true, so do not read success on this endpoint.Return the original decline to the merchant.
POST /v1/capturestatusstatus: FAILED. success stays true, so do not read success on this endpoint.Treat the capture as failed. The order stays in capturerequired until the capture window elapses.
POST /v1/refund and the path-based POST /v1/orders/{id}/refundstatusstatus: FAILED and success: false. responseCode and responseMessage carry the processor result. An unexpected failure carries REFUND_FAILED in errors.Follow the retry rules for a failed refund on the /refund page.
POST /v1/orders/{id}/cancel and /external-cancelsuccess, then the order recordsuccess: true is also returned when the order was not in a cancellable status and nothing changed.Confirm with GET /v1/orders/{id} (status cancelled) or the order.cancelled webhook before you mark the order cancelled.
POST /v1/transmitThe bodyAn empty body. An internal error occurred, and the response carries no success and no transmitId.Check that the body is present before you read it. FlexFactor did not confirm the copy.

POST /v1/void is not in this table. A void that the processor does not apply returns HTTP 500 with status: FAILED, never HTTP 200.


Retry strategy

StatusRecommended behavior
400 Bad RequestDo not retry the same payload. Correct the request first.
401 UnauthorizedRefresh the access token via /oauth2/token once, then retry. Do not loop.
404 Not FoundDo not retry. Check the order identifier. If an /evaluate response was lost and you do not have the FlexFactor orderId, see Workflows §3.1.
409 Conflict (in-flight)An idempotent request is still being processed. Retry the same request and key after a short backoff. See Idempotency.
409 Conflict (reused key)The idempotency key was reused with a different payload. Do not retry — use a unique key per operation.
500 Internal Server Error / 502 Bad Gateway / 504 Gateway TimeoutExponential backoff, up to 3 attempts. Send the same idempotencyKey on every attempt. (Exception: a 500 that the same idempotencyKey keeps returning means an earlier attempt failed with an unknown outcome. Do not retry automatically; check the order with GET /v1/orders/{id} first — see Idempotency.)
503 Service UnavailableDo not retry. Fall back to the original decline. The 503 indicates FlexFactor cannot rescue this transaction right now, and a retry will not change the outcome within the merchant decision window. (Exception: a 503 from the idempotency store carries a Retry-After header and is safe to retry — see Idempotency.)

After a timeout or any uncertain result, GET /v1/orders/{id} is the authoritative record of the order. See Workflows §3.3.


Errors by endpoint

Each endpoint page lists the HTTP status codes that the endpoint returns and the body that comes with each one. The error messages page of each endpoint lists the error key and the message for each 400.

EndpointStatus codes documentedDetails400 messages
POST /v1/oauth2/token200, 400/oauth2/token/oauth2/token
POST /v1/tokenize200, 400, 404, 500/tokenize/tokenize
POST /v1/evaluate200, 400, 401, 404, 409, 500, 503/evaluate/evaluate
POST /v1/capture200, 400, 401, 404, 409, 500, 503/capture/capture
POST /v1/void200, 400, 401, 404, 409, 500, 503/void/void
POST /v1/refund200, 400, 401, 404, 409, 500, 503/refund/refund
POST /v1/orders/{id}/refund200, 400, 401, 404, 409, 500, 503/refund/refund, path-based
POST /v1/orders/{id}/cancel, /external-cancel200, 400, 401, 404, 409, 500, 503/cancel/cancel
GET /v1/orders/{id}200, 400, 401, 404, 500/orders/{id}/orders/{id}
GET /v1/orders200, 400, 401, 404, 500/orders/orders
POST /v1/transmit200, 400, 401, 404/transmit/transmit


Did this page help you?