---
title: Cancel an order
slug: cancel-an-order
docTags: 
createdAt: 2026-04-17T07:48:39.600Z
---

{
  "id": "rb0166p6xkDCQpiEam3_c",
  "type": "api-oas-v2",
  "data": {
    "method": "POST",
    "url": "https://api.archbee.com/v2/orders/{orderId}/cancel",
    "servers": [
      {
        "url": "https://api.archbee.com/v2/orders/{orderId}/cancel",
        "description": "Production server"
      },
      {
        "url": "https://staging-api.archbee.com/v2/orders/{orderId}/cancel",
        "description": "Staging server"
      },
      {
        "url": "https://{region}.api.archbee.com/{version}/orders/{orderId}/cancel",
        "description": "Regional server with variables"
      }
    ],
    "name": "Cancel an order",
    "description": "Cancels a pending or confirmed order. Demonstrates nested objects in request body.",
    "contentType": "application/json",
    "request": {
      "pathParameters": [
        {
          "kind": "required",
          "name": "orderId",
          "type": "string<uuid>",
          "description": "",
          "format": "uuid"
        }
      ],
      "headerParameters": [],
      "queryParameters": [],
      "bodyDataParameters": [
        {
          "kind": "required",
          "name": "body",
          "type": "object",
          "description": "",
          "schema": [
            {
              "name": "reason",
              "kind": "required",
              "type": "string<changed_mind | found_cheaper | ordered_by_mistake | shipping_too_slow | other>",
              "description": "Cancellation reason",
              "example": "",
              "enum": [
                "changed_mind",
                "found_cheaper",
                "ordered_by_mistake",
                "shipping_too_slow",
                "other"
              ]
            },
            {
              "name": "details",
              "kind": "optional",
              "type": "string",
              "description": "Additional details about the cancellation",
              "example": "",
              "maxLength": 500
            },
            {
              "name": "refundPreference",
              "kind": "optional",
              "type": "object",
              "description": "Nested object for refund preferences",
              "example": "",
              "schema": [
                {
                  "name": "method",
                  "kind": "optional",
                  "type": "string<original_payment | store_credit | bank_transfer>",
                  "description": "",
                  "example": "",
                  "default": "original_payment",
                  "enum": [
                    "original_payment",
                    "store_credit",
                    "bank_transfer"
                  ]
                },
                {
                  "name": "bankDetails",
                  "kind": "optional",
                  "type": "object",
                  "description": "Required only when method is bank_transfer",
                  "example": "",
                  "schema": [
                    {
                      "name": "accountName",
                      "kind": "optional",
                      "type": "string",
                      "description": "",
                      "example": ""
                    },
                    {
                      "name": "iban",
                      "kind": "optional",
                      "type": "string",
                      "description": "",
                      "example": ""
                    },
                    {
                      "name": "bic",
                      "kind": "optional",
                      "type": "string",
                      "description": "",
                      "example": ""
                    }
                  ]
                }
              ]
            }
          ],
          "isExpanded": true
        }
      ],
      "formDataParameters": [],
      "oAuthParameters": [
        {
          "id": "bearerAuth",
          "name": "bearerAuth",
          "kind": "optional",
          "type": "http",
          "description": "<p>HTTP Bearer token authentication (JWT)</p>",
          "scheme": "bearer"
        }
      ]
    },
    "responses": [
      {
        "statusCode": "200",
        "description": "Order cancelled",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "",
            "customType": "Order",
            "schema": [
              {
                "name": "id",
                "kind": "optional",
                "type": "string<uuid>",
                "readOnly": true,
                "description": "",
                "example": "880e8400-e29b-41d4-a716-446655440003",
                "format": "uuid"
              },
              {
                "name": "status",
                "kind": "optional",
                "type": "string<pending | confirmed | shipped | delivered | cancelled | refunded>",
                "readOnly": true,
                "description": "",
                "example": "pending",
                "enum": [
                  "pending",
                  "confirmed",
                  "shipped",
                  "delivered",
                  "cancelled",
                  "refunded"
                ]
              },
              {
                "name": "items",
                "kind": "optional",
                "type": "array",
                "description": "",
                "example": "",
                "itemType": "object",
                "customType": "object[]",
                "itemExample": "",
                "itemDefault": ""
              },
              {
                "name": "subtotal",
                "kind": "optional",
                "type": "number<double>",
                "readOnly": true,
                "description": "",
                "example": 159.98,
                "format": "double"
              },
              {
                "name": "tax",
                "kind": "optional",
                "type": "number<double>",
                "readOnly": true,
                "description": "",
                "example": 12.8,
                "format": "double"
              },
              {
                "name": "total",
                "kind": "optional",
                "type": "number<double>",
                "readOnly": true,
                "description": "",
                "example": 172.78,
                "format": "double"
              },
              {
                "name": "shippingAddress",
                "kind": "optional",
                "type": "object",
                "description": "Full mailing address",
                "modelRef": "#/components/schemas/Address",
                "customType": "Address",
                "schema": [
                  {
                    "name": "street",
                    "kind": "required",
                    "type": "string",
                    "description": "",
                    "example": "123 Main St"
                  },
                  {
                    "name": "street2",
                    "kind": "optional",
                    "type": "string",
                    "description": "",
                    "example": "Apt 4B"
                  },
                  {
                    "name": "city",
                    "kind": "required",
                    "type": "string",
                    "description": "",
                    "example": "Springfield"
                  },
                  {
                    "name": "state",
                    "kind": "optional",
                    "type": "string",
                    "description": "",
                    "example": "IL"
                  },
                  {
                    "name": "zipCode",
                    "kind": "required",
                    "type": "string",
                    "description": "",
                    "example": "62701",
                    "pattern": "^\\d{5}(-\\d{4})?$"
                  },
                  {
                    "name": "country",
                    "kind": "required",
                    "type": "string",
                    "description": "ISO 3166-1 alpha-2 country code",
                    "example": "US",
                    "pattern": "^[A-Z]{2}$"
                  }
                ]
              },
              {
                "name": "metadata",
                "kind": "optional",
                "type": "map",
                "description": "",
                "example": "",
                "customType": "map<string, string>",
                "schema": []
              },
              {
                "name": "tracking",
                "kind": "optional",
                "type": "object",
                "readOnly": true,
                "description": "Nested tracking info (populated after shipping)",
                "example": "",
                "schema": [
                  {
                    "name": "carrier",
                    "kind": "optional",
                    "type": "string",
                    "description": "",
                    "example": "FedEx"
                  },
                  {
                    "name": "trackingNumber",
                    "kind": "optional",
                    "type": "string",
                    "description": "",
                    "example": 794644790132
                  },
                  {
                    "name": "estimatedDelivery",
                    "kind": "optional",
                    "type": "string<date>",
                    "description": "",
                    "example": "2025-07-15",
                    "format": "date"
                  },
                  {
                    "name": "events",
                    "kind": "optional",
                    "type": "array",
                    "description": "",
                    "example": "",
                    "itemType": "object",
                    "customType": "object[]",
                    "schema": [
                      {
                        "name": "timestamp",
                        "kind": "optional",
                        "type": "string<date-time>",
                        "description": "",
                        "example": "",
                        "format": "date-time"
                      },
                      {
                        "name": "location",
                        "kind": "optional",
                        "type": "string",
                        "description": "",
                        "example": ""
                      },
                      {
                        "name": "description",
                        "kind": "optional",
                        "type": "string",
                        "description": "",
                        "example": ""
                      }
                    ]
                  }
                ]
              },
              {
                "name": "createdAt",
                "kind": "optional",
                "type": "string<date-time>",
                "readOnly": true,
                "description": "",
                "example": "",
                "format": "date-time"
              },
              {
                "name": "updatedAt",
                "kind": "optional",
                "type": "string<date-time>",
                "readOnly": true,
                "description": "",
                "example": "",
                "format": "date-time"
              }
            ],
            "modelRef": "#/components/schemas/Order",
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "400",
        "description": "Order cannot be cancelled (already shipped/delivered)",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "Standard error response",
            "customType": "Error",
            "schema": [
              {
                "name": "code",
                "kind": "required",
                "type": "string",
                "description": "Machine-readable error code",
                "example": "VALIDATION_ERROR"
              },
              {
                "name": "message",
                "kind": "required",
                "type": "string",
                "description": "Human-readable error message",
                "example": "The request body contains invalid fields"
              },
              {
                "name": "details",
                "kind": "optional",
                "type": "array",
                "description": "Detailed validation errors (when applicable)",
                "example": "",
                "itemType": "object",
                "customType": "object[]",
                "schema": [
                  {
                    "name": "field",
                    "kind": "optional",
                    "type": "string",
                    "description": "",
                    "example": "email"
                  },
                  {
                    "name": "message",
                    "kind": "optional",
                    "type": "string",
                    "description": "",
                    "example": "must be a valid email address"
                  },
                  {
                    "name": "code",
                    "kind": "optional",
                    "type": "string",
                    "description": "",
                    "example": "INVALID_FORMAT"
                  }
                ]
              },
              {
                "name": "requestId",
                "kind": "optional",
                "type": "string<uuid>",
                "description": "Correlation ID for support inquiries",
                "example": "",
                "format": "uuid"
              }
            ],
            "modelRef": "#/components/schemas/Error",
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "404",
        "description": "Not found — the requested resource does not exist",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "example": "{\"code\":\"NOT_FOUND\",\"message\":\"The requested resource was not found\"}",
            "description": "Standard error response",
            "customType": "Error",
            "schema": [
              {
                "name": "code",
                "kind": "required",
                "type": "string",
                "description": "Machine-readable error code",
                "example": "VALIDATION_ERROR"
              },
              {
                "name": "message",
                "kind": "required",
                "type": "string",
                "description": "Human-readable error message",
                "example": "The request body contains invalid fields"
              },
              {
                "name": "details",
                "kind": "optional",
                "type": "array",
                "description": "Detailed validation errors (when applicable)",
                "example": "",
                "itemType": "object",
                "customType": "object[]",
                "schema": [
                  {
                    "name": "field",
                    "kind": "optional",
                    "type": "string",
                    "description": "",
                    "example": "email"
                  },
                  {
                    "name": "message",
                    "kind": "optional",
                    "type": "string",
                    "description": "",
                    "example": "must be a valid email address"
                  },
                  {
                    "name": "code",
                    "kind": "optional",
                    "type": "string",
                    "description": "",
                    "example": "INVALID_FORMAT"
                  }
                ]
              },
              {
                "name": "requestId",
                "kind": "optional",
                "type": "string<uuid>",
                "description": "Correlation ID for support inquiries",
                "example": "",
                "format": "uuid"
              }
            ],
            "modelRef": "#/components/schemas/Error",
            "isExpanded": true
          }
        ]
      }
    ],
    "hasXCodeSamples": false,
    "examples": {
      "languages": [
        {
          "id": "24rQ_uncCpZakZkj33HL6",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request POST \\\n     --url https://api.archbee.com/v2/orders/{orderId}/cancel \\\n     --header 'accept: application/json' \\\n     --header 'content-type: application/json' \\\n     --data '{\n     \"reason\": \"\",\n     \"refundPreference\": {\n     \"method\": \"original_payment\"\n     }\n     }'"
        },
        {
          "id": "A7Gr3XGMwX3SPoQK-eoHm",
          "language": "javascript",
          "label": "javascript",
          "code": "var myHeaders = new Headers();\nmyHeaders.append(\"accept\", \"application/json\");\nmyHeaders.append(\"content-type\", \"application/json\");\n\nvar raw = JSON.stringify({\n   \"reason\": \"\",\n   \"refundPreference\": {\n      \"method\": \"original_payment\"\n   }\n});\n\nvar requestOptions = {\n   method: 'POST',\n   headers: myHeaders,\n   body: raw,\n   redirect: 'follow'\n};\n\nfetch(\"https://api.archbee.com/v2/orders/{orderId}/cancel\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "xnA_vZT_0MZey_yjMMrYN",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://api.archbee.com/v2/orders/{orderId}/cancel\")\n\nhttps = Net::HTTP.new(url.host, url.port)\nhttps.use_ssl = true\n\nrequest = Net::HTTP::Post.new(url)\nrequest[\"accept\"] = \"application/json\"\nrequest[\"content-type\"] = \"application/json\"\nrequest.body = JSON.dump({\n   \"reason\": \"\",\n   \"refundPreference\": {\n      \"method\": \"original_payment\"\n   }\n})\n\nresponse = https.request(request)\nputs response.read_body\n"
        },
        {
          "id": "7XT-hpQq-Dd3BBmLtE0Rc",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://api.archbee.com/v2/orders/{orderId}/cancel\"\n\npayload = json.dumps({\n   \"reason\": \"\",\n   \"refundPreference\": {\n      \"method\": \"original_payment\"\n   }\n})\nheaders = {\n   'accept': 'application/json',\n   'content-type': 'application/json'\n}\n\nresponse = requests.request(\"POST\", url, headers=headers, data=payload)\n\nprint(response.text)\n"
        }
      ],
      "selectedLanguageId": "24rQ_uncCpZakZkj33HL6"
    },
    "results": {
      "languages": [
        {
          "id": "HnaS0oA8uP7JwjNRxDWYT",
          "language": "200",
          "code": "// Order cancelled\n{\n  \"id\": \"880e8400-e29b-41d4-a716-446655440003\",\n  \"status\": \"pending\",\n  \"items\": [\n    {}\n  ],\n  \"subtotal\": 159.98,\n  \"tax\": 12.8,\n  \"total\": 172.78,\n  \"shippingAddress\": {\n    \"street\": \"123 Main St\",\n    \"street2\": \"Apt 4B\",\n    \"city\": \"Springfield\",\n    \"state\": \"IL\",\n    \"zipCode\": \"62701\",\n    \"country\": \"US\"\n  },\n  \"metadata\": \"\",\n  \"tracking\": {\n    \"carrier\": \"FedEx\",\n    \"trackingNumber\": 794644790132,\n    \"estimatedDelivery\": \"2025-07-15\",\n    \"events\": [\n      {\n        \"timestamp\": \"\",\n        \"location\": \"\",\n        \"description\": \"\"\n      }\n    ]\n  },\n  \"createdAt\": \"\",\n  \"updatedAt\": \"\"\n}"
        },
        {
          "id": "T5H95nCQJ2HEsF5lawzHN",
          "language": "400",
          "code": "// Order cannot be cancelled (already shipped/delivered)\n{\n  \"code\": \"VALIDATION_ERROR\",\n  \"message\": \"The request body contains invalid fields\",\n  \"details\": [\n    {\n      \"field\": \"email\",\n      \"message\": \"must be a valid email address\",\n      \"code\": \"INVALID_FORMAT\"\n    }\n  ],\n  \"requestId\": \"\"\n}"
        },
        {
          "id": "41WTrZiaXEymJ07D4sr3D",
          "language": "404",
          "code": "// Not found — the requested resource does not exist\n{\n  \"code\": \"VALIDATION_ERROR\",\n  \"message\": \"The request body contains invalid fields\",\n  \"details\": [\n    {\n      \"field\": \"email\",\n      \"message\": \"must be a valid email address\",\n      \"code\": \"INVALID_FORMAT\"\n    }\n  ],\n  \"requestId\": \"\"\n}"
        }
      ],
      "selectedLanguageId": "HnaS0oA8uP7JwjNRxDWYT"
    }
  },
  "children": [
    {
      "text": ""
    }
  ]
}