> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.sqril.io/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.sqril.io/_mcp/server.

# Webhook Notification - Transaction Refunded

POST https://stg-api.sqril.io/webhooks/transactions/refunded
Content-Type: application/json

Example webhook notification sent by SQRIL when a settled transaction is manually refunded by ops.

**When it is sent:**

- After an admin marks a SUCCESS transaction as REFUNDED (ledger credit).

- Sent to all active webhook configs whose event filter matches `transaction.refunded`.


**Payload notes:**

- Required fields: `tx_id`, `status` (`REFUNDED`).

- Optional fields: `amount`, `fee`, `percentage_fee`, `fixed_fee`, `refund_reason`, `sender`, `recipient`.

- `refund_reason` is included when ops supplied a reason on the refund request.


**Headers:**

- `Content-Type: application/json`

- `User-Agent: SQRIL-Webhook/`

- `X-SQRIL-Signature` only when a webhook secret is configured.

**Verifying `X-SQRIL-Signature`:**
```
X-SQRIL-Signature = base64(HMAC-SHA256(webhook_secret, exact_raw_request_body))
```
Use the exact raw HTTP body (do not re-serialize JSON). Encoding is base64, not hex. See the Account Webhook Notifications folder description for a Node.js verification example.

Reference: https://docs.sqril.io/sqril-saa-s-api/account-webhook-notifications/webhook-notification-transaction-refunded

## Authentication

- `Authorization` header (basic auth, required) — Basic Auth: base64(client_id:client_secret)

## Request

### Headers

- `X-SQRIL-Signature` (string, optional) — base64(HMAC-SHA256(webhook_secret, exact_raw_request_body)). Included only when webhook secret is configured. Verify against the raw body; do not re-serialize JSON.

### Body (application/json)

- `tx_id` (string, required)
- `status` (enum, required)
  - Allowed values: `REFUNDED`
- `amount` (double, optional)
- `fee` (double, optional)
- `percentage_fee` (double, optional)
- `fixed_fee` (double, optional)
- `refund_reason` (string, optional)
- `sender` (map from string to any, optional)
- `recipient` (map from string to any, optional)

## Response

### 200

OK

- `received` (boolean, optional)
- `message` (string, optional)

## Examples

### Your endpoint response - 200 OK

**Request**

```json
undefined
```

**Response**

```json
{
  "received": true,
  "message": "Webhook processed successfully"
}
```

**SDK Code**

```python Your endpoint response - 200 OK
import requests

url = "https://stg-api.sqril.io/webhooks/transactions/refunded"

response = requests.post(url, auth=("<username>", "<password>"))

print(response.json())
```

```javascript Your endpoint response - 200 OK
const url = 'https://stg-api.sqril.io/webhooks/transactions/refunded';
const credentials = btoa("<username>:<password>");

const options = {method: 'POST', headers: {Authorization: `Basic ${credentials}`}};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Your endpoint response - 200 OK
package main

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

func main() {

	url := "https://stg-api.sqril.io/webhooks/transactions/refunded"

	req, _ := http.NewRequest("POST", url, nil)

	req.SetBasicAuth("<username>", "<password>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Your endpoint response - 200 OK
require 'uri'
require 'net/http'

url = URI("https://stg-api.sqril.io/webhooks/transactions/refunded")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request.basic_auth("<username>", "<password>")

response = http.request(request)
puts response.read_body
```

```java Your endpoint response - 200 OK
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://stg-api.sqril.io/webhooks/transactions/refunded")
  .basicAuth("<username>", "<password>")
  .asString();
```

```php Your endpoint response - 200 OK
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://stg-api.sqril.io/webhooks/transactions/refunded', [
  'headers' => [
  ],
    'auth' => ['<username>', '<password>'],
]);

echo $response->getBody();
```

```csharp Your endpoint response - 200 OK
using RestSharp;
using RestSharp.Authenticators;

var client = new RestClient("https://stg-api.sqril.io/webhooks/transactions/refunded");
client.Authenticator = new HttpBasicAuthenticator("<username>", "<password>");
var request = new RestRequest(Method.POST);

IRestResponse response = client.Execute(request);
```

