Skip to main content
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>"
}
'
{
  "success": true,
  "message": "<string>",
  "orderId": "<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

ScenarioUse This
Customer changed their mindCancel Order
Order created in errorCancel Order
Items no longer availableCancel Order
Order already has subscriptionsCancel subscriptions instead

Request Fields

FieldRequiredDescription
reasonNoReason for cancellation (max 1000 chars)

Example Request

{
  "reason": "Customer requested cancellation - changed delivery address"
}

Response Fields

FieldDescription
successAlways true on success
messageConfirmation message
orderIdThe cancelled order ID

What Happens

When you cancel an order:
  1. Order status changes to cancelled
  2. Order items are released (no longer reserved)
  3. Cancellation logged with reason and timestamp
  4. 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 CodeCauseSolution
NOT_FOUNDOrder doesn’t existVerify order ID
ORDER_NOT_CANCELLABLEOrder has active subscriptionsCancel subscriptions first
ALREADY_CANCELLEDOrder already cancelledNo action needed

Authorizations

Authorization
string
header
required

API key obtained from FlexPortal dashboard

Headers

Tenant-ID
string
required

Your tenant identifier

Path Parameters

orderId
string
required

The order ID

Body

application/json
reason
string
Maximum string length: 1000

Response

Order cancelled

success
enum<boolean>
required
Available options:
true,
false
message
string
required
orderId
string
required