Skip to Content
Bhakti BaazarDevelopers
API referenceOrders

Cancel an order or some of its lines

POST
/orders/{orderId}/cancel

Scope: orders:cancel

Cancels the lines in lineIds, or the whole order when it is left out, through the same cancellation as the portal: the customer is refunded and told, and a credit note is raised where an invoice exists.

Single lines can be cancelled until pickup is scheduled; the whole order until the courier collects it. Later answers 409 ORDER_NOT_CANCELLABLE. Lines already cancelled are skipped, so retries are safe: once nothing is left to do the order is returned unchanged.

Authorization

sellerApiKey
headerAuthorizationBearer <bbsk_live_…>

A Seller API key, bbsk_live_…

Path Parameters

orderId*string

The order id (not the order number)

Formatuuid

Request Body

application/json
  1. body
lineIds?array<>

The lines to cancel (lines[].id). Leave it out to cancel the whole order. Whole lines only: to send fewer units of a line, cancel the line. Naming every line still open cancels the whole order.

Itemsitems <= 100
reason*string

Why, for example "Out of stock". The customer sees it.

Lengthlength <= 255

Response Body

application/json
  1. response
id*string
Formatuuid
orderNumber*string|null
status*string
Value in"ordered""accepted""pickup_scheduled""shipped""cancelled""delivered""failed""completed"
paymentMethod*string
Value in"cod""prepaid"
codAmount*|

Cash on delivery: the amount your courier collects. Null for prepaid orders.

invoicePrepared*boolean

Whether the tax invoice exists. A COD order needs it before you add self-ship tracking; prepare it with POST /orders/{orderId}/invoice or in the seller portal.

lines*array<>
shipment*|null
invoice*|null

The tax invoice, once it exists. Download it with GET /orders/{orderId}/invoice.

returns*array<>

Returns raised on this order, oldest first. Empty when none.

rto*|null

Set when the courier turned the parcel around (return to origin). Restock once status is delivered or received.

customer*|null

The customer and delivery address. Only for keys with orders:read_pii, and only until 90 days after the order closes (cancelled, delivered, or its RTO parcel received); null otherwise. Never sent in webhooks.

placedAt*string

When the customer placed the order

Formatdate-time
dispatchDueAt*|

Dispatch is due by

Formatdate-time
cancelledAt*|
Formatdate-time
completedAt*|
Formatdate-time
updatedAt*string

Last change to the order, its lines or its shipment. Pass the newest one you have seen as updated_since.

Formatdate-time
Example Request
curl -X POST 'https://api.bhaktibaazar.com/seller-api/v1/orders/497f6eca-6276-4993-bfeb-53cbbbba6f08/cancel' \  -H 'Content-Type: application/json' \  -d '{  "reason": "Out of stock"}'
Example Response
{  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",  "orderNumber": "BB2611270042",  "status": "ordered",  "paymentMethod": "cod",  "codAmount": 0,  "invoicePrepared": true,  "lines": [    {      "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",      "productId": "dcd53ddb-8104-4e48-8cc0-5df1088c6113",      "variantId": "d53feca7-c65b-4741-aca7-827a42d686bf",      "sku": "string",      "sellerSku": "string",      "sellerProductCode": "string",      "name": "string",      "attributes": [        {          "name": "Bead size",          "value": {},          "unit": "mm"        }      ],      "quantity": 1,      "unitPrice": 0,      "mrp": 0,      "shippable": true,      "status": "pending",      "returnedQuantity": 0,      "hsnCode": "9603",      "gstRate": 5,      "tax": {        "taxableValue": 0,        "taxAmount": 0,        "total": 0,        "gstType": "igst",        "cgst": 0,        "sgst": 0,        "igst": 0      }    }  ],  "shipment": {    "fulfilment": "self_ship",    "courierCode": "string",    "courierName": "string",    "awbCode": "string",    "status": "created",    "trackingUrl": "string",    "dispatchedAt": "2019-08-24T14:15:22Z",    "pickedUpAt": "2019-08-24T14:15:22Z",    "estimatedDelivery": "string"  },  "invoice": {    "number": "BBSL-C-I-2612-000042",    "date": "2019-08-24T14:15:22Z"  },  "returns": [    {      "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",      "status": "requested",      "requestedAt": "2019-08-24T14:15:22Z"    }  ],  "rto": {    "status": "in_transit",    "initiatedAt": "2019-08-24T14:15:22Z",    "deliveredAt": "2019-08-24T14:15:22Z",    "receivedAt": "2019-08-24T14:15:22Z"  },  "customer": {    "name": "string",    "phone": "9876543210",    "email": "string",    "address": {      "line1": "string",      "landmark": "string",      "city": "string",      "state": "string",      "stateCode": "09",      "pincode": "282001"    }  },  "placedAt": "2019-08-24T14:15:22Z",  "dispatchDueAt": "2019-08-24T14:15:22Z",  "cancelledAt": "2019-08-24T14:15:22Z",  "completedAt": "2019-08-24T14:15:22Z",  "updatedAt": "2019-08-24T14:15:22Z"}