Skip to main content

Cancel Order

Cancel an existing order. Only orders that haven't been delivered can be cancelled.

Endpoint

POST /v1/orders/{order_id}/cancel

Request

Path Parameters

ParameterTypeRequiredDescription
order_idstringYesThe order ID

Headers

Authorization: Bearer YOUR_ACCESS_TOKEN
Content-Type: application/json

Request Body (Optional)

FieldTypeRequiredDescription
reasonstringNoCancellation reason

Example Request

curl -X POST ${API_URL}/v1/orders/order_1a2b3c4d5e6f/cancel \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"reason": "Customer requested cancellation"
}'

PHP Example

<?php
$access_token = 'YOUR_ACCESS_TOKEN';
$order_id = 'order_1a2b3c4d5e6f';

$ch = curl_init("${API_URL}/v1/orders/{$order_id}/cancel");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
'reason' => 'Customer requested cancellation'
]));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $access_token,
'Content-Type: application/json',
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
$order = json_decode($response, true);

echo "Order cancelled: " . $order['status'];
?>

Response

Success Response (200 OK)

{
"id": "order_1a2b3c4d5e6f",
"tracking_number": "FUF123456789",
"status": "cancelled",
"cancellation": {
"reason": "Customer requested cancellation",
"cancelled_at": "2024-01-15T12:00:00Z"
},
"updated_at": "2024-01-15T12:00:00Z"
}

Error Response (400 Bad Request)

{
"error": {
"code": "cannot_cancel",
"message": "Cannot cancel order with status 'delivered'"
}
}

Error Response (404 Not Found)

{
"error": {
"code": "order_not_found",
"message": "Order not found"
}
}

Cancellation Rules

StatusCan Cancel?Notes
pending✅ YesFull refund
picked_up✅ YesMay incur cancellation fee
in_transit✅ YesMay incur cancellation fee
out_for_delivery⚠️ MaybeContact support
delivered❌ NoCannot cancel delivered orders
cancelled❌ NoAlready cancelled

Refunds

Cancellation refunds are processed based on the order status:

  • Pending: Full refund within 3-5 business days
  • Picked up: Partial refund (minus pickup fee)
  • In transit: Partial refund (minus handling fees)

Next Steps