# Invoice cancel

##### Endpoint

<table border="1" id="bkmrk-endpoint-method-auth" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 33.3333%;"></col><col style="width: 33.3333%;"></col><col style="width: 33.3333%;"></col></colgroup><tbody><tr><td>**Endpoint**</td><td>**Method**  
</td><td>**Authentication**</td></tr><tr><td>/invoice/cancel</td><td>POST</td><td>yes</td></tr></tbody></table>

##### Authentication

<table border="1" id="bkmrk-endpoint-method-serv" style="border-collapse: collapse; width: 100%; height: 59.757px;"><colgroup><col style="width: 39.3078%;"></col><col style="width: 60.6922%;"></col></colgroup><tbody><tr style="height: 29.8785px;"><td style="height: 29.8785px;">**Type**  
</td><td style="height: 29.8785px;">**Auth type**  
</td></tr><tr style="height: 29.8785px;"><td style="height: 29.8785px;">Basic</td><td style="height: 29.8785px;">Login and password same as USAPI Login</td></tr></tbody></table>

##### Body request

```json
{
  "platform": "ONMARKET",
  "invoice_id": "OM0003d0CS00009",
  "invoice_onmarket": "INV/ONM/20240124-002B0001",
  "buyer_username": "usernew1"
}
```

<table border="1" id="bkmrk-properties-propertie" style="border-collapse: collapse; width: 100%; height: 142.422px;"><colgroup><col style="width: 18.7886%;"></col><col style="width: 18.7886%;"></col><col style="width: 11.1248%;"></col><col style="width: 9.88875%;"></col><col style="width: 41.4091%;"></col></colgroup><tbody><tr style="height: 29.7969px;"><td style="height: 29.7969px;">**Properties**  
</td><td style="height: 29.7969px;">**Properties of**</td><td style="height: 29.7969px;">**Data type**</td><td style="height: 29.7969px;">**Required**</td><td style="height: 29.7969px;">**Description**</td></tr><tr><td>platform</td><td>  
</td><td>string</td><td>yes</td><td>ONINDONESIA services.  
Possible values:

- ONDELIVERY means the source of the transaction comes from ondelivery.
- ONTICKET means the source of the transaction comes from onticket.
- ONMARKET means the source of the transaction comes from onmarket.

</td></tr><tr style="height: 29.7969px;"><td style="height: 29.7969px;">invoice\_id</td><td style="height: 29.7969px;">  
</td><td style="height: 29.7969px;">string</td><td style="height: 29.7969px;">yes</td><td style="height: 29.7969px;">invoice ID generated by USAPI</td></tr><tr><td>invoice\_onmarket</td><td>  
</td><td>string</td><td>no<sup>1</sup></td><td>Invoice ID generated by ONMARKET

<sup>1</sup>if status of the invoice is PAID, it will be refunded to buyer's balance from each store. So invoice\_onmarket is required.

</td></tr><tr style="height: 82.8281px;"><td style="height: 82.8281px;"><div><div>buyer_username</div></div></td><td style="height: 82.8281px;">  
</td><td style="height: 82.8281px;">string</td><td style="height: 82.8281px;">no<sup>1</sup></td><td style="height: 82.8281px;">Username from buyer

<sup>1</sup>if status of the invoice is PAID, it will be refunded to buyer's balance. So buyer's username is required.

</td></tr></tbody></table>

<details id="bkmrk-result-example-body-"><summary>Result example</summary>

<p class="callout info">200 OK (Invoice status is PAID)</p>

```json
{
  "message": "REFUND IN PROCESS"
}
```

<p class="callout info">200 OK (Invoice status is PENDING)</p>

```json
{
  "message": "INVOICE CANCELED"
}
```

</details><details id="bkmrk-error-example-body-r"><summary>Error example</summary>

<p class="callout danger">400 Bad request</p>

```json
{
    "message": "REFUND ALREADY IN PROCESS"
}
```

```json
{
    "message": "TRANSACTION IS ALREADY CANCELED"
}
```

```json
{
    "message": "EXPIRED INVOICE"
}
```

<p class="callout danger">500 Internal server error</p>

```json
{
    "message": "INTERNAL SERVER ERROR"
}
```

</details>