Cancel an order
curl --request POST \
--url https://api-eu.flexportal.io/v1/orders/{orderId}/cancel \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Tenant-ID: <tenant-id>' \
--data '
{
"reason": "<string>"
}
'import requests
url = "https://api-eu.flexportal.io/v1/orders/{orderId}/cancel"
payload = { "reason": "<string>" }
headers = {
"Tenant-ID": "<tenant-id>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'Tenant-ID': '<tenant-id>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({reason: '<string>'})
};
fetch('https://api-eu.flexportal.io/v1/orders/{orderId}/cancel', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-eu.flexportal.io/v1/orders/{orderId}/cancel",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'reason' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"Tenant-ID: <tenant-id>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api-eu.flexportal.io/v1/orders/{orderId}/cancel"
payload := strings.NewReader("{\n \"reason\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Tenant-ID", "<tenant-id>")
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api-eu.flexportal.io/v1/orders/{orderId}/cancel")
.header("Tenant-ID", "<tenant-id>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"reason\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-eu.flexportal.io/v1/orders/{orderId}/cancel")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Tenant-ID"] = '<tenant-id>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"reason\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"message": "<string>",
"orderId": "<string>"
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}Orders
Cancel Order
Cancels a pending order. Cannot cancel orders that have fulfilled subscriptions.
POST
/
v1
/
orders
/
{orderId}
/
cancel
Cancel an order
curl --request POST \
--url https://api-eu.flexportal.io/v1/orders/{orderId}/cancel \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Tenant-ID: <tenant-id>' \
--data '
{
"reason": "<string>"
}
'import requests
url = "https://api-eu.flexportal.io/v1/orders/{orderId}/cancel"
payload = { "reason": "<string>" }
headers = {
"Tenant-ID": "<tenant-id>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'Tenant-ID': '<tenant-id>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({reason: '<string>'})
};
fetch('https://api-eu.flexportal.io/v1/orders/{orderId}/cancel', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-eu.flexportal.io/v1/orders/{orderId}/cancel",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'reason' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"Tenant-ID: <tenant-id>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api-eu.flexportal.io/v1/orders/{orderId}/cancel"
payload := strings.NewReader("{\n \"reason\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Tenant-ID", "<tenant-id>")
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api-eu.flexportal.io/v1/orders/{orderId}/cancel")
.header("Tenant-ID", "<tenant-id>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"reason\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-eu.flexportal.io/v1/orders/{orderId}/cancel")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Tenant-ID"] = '<tenant-id>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"reason\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"message": "<string>",
"orderId": "<string>"
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}Overview
Cancel a pending order before it’s been fulfilled. Use this when a customer changes their mind, the order was created in error, or the items are no longer available.You cannot cancel orders that have active subscriptions. If subscriptions have already been created from this order, you must cancel the subscriptions individually.
When to Use Cancellation
| Scenario | Use This |
|---|---|
| Customer changed their mind | Cancel Order |
| Order created in error | Cancel Order |
| Items no longer available | Cancel Order |
| Order already has subscriptions | Cancel subscriptions instead |
Request Fields
| Field | Required | Description |
|---|---|---|
reason | No | Reason for cancellation (max 1000 chars) |
Example Request
{
"reason": "Customer requested cancellation - changed delivery address"
}
Response Fields
| Field | Description |
|---|---|
success | Always true on success |
message | Confirmation message |
orderId | The cancelled order ID |
What Happens
When you cancel an order:- Order status changes to
cancelled - Order items are released (no longer reserved)
- Cancellation logged with reason and timestamp
- No subscriptions can be created from this order
Example: Cancel with Reason
async function cancelOrder(orderId, reason) {
const result = await cancelOrder(orderId, { reason });
return {
cancelled: result.success,
orderId: result.orderId
};
}
Example: Check Before Cancelling
async function safeCancelOrder(orderId, reason) {
const order = await getOrder(orderId);
// Check if order has any fulfilled subscriptions
if (order.rentalProgress.rentedDevices > 0) {
throw new Error('Cannot cancel order with active subscriptions');
}
return await cancelOrder(orderId, { reason });
}
Error Handling
| Error Code | Cause | Solution |
|---|---|---|
NOT_FOUND | Order doesn’t exist | Verify order ID |
ORDER_NOT_CANCELLABLE | Order has active subscriptions | Cancel subscriptions first |
ALREADY_CANCELLED | Order already cancelled | No action needed |
Related Endpoints
- Get Order - Check order status before cancelling
- List Orders - Find orders to cancel
- Cancel Subscription - Cancel individual subscriptions
Authorizations
API key obtained from FlexPortal dashboard
Headers
Your tenant identifier
Path Parameters
The order ID
Body
application/json
Maximum string length:
1000Was this page helpful?