/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.
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 may 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 the common FlexFactor envelope, the same shape that /void returns. 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 errors is empty. |
status | string | Not meaningful on this endpoint; null in current responses. Read success. |
result | string | Do not use it. |
responseCode | string | Processor response code when the cancel failed. null on success. Optional |
responseMessage | string | Processor response message when the cancel failed. null on success. Optional |
statusCode | string | It is not the HTTP status code. Do not use it. |
errors | array of objects | Error details for a failed cancel; empty on success. Each item is serialized positionally: item1 message, item2 key, item3 error code, item4 friendly flag (boolean). |
customProperties | object | Additional custom properties for the API request Optional |
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 | Envelope with success: true |
| The order was already cancelled, or is not in a cancellable status — nothing changes | 200 | Same body |
No order matches {id}, or it belongs to another merchant | 404 | Problem details |
An idempotent request is still in progress, or the idempotencyKey was reused with a different payload | 409 | Problem details — see Idempotency §3.4 |
| Invalid or expired bearer token | 401 | — |
| The cancel failed, or an internal error occurred | 500 | Envelope with success: false and responseMessage, for example 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. 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.
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 \ //insert the orderId returned by the response to /evaluate
--header 'Authorization: Bearer abc123def456' \ //replace with bearer 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,
"status": null,
"result": null,
"responseCode": null,
"responseMessage": null,
"statusCode": null,
"errors": [],
"customProperties": {}
}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 envelope, including when nothing was cancelled — see Response above.
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 abc123def456' \ //replace with bearer returned by /oauth2
--header 'accept: application/json'The request body is empty.
Response
HTTP/1.1 200 OK
Content-Type: application/json
{
"success": true,
"status": null,
"result": null,
"responseCode": null,
"responseMessage": null,
"statusCode": null,
"errors": [],
"customProperties": {}
}Updated 4 days ago

