# Cancellations

{% hint style="success" %}
Utilizamos a especificação Open Delivery para o tratamento de pedidos.\
<https://abrasel-nacional.github.io/docs/#tag/ordersCancellation>
{% endhint %}

## Solicita o cancelamento de um pedido

<mark style="color:green;">`POST`</mark> `https://{account}.myhubdelivery.io/orders/api/v1/{orderId}/requestCancellation`

#### Path Parameters

| Name                                      | Type   | Description             |
| ----------------------------------------- | ------ | ----------------------- |
| orderId<mark style="color:red;">\*</mark> | String | Identificador do pedido |

#### Headers

| Name                                            | Type   | Description |
| ----------------------------------------------- | ------ | ----------- |
| Authorization<mark style="color:red;">\*</mark> | String | Bearer ...  |

#### Request Body

| Name                                     | Type           | Description                                                                                                                                                                                                                                                         |
| ---------------------------------------- | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| reason<mark style="color:red;">\*</mark> | String         | Razão do cancelamento                                                                                                                                                                                                                                               |
| code<mark style="color:red;">\*</mark>   | String         | "SYSTEMIC\_ISSUES" "DUPLICATE\_APPLICATION" "UNAVAILABLE\_ITEM" "RESTAURANT\_WITHOUT\_DELIVERY\_MAN" "OUTDATED\_MENU" "ORDER\_OUTSIDE\_THE\_DELIVERY\_AREA" "BLOCKED\_CUSTOMER" "OUTSIDE\_DELIVERY\_HOURS" "INTERNAL\_DIFFICULTIES\_OF THE RESTAURANT" "RISK\_AREA" |
| mode                                     | String         | "AUTO" "MANUAL"                                                                                                                                                                                                                                                     |
| outOfStockItems                          | Array\<String> |                                                                                                                                                                                                                                                                     |
| invalidItems                             | Array\<String> |                                                                                                                                                                                                                                                                     |

{% tabs %}
{% tab title="201: Created " %}

```javascript
{
    // Response
}
```

{% endtab %}

{% tab title="400: Bad Request " %}

```javascript
{
    // Response
}
```

{% endtab %}

{% tab title="401: Unauthorized " %}

```javascript
{
    // Response
}
```

{% endtab %}
{% endtabs %}

{% hint style="success" %}
**Exemplo do conteúdo da requisição**
{% endhint %}

```json
{
  "reason": "",
  "code": "",
  "mode": "AUTO|MANUAL",
  "outOfStockItems": [
    ""
  ],
  "invalidItems": [
    ""
  ]
}
```

## Aceita a solicitação de cancelamento enviada pelo canal de vendas

<mark style="color:green;">`POST`</mark> `https://{account}.myhubdelivery.io/orders/api/v1/{orderId}/acceptCancellation`

## Rejeita a solicitação de cancelamento enviada pelo canal de vendas

<mark style="color:green;">`POST`</mark> `https://{account}.myhubdelivery.io/orders/api/v1/{orderId}/denyCancellation`

{% hint style="success" %}
**Exemplo do conteúdo da requisição**
{% endhint %}

```json
{
  "reason": "",
  "code": ""
}
```

## Força o cancelamento do pedido pelo canal

<mark style="color:purple;">`PATCH`</mark> `https://{account}.myhubdelivery.io/orders/api/v1/{orderId}/cancellation/force`

Esta operação só é permitida em sandbox, não existindo em produção

#### Path Parameters

| Name                                      | Type | Description             |
| ----------------------------------------- | ---- | ----------------------- |
| orderId<mark style="color:red;">\*</mark> | UUID | Identificação do pedido |

{% tabs %}
{% tab title="200: OK " %}

{% endtab %}
{% endtabs %}
