> For the complete documentation index, see [llms.txt](https://drophub.gitbook.io/drophub-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://drophub.gitbook.io/drophub-docs/cancel-order.md).

# 📦 Cancel Order

Use this endpoint to cancel an existing order using your `integrationOrderId`.\
Cancellation is only allowed if the order is still in a cancelable status (`PENDING`, `ACCEPTED`).

***

#### 🔗 Endpoint

**POST** `/custom-integration/orders/{integrationOrderId}/cancel`\
Example:

```
https://api.drop-hub.com/api/custom-integration/orders/ORD-20250721-0004/cancel
```

***

#### ✅ Success Response (200)

```json
{
  "statusCode": 200,
  "status": "success",
  "message": "The operation has been successful",
  "data":"",
  "timestamp": 1756039448302
}
```

***

#### ❌ Error Responses

**1. Order Not Found**

```json
{
  "statusCode": 404,
  "status": "error",
  "message": "Order not found",
  "timestamp": 1756039763043,
  "errorKey": "OR-1000"
}
```

**2. Order Cannot Be Cancelled**

```json
{
  "statusCode": 400,
  "status": "error",
  "message": "You cannot cancel the order",
  "timestamp": 1756039894649,
  "errorKey": "OR-1001"
}
```

***

#### 🔒 Authentication

Include your API key in the request headers:

```http
x-api-key: your_api_key_here
```

***

#### 🚦 Cancellation Rules

| Current Order Status | Cancellation Allowed |
| -------------------- | -------------------- |
| `PENDING`            | ✅ Yes                |
| `ACCEPTED`           | ✅ Yes                |
| `REJECTED`           | ❌ No                 |
| `PICKED_UP`          | ❌ No                 |
| `DELIVERED`          | ❌ No                 |
| `CANCELLED`          | ❌ No                 |

***

#### 📘 Notes

* Once cancelled, the order status will be permanently updated to `CANCELLED`.
