申请交易退款
curl --request POST \
--url https://api.brazilpix.com/v2/transactions/{id}/refund \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"reason": "Cliente solicitou cancelamento"
}
'import requests
url = "https://api.brazilpix.com/v2/transactions/{id}/refund"
payload = { "reason": "Cliente solicitou cancelamento" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({reason: 'Cliente solicitou cancelamento'})
};
fetch('https://api.brazilpix.com/v2/transactions/{id}/refund', 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://api.brazilpix.com/v2/transactions/{id}/refund",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'reason' => 'Cliente solicitou cancelamento'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.brazilpix.com/v2/transactions/{id}/refund"
payload := strings.NewReader("{\n \"reason\": \"Cliente solicitou cancelamento\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.brazilpix.com/v2/transactions/{id}/refund")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"reason\": \"Cliente solicitou cancelamento\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.brazilpix.com/v2/transactions/{id}/refund")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"reason\": \"Cliente solicitou cancelamento\"\n}"
response = http.request(request)
puts response.read_body{
"originalTransactionId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"pspProvider": "<string>",
"pspRefundTransactionId": "<string>",
"status": "PENDING"
}{
"statusCode": 400,
"error": "BadRequest",
"message": "name must be longer than or equal to 2 characters",
"timestamp": "2025-12-15T22:00:00.000Z",
"details": {},
"traceId": "<string>"
}{
"statusCode": 401,
"error": "Unauthorized",
"message": "Authentication token is required",
"timestamp": "2025-12-15T22:00:00.000Z",
"details": {},
"traceId": "<string>"
}{
"statusCode": 404,
"error": "NotFound",
"message": "Resource with id 550e8400-e29b-41d4-a716-446655440000 not found",
"timestamp": "2025-12-15T22:00:00.000Z",
"details": {
"resource": "Example",
"id": "550e8400-e29b-41d4-a716-446655440000"
},
"traceId": "<string>"
}{
"statusCode": 500,
"error": "InternalError",
"message": "An unexpected error occurred",
"timestamp": "2025-12-15T22:00:00.000Z",
"details": {},
"traceId": "2771463d58840c8e116dc6dda1e1e5d0"
}交易
申请退款
对指定的支付交易申请全额退款。退款为异步处理——PSP 处理完成后,将通过 webhook refund_completed 送达确认。
所需权限: REFUND:WRITE 或 FULL_ACCESS
POST
/
transactions
/
{id}
/
refund
申请交易退款
curl --request POST \
--url https://api.brazilpix.com/v2/transactions/{id}/refund \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"reason": "Cliente solicitou cancelamento"
}
'import requests
url = "https://api.brazilpix.com/v2/transactions/{id}/refund"
payload = { "reason": "Cliente solicitou cancelamento" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({reason: 'Cliente solicitou cancelamento'})
};
fetch('https://api.brazilpix.com/v2/transactions/{id}/refund', 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://api.brazilpix.com/v2/transactions/{id}/refund",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'reason' => 'Cliente solicitou cancelamento'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.brazilpix.com/v2/transactions/{id}/refund"
payload := strings.NewReader("{\n \"reason\": \"Cliente solicitou cancelamento\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.brazilpix.com/v2/transactions/{id}/refund")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"reason\": \"Cliente solicitou cancelamento\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.brazilpix.com/v2/transactions/{id}/refund")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"reason\": \"Cliente solicitou cancelamento\"\n}"
response = http.request(request)
puts response.read_body{
"originalTransactionId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"pspProvider": "<string>",
"pspRefundTransactionId": "<string>",
"status": "PENDING"
}{
"statusCode": 400,
"error": "BadRequest",
"message": "name must be longer than or equal to 2 characters",
"timestamp": "2025-12-15T22:00:00.000Z",
"details": {},
"traceId": "<string>"
}{
"statusCode": 401,
"error": "Unauthorized",
"message": "Authentication token is required",
"timestamp": "2025-12-15T22:00:00.000Z",
"details": {},
"traceId": "<string>"
}{
"statusCode": 404,
"error": "NotFound",
"message": "Resource with id 550e8400-e29b-41d4-a716-446655440000 not found",
"timestamp": "2025-12-15T22:00:00.000Z",
"details": {
"resource": "Example",
"id": "550e8400-e29b-41d4-a716-446655440000"
},
"traceId": "<string>"
}{
"statusCode": 500,
"error": "InternalError",
"message": "An unexpected error occurred",
"timestamp": "2025-12-15T22:00:00.000Z",
"details": {},
"traceId": "2771463d58840c8e116dc6dda1e1e5d0"
}授权
通过 POST /auth(client_id + client_secret)获取的访问令牌。有效期 300 秒。
请求头
执行操作的子账户的 reference。省略时,操作在主账户上执行;保留值 principal 同样解析为主账户,等同于省略该请求头。除 POST /auth 和 /sub-accounts 自身的端点(始终在主账户上操作)外,所有端点均接受该请求头。
可能的错误:404 SUB_ACCOUNT_NOT_FOUND、403 SUB_ACCOUNT_FORBIDDEN、403 SUB_ACCOUNT_SUSPENDED。
要求凭证已启用子账户访问(设置 → 集成 → API 凭证)。该项默认关闭,任何权限都无法替代,FULL_ACCESS 也不例外:未启用时响应为 403 SUB_ACCOUNT_FORBIDDEN。
Pattern:
^[a-z0-9][a-z0-9_-]{1,31}$示例:
"loja-centro"
路径参数
待退款的支付交易 ID
请求体
application/json
退款原因(可选,最多 255 个字符)
Maximum string length:
255示例:
"Cliente solicitou cancelamento"