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
- Error response body
- HTTP status codes
- Operations that fail with HTTP 200
- Retry strategy
- Errors by endpoint
How to read a response
The FlexFactor API reports a problem in one of two places. Check both on every call.
- The HTTP status code. A
4xxcode means that FlexFactor rejected the request and did not perform the operation. A5xxcode means that the request failed. In most cases FlexFactor did not perform the operation, but after a500the outcome can be unknown. Before you retry a capture, void, or refund that returned500, confirm the order withGET /v1/orders/{id}. The response body describes the error — see Error response body. - The response body of an HTTP
200. An HTTP200means 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.
| Property | Type | Meaning |
|---|---|---|
type | string | A link to the HTTP specification section for the status code. |
title | string | A short description of the error. |
status | integer | The HTTP status code. |
detail | string | An explanation of this occurrence of the error. Optional |
errors | object | Maps each field name to an array of messages. A field with several errors has several messages. Optional |
traceId | string | A 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.
| Format | Shape | Returned by |
|---|---|---|
| A | Problem details: type, title, status, errors, traceId. A request-level error, such as an empty body, uses the key "" in errors | Every endpoint except /evaluate |
| B | Problem details without type | /oauth2/token when the credentials are not valid |
| C | A 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 |
| D | A JSON string, not an object | The path-based POST /v1/orders/{id}/refund when amount and amountToRefund disagree |
| E | The refund envelope with status: FAILED, success: false, and errors | The 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.
| Item | Type | Meaning |
|---|---|---|
item1 | string | Message |
item2 | string | Key, usually the field name |
item3 | string | Error code, for example REFUND_FAILED |
item4 | boolean | Friendly 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 Code | Description |
|---|---|
| 200 OK | FlexFactor processed the request. Read the response body for the outcome of the operation. |
| 201 Created | Resource created successfully. |
| 204 No Content | The request succeeded and no response body is returned. |
| 400 Bad Request | The request failed validation. Parse the errors object for field-level details. Do not retry the same payload. |
| 401 Unauthorized | The 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 Forbidden | Access to the requested resource is denied. |
| 404 Not Found | The 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 Allowed | The method you supplied is not allowed for that resource, for example a PUT method on a read-only resource. |
| 409 Conflict | An idempotent request is still in progress, or an idempotency key was reused with a different payload. See Idempotency. |
| 500 Internal Server Error | An error occurred that could not be handled by the application. |
| 502 Bad Gateway | An invalid response was received by the server. |
| 503 Service Unavailable | The server is temporarily unable to handle this request. See Retry strategy. |
| 504 Gateway Timeout | The 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.
| Endpoint | Field to read | A failed or unconfirmed outcome looks like | What to do |
|---|---|---|---|
POST /v1/evaluate | status, then result | status: 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/capture | status | status: 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}/refund | status | status: 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-cancel | success, then the order record | success: 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/transmit | The body | An 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
| Status | Recommended behavior |
|---|---|
400 Bad Request | Do not retry the same payload. Correct the request first. |
401 Unauthorized | Refresh the access token via /oauth2/token once, then retry. Do not loop. |
404 Not Found | Do 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 Timeout | Exponential 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 Unavailable | Do 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.
| Endpoint | Status codes documented | Details | 400 messages |
|---|---|---|---|
POST /v1/oauth2/token | 200, 400 | /oauth2/token | /oauth2/token |
POST /v1/tokenize | 200, 400, 404, 500 | /tokenize | /tokenize |
POST /v1/evaluate | 200, 400, 401, 404, 409, 500, 503 | /evaluate | /evaluate |
POST /v1/capture | 200, 400, 401, 404, 409, 500, 503 | /capture | /capture |
POST /v1/void | 200, 400, 401, 404, 409, 500, 503 | /void | /void |
POST /v1/refund | 200, 400, 401, 404, 409, 500, 503 | /refund | /refund |
POST /v1/orders/{id}/refund | 200, 400, 401, 404, 409, 500, 503 | /refund | /refund, path-based |
POST /v1/orders/{id}/cancel, /external-cancel | 200, 400, 401, 404, 409, 500, 503 | /cancel | /cancel |
GET /v1/orders/{id} | 200, 400, 401, 404, 500 | /orders/{id} | /orders/{id} |
GET /v1/orders | 200, 400, 401, 404, 500 | /orders | /orders |
POST /v1/transmit | 200, 400, 401, 404 | /transmit | /transmit |
Updated 8 days ago