```swift Your endpoint response - 200 OK
import Foundation

let credentials = Data("<username>:<password>".utf8).base64EncodedString()

let headers = ["Authorization": "Basic \(credentials)"]

let request = NSMutableURLRequest(url: NSURL(string: "https://stg-api.sqril.io/webhooks/transactions/refunded")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Outbound webhook payload (SQRIL → your endpoint)

**Request**

```json
{
  "tx_id": "{{tx_id}}",
  "status": "REFUNDED",
  "amount": 100000,
  "fee": 0.35,
  "percentage_fee": 0.25,
  "fixed_fee": 0.1,
  "refund_reason": "Payment reversal",
  "sender": {
    "name_first": "John",
    "name_last": "Doe",
    "country": "MY",
    "ic_number": "123456789012",
    "ic_type": "NIC",
    "phone": "+60123456789",
    "email": "john.doe@example.com"
  },
  "recipient": {
    "name_first": "Jane",
    "name_last": "Smith",
    "country": "ID",
    "account_no": "1234567890",
    "bank_code": "014",
    "bank_name": "Bank BCA"
  }
}
```

**Response**

```json
{
  "received": true,
  "message": "Webhook processed successfully"
}
```

**SDK Code**

```python Outbound webhook payload (SQRIL → your endpoint)
import requests

url = "https://stg-api.sqril.io/webhooks/transactions/refunded"

payload = {
    "tx_id": "{{tx_id}}",
    "status": "REFUNDED",
    "amount": 100000,
    "fee": 0.35,
    "percentage_fee": 0.25,
    "fixed_fee": 0.1,
    "refund_reason": "Payment reversal",
    "sender": {
        "name_first": "John",
        "name_last": "Doe",
        "country": "MY",
        "ic_number": "123456789012",
        "ic_type": "NIC",
        "phone": "+60123456789",
        "email": "john.doe@example.com"
    },
    "recipient": {
        "name_first": "Jane",
        "name_last": "Smith",
        "country": "ID",
        "account_no": "1234567890",
        "bank_code": "014",
        "bank_name": "Bank BCA"
    }
}
headers = {
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers, auth=("<username>", "<password>"))

print(response.json())
```

```javascript Outbound webhook payload (SQRIL → your endpoint)
const url = 'https://stg-api.sqril.io/webhooks/transactions/refunded';
const credentials = btoa("<username>:<password>");

