Cancelar Cobrança
curl --request DELETE \
--url https://garu.com.br/api/v1/charges/{uuid} \
--header 'Authorization: <authorization>'import requests
url = "https://garu.com.br/api/v1/charges/{uuid}"
headers = {"Authorization": "<authorization>"}
response = requests.delete(url, headers=headers)
print(response.text)const options = {method: 'DELETE', headers: {Authorization: '<authorization>'}};
fetch('https://garu.com.br/api/v1/charges/{uuid}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://garu.com.br/api/v1/charges/{uuid}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://garu.com.br/api/v1/charges/{uuid}"
req, _ := http.NewRequest("DELETE", url, nil)
req.Header.Add("Authorization", "<authorization>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.delete("https://garu.com.br/api/v1/charges/{uuid}")
.header("Authorization", "<authorization>")
.asString();require 'uri'
require 'net/http'
url = URI("https://garu.com.br/api/v1/charges/{uuid}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["Authorization"] = '<authorization>'
response = http.request(request)
puts response.read_bodyCobranças
Cancelar Cobrança
Cancele uma cobrança que ainda não foi paga
DELETE
/
api
/
v1
/
charges
/
{uuid}
Cancelar Cobrança
curl --request DELETE \
--url https://garu.com.br/api/v1/charges/{uuid} \
--header 'Authorization: <authorization>'import requests
url = "https://garu.com.br/api/v1/charges/{uuid}"
headers = {"Authorization": "<authorization>"}
response = requests.delete(url, headers=headers)
print(response.text)const options = {method: 'DELETE', headers: {Authorization: '<authorization>'}};
fetch('https://garu.com.br/api/v1/charges/{uuid}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://garu.com.br/api/v1/charges/{uuid}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://garu.com.br/api/v1/charges/{uuid}"
req, _ := http.NewRequest("DELETE", url, nil)
req.Header.Add("Authorization", "<authorization>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.delete("https://garu.com.br/api/v1/charges/{uuid}")
.header("Authorization", "<authorization>")
.asString();require 'uri'
require 'net/http'
url = URI("https://garu.com.br/api/v1/charges/{uuid}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["Authorization"] = '<authorization>'
response = http.request(request)
puts response.read_bodyVisão Geral
Cancela uma cobrança ainda não paga — um PIX que expirou no seu fluxo, um boleto que não faz mais sentido, um pedido abandonado. O código PIX e o boleto deixam de ser pagáveis.Para uma cobrança já paga, o caminho é o estorno, não o cancelamento.
Headers
string
required
Sua chave de API (
Bearer sk_live_...)Path Parameters
string
required
UUID da cobrança
Exemplo de Requisição
curl -X DELETE https://garu.com.br/api/v1/charges/6f1c9b2e-4a7d-4f0b-9a3e-1d2c3b4a5e6f \
-H "Authorization: Bearer sk_live_sua_chave_api"
const response = await fetch(
`https://garu.com.br/api/v1/charges/${chargeUuid}`,
{
method: 'DELETE',
headers: { Authorization: `Bearer ${process.env.GARU_API_KEY}` }
}
);
const { canceled } = await response.json();
import os
import requests
response = requests.delete(
f"https://garu.com.br/api/v1/charges/{charge_uuid}",
headers={"Authorization": f"Bearer {os.environ['GARU_API_KEY']}"},
)
print(response.json()["canceled"])
Resposta de Sucesso (200 OK)
{ "canceled": true }
Erros
| Código | Quando acontece |
|---|---|
401 | Chave de API ausente ou inválida |
404 | A cobrança não existe ou não pertence à conta da chave usada |
Was this page helpful?
⌘I