Skip to main content
POST
/
transactions
/
{transaction_id}
/
refunds
/
all
Refund all instruments in a transaction
using RestSharp;


var options = new RestClientOptions("https://api.sandbox.{id}.gr4vy.app/transactions/{transaction_id}/refunds/all");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("Authorization", "Bearer <token>");
request.AddJsonBody("{\n  \"reason\": \"Refund due to user request\"\n}", false);
var response = await client.PostAsync(request);

Console.WriteLine("{0}", response.Content);
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api.sandbox.{id}.gr4vy.app/transactions/{transaction_id}/refunds/all"

payload := strings.NewReader("{\n \"reason\": \"Refund due to user request\"\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.sandbox.{id}.gr4vy.app/transactions/{transaction_id}/refunds/all")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"reason\": \"Refund due to user request\"\n}")
.asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.sandbox.{id}.gr4vy.app/transactions/{transaction_id}/refunds/all",
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' => 'Refund due to user request'
]),
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;
}
import requests

url = "https://api.sandbox.{id}.gr4vy.app/transactions/{transaction_id}/refunds/all"

payload = { "reason": "Refund due to user request" }
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: 'Refund due to user request'})
};

fetch('https://api.sandbox.{id}.gr4vy.app/transactions/{transaction_id}/refunds/all', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
curl --request POST \
--url https://api.sandbox.{id}.gr4vy.app/transactions/{transaction_id}/refunds/all \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"reason": "Refund due to user request"
}
'
{
  "items": [
    {
      "type": "refund",
      "id": "8724fd24-5489-4a5d-90fd-0604df7d3b83",
      "transaction_id": "fe26475d-ec3e-4884-9553-f7356683f7f9",
      "payment_service_refund_id": "refund_xYqd43gySMtori",
      "status": "processing",
      "currency": "USD",
      "amount": 1299,
      "reason": "Refund due to user request",
      "created_at": "2013-07-16T19:23:00.000+00:00",
      "updated_at": "2013-07-16T19:23:00.000+00:00",
      "target_type": "payment-method",
      "target_id": "c23ea83f-1b1c-4584-a0e8-78ef8c041949",
      "external_identifier": "refund-789123",
      "reconciliation_id": "7jZXl4gBUNl0CnaLEnfXbt",
      "transaction_external_identifier": "transaction-789123",
      "transaction_reconciliation_id": "7jZXl4gBUNl0CnaLEnfXbt"
    }
  ],
  "limit": 1,
  "next_cursor": "ZXhhbXBsZTE",
  "previous_cursor": null
}
{
"type": "error",
"code": "bad_request",
"status": 400,
"message": "Missing '****' field",
"details": [
{
"location": "body",
"type": "value_error.missing",
"pointer": "/payment_method/number",
"message": "field required"
}
]
}
{
"type": "error",
"code": "unauthorized",
"status": 401,
"message": "No valid API authentication found",
"details": []
}
{
"type": "error",
"code": "not_found",
"status": 404,
"message": "The resource could not be found",
"details": []
}
This endpoint requires the transactions.write scope.

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

transaction_id
string
required

The ID for the transaction to get the information for.

Example:

"fe26475d-ec3e-4884-9553-f7356683f7f9"

Body

application/json

A request to fully refund a transaction.

reason
string | null

The reason to refund for. This can be used to attach a written reason to the refund request.

Maximum string length: 100
Example:

"Refund due to user request"

external_identifier
string | null

An external identifier that can be used to match the refund against your own records.

Required string length: 1 - 300
Example:

"refund-789123"

Response

Returns the created refunds. Not all refunds may have succeeded.

A list of refunds.

items
Refund · object[]

A list of refunds.

limit
integer<int32>
default:20

The limit applied to request. This represents the number of items that are at maximum returned by this request.

Required range: 1 <= x <= 100
Example:

1

next_cursor
string | null

The cursor that represents the next page of results. Use the cursor query parameter to fetch this page of items.

Required string length: 1 - 1000
Example:

"ZXhhbXBsZTE"

previous_cursor
string | null

The cursor that represents the next page of results. Use the cursor query parameter to fetch this page of items.

Required string length: 1 - 1000
Example:

null