# Submit a Cancel Order Request

Cancel an in-flight order.

```nolang
POST /v2/cpq/carts/{order_ID}/cancel
```

For CME Winter '20 and later releases, the **Cancel** button is used to cancel an in-flight order.

For releases prior to CME Winter '20, the **Cancel Order** button is used to invoke the submitCancelOrder API, create a supplemental order, and submit the order to Order Management.

The submitCancelOrder API uses the Supplemental Order interface implementations that predate the CME Winter '20 release, including SupplementalOrderService and XOMSupplementalOrderLifeCycle. See [In-Flight Order Cancellation](https://help.salesforce.com/s/articleView?id=ind.comms_in_flight_order_cancellation.htm).

This API supports the guest user enhancements that Salesforce introduced with the Winter ‘21 release. To encrypt and decrypt data for guest users, use the `UserSecurity` class with this API. See Guest User Technical Details.

For additional information, ​see UserSecurity Class and CPQ and Digital Commerce Changes for Guest Users.

## Apex Method

Use this method with the supplemental order's ID as input (supplementalOrdId) to submit a cancel order request.

```nolang
public static void submitSupplementalOrder(Id originalOrdId, Id supplementalOrdId)
{
    final String methodName = 'submitCancelOrder';
    Map<String, Object> inputMap = new Map<String, Object>
    {
        'cartId' => originalOrdId,
        'methodName' => methodName,
        'cancelOrderId' => supplementalOrdId
    };
    Map<String, Object> outputMap = new Map<String, Object>();
    Map<String, Object> optionsMap = new Map<String, Object>();
    vlocity_cmt.CpqAppHandler handler = new vlocity_cmt.CpqAppHandler();
    handler.invokeMethod(methodName, inputMap, outputMap, optionsMap);

    // traverse the result that was returned, to find the supplemental order id.
    vlocity_cmt.JSONResult result = (vlocity_cmt.JSONResult) outputMap.get('result');
}
```

## Package

Communication (vlocity_cmt)

## API Parameters and Response Format

For API parameter names and descriptions, see [Cart-Based API Swagger Reference](https://developer.salesforce.com/docs/industries/cme/references/cpq?meta=Summary).

## Resource Information

| Response Format | JSON                                                            |
| --------------- | --------------------------------------------------------------- |
| Resource URL    | `/services/apexrest/{namespace}/v2/cpq/carts/{order_ID}/cancel` |

## Example Request

```nolang
POST
/services/apexrest/v2/cpq/carts/{order_ID}/cancel
```

## Example Request Body

```nolang
{
  "cartId": "order_ID",
  "subaction": "submitCancelOrder",
  "cancelOrderId": "supplemental_order_ID"
}
```

**See Also**

- [Cancel Order](/docs/industries/cme/guide/comms-cancel-order.md)
- [Create Supplemental Order](/docs/industries/cme/guide/comms-create-supplemental-order.md)
- [In-Flight Order Cancellation](https://help.salesforce.com/s/articleView?id=ind.comms_in_flight_order_cancellation.htm)
