Cancel an order
curl --request POST \
--url https://staging.api.commercengine.io/api/v1/{store_id}/admin/orders/{order_number}/cancel \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"cancellation_reason": "<string>",
"bank_account_id": "<string>"
}
'import requests
url = "https://staging.api.commercengine.io/api/v1/{store_id}/admin/orders/{order_number}/cancel"
payload = {
"cancellation_reason": "<string>",
"bank_account_id": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({cancellation_reason: '<string>', bank_account_id: '<string>'})
};
fetch('https://staging.api.commercengine.io/api/v1/{store_id}/admin/orders/{order_number}/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://staging.api.commercengine.io/api/v1/{store_id}/admin/orders/{order_number}/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([
'cancellation_reason' => '<string>',
'bank_account_id' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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://staging.api.commercengine.io/api/v1/{store_id}/admin/orders/{order_number}/cancel"
payload := strings.NewReader("{\n \"cancellation_reason\": \"<string>\",\n \"bank_account_id\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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://staging.api.commercengine.io/api/v1/{store_id}/admin/orders/{order_number}/cancel")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"cancellation_reason\": \"<string>\",\n \"bank_account_id\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://staging.api.commercengine.io/api/v1/{store_id}/admin/orders/{order_number}/cancel")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"cancellation_reason\": \"<string>\",\n \"bank_account_id\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"message": "<string>",
"success": true,
"content": {
"order": {
"order_number": "<string>",
"order_date": "2023-11-07T05:31:56Z",
"status": "draft",
"payment_status": "pending",
"marketplace_synced": true,
"payment_success_date": "<string>",
"customer_id": "<string>",
"customer_email": "<string>",
"customer_phone": "<string>",
"customer_note": "<string>",
"is_promotion_applied": true,
"promotion_discount_amount": 123,
"is_coupon_applied": true,
"coupon_code": "<string>",
"coupon_discount_amount": 123,
"on_subscription": true,
"fulfillment_preference": {
"fulfillment_type": "collect-in-store",
"pickup_location_id": "<string>",
"preference_type": "user",
"pickup_location_name": "<string>"
},
"sales_channel": {
"id": "<string>",
"name": "<string>",
"type": "<string>"
},
"metadata": {},
"subtotal": 123,
"subtotal_tax": 123,
"subtotal_including_tax": 123,
"shipping_amount": 123,
"shipping_tax_rate": 123,
"shipping_total_tax": 123,
"shipping_amount_including_tax": 123,
"total_tax": 123,
"grand_total": 123,
"loyalty_point_redeemed": 123,
"credit_balance_used": 123,
"to_be_paid": 123,
"loyalty_point_earned": 123,
"order_items_count": 123,
"order_items": [
{
"sku": "<string>",
"quantity": 123,
"product_id": "<string>",
"product_name": "<string>",
"product_image_url": "<string>",
"on_offer": true,
"on_promotion": true,
"on_subscription": true,
"subscription_plan": "<string>",
"subscription_interval": 123,
"subscription_frequency": "<string>",
"free_quantity": 123,
"is_free_item": true,
"selling_price": 123,
"listing_price": 123,
"promotion_discount_amount": 123,
"coupon_discount_amount": 123,
"tax_type": "GST",
"tax_rate": 123,
"tax_amount": 123,
"handling_charge_excluding_tax": 123,
"handling_charge_including_tax": 123,
"handling_charge_tax_rate": 123,
"variant_id": "<string>",
"variant_name": "<string>",
"seller_id": "<string>",
"seller_detail": {
"id": "<string>",
"trade_name": "<string>",
"legal_name": "<string>",
"business_type": "sole_proprietorship",
"tax_identification_number": "<string>"
}
}
],
"billing_address": {
"first_name": "<string>",
"phone": "<string>",
"email": "<string>",
"address_line1": "<string>",
"pincode": "<string>",
"city": "<string>",
"state": "<string>",
"country": "India",
"id": "<string>",
"last_name": "<string>",
"country_code": "<string>",
"address_line2": "<string>",
"landmark": "<string>",
"gstin": "<string>",
"business_name": "<string>",
"is_phone_verified": true,
"is_email_verified": true,
"is_default_shipping": true,
"is_default_billing": true
},
"shipping_address": {
"first_name": "<string>",
"phone": "<string>",
"email": "<string>",
"address_line1": "<string>",
"pincode": "<string>",
"city": "<string>",
"state": "<string>",
"country": "India",
"id": "<string>",
"last_name": "<string>",
"country_code": "<string>",
"address_line2": "<string>",
"landmark": "<string>",
"gstin": "<string>",
"business_name": "<string>",
"is_phone_verified": true,
"is_email_verified": true,
"is_default_shipping": true,
"is_default_billing": true
},
"currency": {
"name": "<string>",
"code": "<string>",
"symbol": "<string>"
},
"feedback": "<string>",
"allowed_actions": [
"create-shipment"
],
"applied_coupons": [
{
"coupon_id": "<string>",
"coupon_type": "discount",
"savings": 123,
"product_id": "<string>",
"variant_id": "<string>",
"product_name": "<string>",
"variant_name": "<string>"
}
],
"applied_promotions": [
{
"promotion_id": "<string>",
"promotion_type": "discount",
"savings": 123,
"product_id": "<string>",
"variant_id": "<string>",
"product_name": "<string>",
"variant_name": "<string>",
"applied_sequence": 123,
"scope": "<string>"
}
],
"payments": [
{
"transaction_type": "payment",
"request_number": "<string>",
"amount": 123,
"payment_status": "pending",
"payment_date": "2023-11-07T05:31:56Z",
"payment_reference_number": "<string>",
"payment_method": "Card",
"payment_mode": "<string>",
"icon_url": "<string>",
"card_number": "<string>",
"card_type": "Visa"
}
],
"shipments": [
{
"reference_number": "<string>",
"status": "unscheduled",
"total_weight": 123,
"total_boxes": 123,
"shipment_items_count": 123,
"shipment_items": [
{
"product_id": "<string>",
"variant_id": "<string>",
"quantity": 123,
"product_name": "<string>",
"variant_name": "<string>",
"product_image_url": "<string>",
"sku": "<string>",
"free_quantity": 123,
"is_free_item": true,
"selling_price": 123
}
],
"shipping_amount": 123,
"shipping_tax_amount": 123,
"shipping_amount_including_tax": 123,
"courier_company_id": "<string>",
"courier_company_name": "<string>",
"shipping_label_url": "<string>",
"awb_no": "<string>",
"eta_delivery": "2023-11-07T05:31:56Z",
"shipped_date": "2023-11-07T05:31:56Z",
"delivered_date": "2023-11-07T05:31:56Z",
"cancellation_reason": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"modified_at": "2023-11-07T05:31:56Z"
}
],
"created_at": "2023-11-07T05:31:56Z",
"modified_at": "2023-11-07T05:31:56Z"
}
}
}Orders
Cancel an order
Cancels an order and initiates a refund for any captured payment. Returns the updated OrderDetail object.
POST
/
orders
/
{order_number}
/
cancel
Cancel an order
curl --request POST \
--url https://staging.api.commercengine.io/api/v1/{store_id}/admin/orders/{order_number}/cancel \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"cancellation_reason": "<string>",
"bank_account_id": "<string>"
}
'import requests
url = "https://staging.api.commercengine.io/api/v1/{store_id}/admin/orders/{order_number}/cancel"
payload = {
"cancellation_reason": "<string>",
"bank_account_id": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({cancellation_reason: '<string>', bank_account_id: '<string>'})
};
fetch('https://staging.api.commercengine.io/api/v1/{store_id}/admin/orders/{order_number}/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://staging.api.commercengine.io/api/v1/{store_id}/admin/orders/{order_number}/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([
'cancellation_reason' => '<string>',
'bank_account_id' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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://staging.api.commercengine.io/api/v1/{store_id}/admin/orders/{order_number}/cancel"
payload := strings.NewReader("{\n \"cancellation_reason\": \"<string>\",\n \"bank_account_id\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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://staging.api.commercengine.io/api/v1/{store_id}/admin/orders/{order_number}/cancel")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"cancellation_reason\": \"<string>\",\n \"bank_account_id\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://staging.api.commercengine.io/api/v1/{store_id}/admin/orders/{order_number}/cancel")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"cancellation_reason\": \"<string>\",\n \"bank_account_id\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"message": "<string>",
"success": true,
"content": {
"order": {
"order_number": "<string>",
"order_date": "2023-11-07T05:31:56Z",
"status": "draft",
"payment_status": "pending",
"marketplace_synced": true,
"payment_success_date": "<string>",
"customer_id": "<string>",
"customer_email": "<string>",
"customer_phone": "<string>",
"customer_note": "<string>",
"is_promotion_applied": true,
"promotion_discount_amount": 123,
"is_coupon_applied": true,
"coupon_code": "<string>",
"coupon_discount_amount": 123,
"on_subscription": true,
"fulfillment_preference": {
"fulfillment_type": "collect-in-store",
"pickup_location_id": "<string>",
"preference_type": "user",
"pickup_location_name": "<string>"
},
"sales_channel": {
"id": "<string>",
"name": "<string>",
"type": "<string>"
},
"metadata": {},
"subtotal": 123,
"subtotal_tax": 123,
"subtotal_including_tax": 123,
"shipping_amount": 123,
"shipping_tax_rate": 123,
"shipping_total_tax": 123,
"shipping_amount_including_tax": 123,
"total_tax": 123,
"grand_total": 123,
"loyalty_point_redeemed": 123,
"credit_balance_used": 123,
"to_be_paid": 123,
"loyalty_point_earned": 123,
"order_items_count": 123,
"order_items": [
{
"sku": "<string>",
"quantity": 123,
"product_id": "<string>",
"product_name": "<string>",
"product_image_url": "<string>",
"on_offer": true,
"on_promotion": true,
"on_subscription": true,
"subscription_plan": "<string>",
"subscription_interval": 123,
"subscription_frequency": "<string>",
"free_quantity": 123,
"is_free_item": true,
"selling_price": 123,
"listing_price": 123,
"promotion_discount_amount": 123,
"coupon_discount_amount": 123,
"tax_type": "GST",
"tax_rate": 123,
"tax_amount": 123,
"handling_charge_excluding_tax": 123,
"handling_charge_including_tax": 123,
"handling_charge_tax_rate": 123,
"variant_id": "<string>",
"variant_name": "<string>",
"seller_id": "<string>",
"seller_detail": {
"id": "<string>",
"trade_name": "<string>",
"legal_name": "<string>",
"business_type": "sole_proprietorship",
"tax_identification_number": "<string>"
}
}
],
"billing_address": {
"first_name": "<string>",
"phone": "<string>",
"email": "<string>",
"address_line1": "<string>",
"pincode": "<string>",
"city": "<string>",
"state": "<string>",
"country": "India",
"id": "<string>",
"last_name": "<string>",
"country_code": "<string>",
"address_line2": "<string>",
"landmark": "<string>",
"gstin": "<string>",
"business_name": "<string>",
"is_phone_verified": true,
"is_email_verified": true,
"is_default_shipping": true,
"is_default_billing": true
},
"shipping_address": {
"first_name": "<string>",
"phone": "<string>",
"email": "<string>",
"address_line1": "<string>",
"pincode": "<string>",
"city": "<string>",
"state": "<string>",
"country": "India",
"id": "<string>",
"last_name": "<string>",
"country_code": "<string>",
"address_line2": "<string>",
"landmark": "<string>",
"gstin": "<string>",
"business_name": "<string>",
"is_phone_verified": true,
"is_email_verified": true,
"is_default_shipping": true,
"is_default_billing": true
},
"currency": {
"name": "<string>",
"code": "<string>",
"symbol": "<string>"
},
"feedback": "<string>",
"allowed_actions": [
"create-shipment"
],
"applied_coupons": [
{
"coupon_id": "<string>",
"coupon_type": "discount",
"savings": 123,
"product_id": "<string>",
"variant_id": "<string>",
"product_name": "<string>",
"variant_name": "<string>"
}
],
"applied_promotions": [
{
"promotion_id": "<string>",
"promotion_type": "discount",
"savings": 123,
"product_id": "<string>",
"variant_id": "<string>",
"product_name": "<string>",
"variant_name": "<string>",
"applied_sequence": 123,
"scope": "<string>"
}
],
"payments": [
{
"transaction_type": "payment",
"request_number": "<string>",
"amount": 123,
"payment_status": "pending",
"payment_date": "2023-11-07T05:31:56Z",
"payment_reference_number": "<string>",
"payment_method": "Card",
"payment_mode": "<string>",
"icon_url": "<string>",
"card_number": "<string>",
"card_type": "Visa"
}
],
"shipments": [
{
"reference_number": "<string>",
"status": "unscheduled",
"total_weight": 123,
"total_boxes": 123,
"shipment_items_count": 123,
"shipment_items": [
{
"product_id": "<string>",
"variant_id": "<string>",
"quantity": 123,
"product_name": "<string>",
"variant_name": "<string>",
"product_image_url": "<string>",
"sku": "<string>",
"free_quantity": 123,
"is_free_item": true,
"selling_price": 123
}
],
"shipping_amount": 123,
"shipping_tax_amount": 123,
"shipping_amount_including_tax": 123,
"courier_company_id": "<string>",
"courier_company_name": "<string>",
"shipping_label_url": "<string>",
"awb_no": "<string>",
"eta_delivery": "2023-11-07T05:31:56Z",
"shipped_date": "2023-11-07T05:31:56Z",
"delivered_date": "2023-11-07T05:31:56Z",
"cancellation_reason": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"modified_at": "2023-11-07T05:31:56Z"
}
],
"created_at": "2023-11-07T05:31:56Z",
"modified_at": "2023-11-07T05:31:56Z"
}
}
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
order number
Body
application/json
The reason for cancelling the order. Recorded on the order for reporting and customer communication.
How the refund is issued. Use original-payment-mode to refund back to the customer's original payment instrument, or bank-transfer to refund to a saved customer bank account.
Available options:
original-payment-mode, bank-transfer The customer bank account to credit. Required when refund_mode is bank-transfer; omit or set to null for original-payment-mode.
Was this page helpful?
⌘I