> For the complete documentation index, see [llms.txt](https://docs.barte.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.barte.com/guias/passo-a-passo-do-vendedor/3o-pos-pagamento/estorno-parcial-de-um-pedido.md).

# Estorno de um Pedido

Este endpoint permite realizar o **estorno total ou parcial de uma cobrança (`charge`)** já processada.\
O estorno é sempre feito **no nível da cobrança**, e não diretamente no pedido (`order`).

📌 Um pedido pode possuir **uma ou mais cobranças**, portanto o estorno deve ser executado **para cada charge elegível**.

***

### Endpoint

**PATCH** `/v2/charges/partial-refund/{uuid}`\
`https://api.barte.com/v2/charges/partial-refund/{uuid}`

***

### Headers

```
X-Token-Api: YOUR_API_KEY
Content-Type: application/json
Accept: */*
```

***

### Path Param

#### `uuid` (obrigatório)

Identificador único da cobrança (`charge.uuid`).

📌 Esse `uuid` é obtido:

* Na criação do pedido
* Na consulta do pedido (`GET /v2/orders/{uuid}`)
* Via webhook de atualização de status

***

### Body

```json
{
  "value": 100
}
```

#### `value`&#x20;

Indica o valor que deverá ser estornado da cobrança.

<sub>📌 Também é possível passar o valor total da cobrança, realizando assim um estorno total.</sub>

***

### Exemplo de resposta

```json
[{
  "uuid": "",
  "originalValue": 100,
  "value": 0,
  "refundValue": 100,
  "refundStatus": "processing"
}]
```

***

### Campos mais importantes da resposta

* `uuid` - Identificador único da cobrança estornada. Use para:
  * Auditoria
  * Suporte
  * Conciliação financeira
* `value` - Valor atual da cobrança após a solicitação de estorno
* `originalValue` - Valor original da cobrança
* `refundValue` - Valor da solicitação de estorno
* `refundStatus` - Status em que se encontra a solicitação de estorno

***

### <i class="fa-rotate">:rotate:</i> Fluxo recomendado de estorno

```
Consultar pedido
      ↓
Identificar charge elegível
      ↓
Executar PATCH /partial-refund
      ↓
Validar retorno
      ↓
Atualizar estado final
```

***

### <i class="fa-lightbulb">:lightbulb:</i> Boas práticas

* Sempre valide:
  * `value`
  * `originalValue`
* Armazene:
  * `uuid` da charge
  * Status anterior e posterior

***

### <i class="fa-hexagon-xmark">:hexagon-xmark:</i> O que não fazer

* Tentar estornar novamente quando `value = 0`
* Estornar pedido sem identificar a cobrança correta
* Implementar loop automático de retry sem validação


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.barte.com/guias/passo-a-passo-do-vendedor/3o-pos-pagamento/estorno-parcial-de-um-pedido.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