const options = {
  method: 'POST',
  headers: {
    Authorization: `Basic ${credentials}`,
    'Content-Type': 'application/json'
  },
  body: '{"tx_id":"{{tx_id}}","status":"REFUNDED","amount":100000,"fee":0.35,"percentage_fee":0.25,"fixed_fee":0.1,"refund_reason":"Payment reversal","sender":{"name_first":"John","name_last":"Doe","country":"MY","ic_number":"123456789012","ic_type":"NIC","phone":"+60123456789","email":"john.doe@example.com"},"recipient":{"name_first":"Jane","name_last":"Smith","country":"ID","account_no":"1234567890","bank_code":"014","bank_name":"Bank BCA"}}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Outbound webhook payload (SQRIL → your endpoint)
package main

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

func main() {

	url := "https://stg-api.sqril.io/webhooks/transactions/refunded"

	payload := strings.NewReader("{\n  \"tx_id\": \"{{tx_id}}\",\n  \"status\": \"REFUNDED\",\n  \"amount\": 100000,\n  \"fee\": 0.35,\n  \"percentage_fee\": 0.25,\n  \"fixed_fee\": 0.1,\n  \"refund_reason\": \"Payment reversal\",\n  \"sender\": {\n    \"name_first\": \"John\",\n    \"name_last\": \"Doe\",\n    \"country\": \"MY\",\n    \"ic_number\": \"123456789012\",\n    \"ic_type\": \"NIC\",\n    \"phone\": \"+60123456789\",\n    \"email\": \"john.doe@example.com\"\n  },\n  \"recipient\": {\n    \"name_first\": \"Jane\",\n    \"name_last\": \"Smith\",\n    \"country\": \"ID\",\n    \"account_no\": \"1234567890\",\n    \"bank_code\": \"014\",\n    \"bank_name\": \"Bank BCA\"\n  }\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.SetBasicAuth("<username>", "<password>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Outbound webhook payload (SQRIL → your endpoint)
require 'uri'
require 'net/http'

url = URI("https://stg-api.sqril.io/webhooks/transactions/refunded")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request.basic_auth("<username>", "<password>")
request["Content-Type"] = 'application/json'
request.body = "{\n  \"tx_id\": \"{{tx_id}}\",\n  \"status\": \"REFUNDED\",\n  \"amount\": 100000,\n  \"fee\": 0.35,\n  \"percentage_fee\": 0.25,\n  \"fixed_fee\": 0.1,\n  \"refund_reason\": \"Payment reversal\",\n  \"sender\": {\n    \"name_first\": \"John\",\n    \"name_last\": \"Doe\",\n    \"country\": \"MY\",\n    \"ic_number\": \"123456789012\",\n    \"ic_type\": \"NIC\",\n    \"phone\": \"+60123456789\",\n    \"email\": \"john.doe@example.com\"\n  },\n  \"recipient\": {\n    \"name_first\": \"Jane\",\n    \"name_last\": \"Smith\",\n    \"country\": \"ID\",\n    \"account_no\": \"1234567890\",\n    \"bank_code\": \"014\",\n    \"bank_name\": \"Bank BCA\"\n  }\n}"

response = http.request(request)
puts response.read_body
```

```java Outbound webhook payload (SQRIL → your endpoint)
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://stg-api.sqril.io/webhooks/transactions/refunded")
  .basicAuth("<username>", "<password>")
  .header("Content-Type", "application/json")
  .body("{\n  \"tx_id\": \"{{tx_id}}\",\n  \"status\": \"REFUNDED\",\n  \"amount\": 100000,\n  \"fee\": 0.35,\n  \"percentage_fee\": 0.25,\n  \"fixed_fee\": 0.1,\n  \"refund_reason\": \"Payment reversal\",\n  \"sender\": {\n    \"name_first\": \"John\",\n    \"name_last\": \"Doe\",\n    \"country\": \"MY\",\n    \"ic_number\": \"123456789012\",\n    \"ic_type\": \"NIC\",\n    \"phone\": \"+60123456789\",\n    \"email\": \"john.doe@example.com\"\n  },\n  \"recipient\": {\n    \"name_first\": \"Jane\",\n    \"name_last\": \"Smith\",\n    \"country\": \"ID\",\n    \"account_no\": \"1234567890\",\n    \"bank_code\": \"014\",\n    \"bank_name\": \"Bank BCA\"\n  }\n}")
  .asString();
```

```php Outbound webhook payload (SQRIL → your endpoint)
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://stg-api.sqril.io/webhooks/transactions/refunded', [
  'body' => '{
  "tx_id": "{{tx_id}}",
  "status": "REFUNDED",
  "amount": 100000,
  "fee": 0.35,
  "percentage_fee": 0.25,
  "fixed_fee": 0.1,
  "refund_reason": "Payment reversal",
  "sender": {
    "name_first": "John",
    "name_last": "Doe",
    "country": "MY",
    "ic_number": "123456789012",
    "ic_type": "NIC",
    "phone": "+60123456789",
    "email": "john.doe@example.com"
  },
  "recipient": {
    "name_first": "Jane",
    "name_last": "Smith",
    "country": "ID",
    "account_no": "1234567890",
    "bank_code": "014",
    "bank_name": "Bank BCA"
  }
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
    'auth' => ['<username>', '<password>'],
]);

echo $response->getBody();
```

```csharp Outbound webhook payload (SQRIL → your endpoint)
using RestSharp;
using RestSharp.Authenticators;

var client = new RestClient("https://stg-api.sqril.io/webhooks/transactions/refunded");
client.Authenticator = new HttpBasicAuthenticator("<username>", "<password>");
var request = new RestRequest(Method.POST);

request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"tx_id\": \"{{tx_id}}\",\n  \"status\": \"REFUNDED\",\n  \"amount\": 100000,\n  \"fee\": 0.35,\n  \"percentage_fee\": 0.25,\n  \"fixed_fee\": 0.1,\n  \"refund_reason\": \"Payment reversal\",\n  \"sender\": {\n    \"name_first\": \"John\",\n    \"name_last\": \"Doe\",\n    \"country\": \"MY\",\n    \"ic_number\": \"123456789012\",\n    \"ic_type\": \"NIC\",\n    \"phone\": \"+60123456789\",\n    \"email\": \"john.doe@example.com\"\n  },\n  \"recipient\": {\n    \"name_first\": \"Jane\",\n    \"name_last\": \"Smith\",\n    \"country\": \"ID\",\n    \"account_no\": \"1234567890\",\n    \"bank_code\": \"014\",\n    \"bank_name\": \"Bank BCA\"\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Outbound webhook payload (SQRIL → your endpoint)
import Foundation

let credentials = Data("<username>:<password>".utf8).base64EncodedString()

let headers = [
  "Authorization": "Basic \(credentials)",
  "Content-Type": "application/json"
]
let parameters = [
  "tx_id": "{{tx_id}}",
  "status": "REFUNDED",
  "amount": 100000,
  "fee": 0.35,
  "percentage_fee": 0.25,
  "fixed_fee": 0.1,
  "refund_reason": "Payment reversal",
  "sender": [
    "name_first": "John",
    "name_last": "Doe",
    "country": "MY",
    "ic_number": "123456789012",
    "ic_type": "NIC",
    "phone": "+60123456789",
    "email": "john.doe@example.com"
  ],
  "recipient": [
    "name_first": "Jane",
    "name_last": "Smith",
    "country": "ID",
    "account_no": "1234567890",
    "bank_code": "014",
    "bank_name": "Bank BCA"
  ]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://stg-api.sqril.io/webhooks/transactions/refunded")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```