> For the complete documentation index, see [llms.txt](https://docs.payengine.co/payengine-api-v2.5/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.payengine.co/payengine-api-v2.5/transactions/cancel-device-sale.md).

# Cancel Device Sale

Cancel Device Sale API allows partners to cancel and in-process on device sale transaction.

<mark style="color:green;">`POST`</mark> `https://<Platform-host>/api/payment/cancel-device-sale`

#### Request Body

<table><thead><tr><th width="227.3740234375">Name</th><th width="149.517578125">Type</th><th>Description</th></tr></thead><tbody><tr><td>merchant_id<mark style="color:red;">*</mark></td><td>string</td><td>Merchant ID</td></tr><tr><td>data.device_id<mark style="color:red;">*</mark></td><td>string</td><td>Registered and connected device ID</td></tr></tbody></table>

{% tabs %}
{% tab title="200 " %}
{% tabs %}
{% tab title="Field Definitions" %}

<table><thead><tr><th width="248">Field Name</th><th width="90.1484375">Type</th><th width="279.0869140625">Description</th><th>Required?</th></tr></thead><tbody><tr><td>id</td><td>string</td><td>Platform payment ID for the sale request when available</td><td>Optional</td></tr><tr><td>transaction_id</td><td>string</td><td>Unique transaction ID when available</td><td>Optional</td></tr><tr><td>merchant_id</td><td>string</td><td>Merchant ID</td><td>Required</td></tr><tr><td>device_id</td><td>string</td><td>Device ID from the request</td><td>Required</td></tr><tr><td>gateway_id</td><td>string</td><td>ID of the gateway through which the transaction is processed</td><td>Optional</td></tr><tr><td>cancel_device_sale_response.status</td><td>string</td><td>Cancellation Status PASSED | FAILED</td><td>Required</td></tr><tr><td>cancel_device_sale_response.response_message</td><td>string</td><td>Cancellation Response Message</td><td>Required</td></tr></tbody></table>
{% endtab %}
{% endtabs %}
{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Request" %}

```json
{
    "merchant_id": "c03ce6ad-1e78-4bd7-ad35-e0d46b6b765d",
    "data": {        
        "device_id": "d9a63ebe-3036-4657-ba47-a4ad6e401b7c"
    }
}
```

{% endtab %}

{% tab title="Response" %}

```json
{
    "data": {
        "id": "d764f5a1-d269-43c8-bdeb-d3d469b2ada5",
        "transaction_id": "9732e3bd-008a-454e-b201-1d600ec95c3e",
        "merchant_id": "e6803b29-68a4-4c2a-b3ee-019dfad86c61",
        "device_id": "d9a63ebe-3036-4657-ba47-a4ad6e401b7c",
        "gateway_id": "1f3e0f67-d560-494c-bb1a-97558a462cc5",
        "cancel_device_sale_response": {
            "status": "PASS",
            "response_message": "Transaction cancellation requested. If the transaction cannot be cancelled, you must process a void/refund request once the transaction is complete."
        }
    }
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
Webhook event: **DEVICE\_SALE\_CANCEL**
{% endhint %}

#### Webhook Payload Example

```json
{
    "event_uid": "6452201be2d3597a92524b325e9b6282",
    "event": "DEVICE_SALE_CANCEL",
    "data": {
        "device_id": "08af6b55-03d9-4bdb-89cb-f895c22e1865",
        "account_id": "fdd24695-1298-496f-b997-89733fc17413",
        "gateway_id": "1f3e0f67-d560-494c-bb1a-97558a462cc5",
        "payment_id": "9e037738-5731-4019-a212-42a97594258e",
        "merchant_id": "94f712c7-17fa-41c6-9c0a-8560db4fd225",
        "transaction_id": "9c5b1cb2-19d5-4aae-a246-987c9115da50",
        "cancel_device_sale_response": {
            "status": "PASS",
            "response_message": "Transaction cancellation requested. If the transaction cannot be cancelled, you must process a void/refund request once the transaction is complete."
        }
    }
}
```
