/cancel
Cancel pending orders before they are captured by FlexFactor.
Merchant Initiated Transactions (MIT) are sent to FlexFactor for an asynchronous evaluation.
If the customers cancel their subscriptions while they are pending over at FlexFactor, you can cancel them by using the /cancel endpoint.
/cancel behaves like a VOID: it stops a rescue that has not yet been captured, rather than reversing a settled charge. You can cancel:
- MIT orders in
draft,onhold,processing, orcapturerequiredstatus — any status that is notcompletedorcancelled - CIT orders in
capturerequiredoronholdstatus
To reverse a charge that has already been captured, use /refund instead.
A cancel always applies to the full order amount. There is no partial cancel: the request body carries no amount or currency field, and the only accepted body field is the optional idempotencyKey. To return part of a charge after capture, use /refund with a partial amount.
Void part of an order with /voidTo release part of an order before capture, or to void with an explicit amount, use /void.
Cancel names the order in the URL. This differs from /void and /refund, which name the order in the request body. Two endpoints are available, depending on whether you have already received the FlexFactor order ID (orderId, returned by /evaluate alongside orderSessionKey):
POST /v1/orders/{id}/cancel— the standard cancellation, used once the FlexFactororderIdis known.POST /v1/orders/{external-order-id}/external-cancel— a standard alternative that identifies the order by your own external order ID, usable at any time. It is especially useful when the FlexFactor order ID was never received (for example, the/evaluateresponse timed out). See external-cancel below.
Prerequisites to invoke this API:
- Authenticate and send the bearer token for this call.
IdempotencyNeither
/cancelnor/external-cancelrequires anidempotencyKey— idempotency is enforced server-side via the order ID, so repeated cancel calls for the same order are safe.You can include an optional
idempotencyKey(a GUID, in the JSON body). When present, a retry within the 24-hour replay window replays the original response, and a reused key with a different payload is rejected as a409conflict. Because/external-cancelis keyed by the same underlying order as/cancel, issuing both for one order collapses into a single operation. See the Idempotency reference (§3.4) for the full behavior.
Request
Details
| HTTP Method | POST |
| Endpoint - Sandbox | https://api-sandbox.flexfactor.io/v1/orders/{id}/cancel |
| Endpoint - Production | https://api.flexfactor.io/v1/orders/{id}/cancel |
| {id} | FlexFactor unique transaction identifier.\ This is the FlexFactor orderId returned by /evaluate and/or GET /v1/orders/{id} and/or webhook and/or batch response file. |
| Authentication | Bearer Token |
Body
This API doesn't require body parameters. A POST with an empty body ({}) is valid. You can optionally include an idempotencyKey (GUID) to make retries safe — see Idempotency. No other body fields are accepted; there is no amount or currency.
Response
A cancel returns HTTP 200 with a body of two fields. Read success to decide whether the request was processed; a 200 does not by itself prove that the order was cancelled.
success | boolean | true when FlexFactor processed the cancel. It is also true when the order was not in a cancellable status and nothing changed. |
responseMessage | string | null on success. Failed to cancel order when the cancel failed. |
The cancel response does not use the common FlexFactor envelope: it carries no status, result, statusCode, errors, or customProperties.
A 200 is returned even when nothing was cancelledA cancel against an order that is not in a cancellable status (for example
completed) also returns HTTP200withsuccess: true, and the order is unchanged. Confirm the result withGET /v1/orders/{id}(statuscancelled) or theorder.cancelledwebhook before you treat the order as cancelled.
| Outcome | HTTP status | Body |
|---|---|---|
| The order is cancelled | 200 | success: true |
| The order was already cancelled, or is not in a cancellable status — nothing changes | 200 | Same body |
idempotencyKey is not a GUID | 400 | Problem details |
| Invalid or expired bearer token | 401 | — |
No order matches {id}, or it belongs to another merchant | 404 | Problem details |
{id} on /cancel is not a GUID | 404 | Empty |
An idempotent request is still in progress, or the idempotencyKey was reused for a different order | 409 | Problem details — see Idempotency §3.4 |
| The cancel failed, for example because the authorization could not be released | 500 | success: false and responseMessage Failed to cancel order |
An internal error occurred. On /external-cancel, this is also returned when several of your orders share the external order ID | 500 | The text Failed to cancel order |
Idempotency store temporarily unavailable — honor Retry-After and retry | 503 | Problem details |
Within 24 hours, a repeat cancel for the same order replays the stored 200 response and does not run the cancel again. This also applies when the first cancel changed nothing. To run a cancel again within the 24 hours, send a new idempotencyKey. A cancel that returned 500 is not stored, so you can repeat it as it is. No webhook fires for a cancel that changed nothing. After a successful cancel, GET /v1/orders/{id} returns status cancelled, and order.cancelled fires when the order status changed and you subscribe to the event. The full transaction state model is in Workflows §3.5.
For the error key and the message of each 400 on /cancel and /external-cancel, see Error Messages: /cancel.
Updating the status orderAfter receiving a successful response from /cancel, you need to update this order in your CRM with the corresponding status.
Payload examples
Request
curl --request POST \
--url https://api-sandbox.flexfactor.io/v1/orders/{id}/cancel \
--header 'Authorization: Bearer {the token returned by /oauth2}' \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '
{}
'Response
HTTP/1.1 200 OK
Content-Type: application/json
{
"success": true,
"responseMessage": null
}Cancel by external order ID
external-cancel identifies the order by your own external order ID (the orderId you sent to /evaluate) instead of the FlexFactor order ID returned in the response. It is a routine cancel path you can use at any time an order is cancellable — and it is especially useful when the FlexFactor order ID was never received, for example when the /evaluate response timed out.
Request
Details
| HTTP Method | POST |
| Endpoint - Sandbox | https://api-sandbox.flexfactor.io/v1/orders/{external-order-id}/external-cancel |
| Endpoint - Production | https://api.flexfactor.io/v1/orders/{external-order-id}/external-cancel |
| {external-order-id} | Your own external order ID — the orderId you sent in the original /evaluate request. |
| Authentication | Bearer Token |
Body
This API doesn't require body parameters.
Response
Same as /cancel: HTTP 200 with the same body, including when nothing was cancelled — see Response above. If several of your orders share the external order ID, the call returns 500; cancel by the FlexFactor orderId instead.
Payload examples
Request
curl --request POST \
--url https://api-sandbox.flexfactor.io/v1/orders/{external-order-id}/external-cancel //insert the orderId you sent to /evaluate
--header 'Authorization: Bearer {the token returned by /oauth2}' \
--header 'accept: application/json'The request body is empty.
Response
HTTP/1.1 200 OK
Content-Type: application/json
{
"success": true,
"responseMessage": null
}Updated 2 days ago

