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

# Refund transaction

POST https://public-api.alphax.asia/v1/transactions/{transactionId}/refund

Refund a card checkout payment by its ULID. No request body is required.

Only authorized payment acceptance transactions can be refunded, and
each transaction can be refunded once.


Reference: https://docs.alphax.asia/api-reference/alpha-x-api/transactions/refund-transaction

## Authentication

- `X-API-Key` header (required) — API Key authentication via header

## Servers

- `https://public-api.alphax.asia` (Production server, default)
- `https://public-api.demo.alphax.asia` (Staging server)

## Request

### Path parameters

- `transactionId` (string, required)

## Response

### 200

Transaction refunded successfully

- `id` (string, optional) — Unique ULID of the transaction
- `status` (enum, optional)
  - Allowed values: `REFUNDED`

## Errors

### 400 Bad Request Error

The transaction cannot be refunded

- `error` (string, optional) — A stable, machine-readable error code.

### 403 Forbidden Error

The `X-Company-Id` company is not linked to your partner account, or is not your company

- `error` (string, optional) — A stable, machine-readable error code.

### 404 Not Found Error

Transaction not found, or it does not belong to the company of the current API key

- `message` (string, optional)

## Examples

**Response**

```json
{
  "id": "01kqc6aaq3jshqyz6a0k8nkxfe",
  "status": "REFUNDED"
}
```

**SDK Code**

```python Transactions_refundTransaction_example
import requests

url = "https://public-api.alphax.asia/v1/transactions/transactionId/refund"

headers = {"X-API-Key": "<apiKey>"}

response = requests.post(url, headers=headers)

print(response.json())
```

```javascript Transactions_refundTransaction_example
const url = 'https://public-api.alphax.asia/v1/transactions/transactionId/refund';
const options = {method: 'POST', headers: {'X-API-Key': '<apiKey>'}};

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

```go Transactions_refundTransaction_example
package main

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

func main() {

	url := "https://public-api.alphax.asia/v1/transactions/transactionId/refund"

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

	req.Header.Add("X-API-Key", "<apiKey>")

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

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

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

}
```

```ruby Transactions_refundTransaction_example
require 'uri'
require 'net/http'

url = URI("https://public-api.alphax.asia/v1/transactions/transactionId/refund")

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

request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<apiKey>'

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

```java Transactions_refundTransaction_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://public-api.alphax.asia/v1/transactions/transactionId/refund")
  .header("X-API-Key", "<apiKey>")
  .asString();
```

```php Transactions_refundTransaction_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://public-api.alphax.asia/v1/transactions/transactionId/refund', [
  'headers' => [
    'X-API-Key' => '<apiKey>',
  ],
]);

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

```csharp Transactions_refundTransaction_example
using RestSharp;

var client = new RestClient("https://public-api.alphax.asia/v1/transactions/transactionId/refund");
var request = new RestRequest(Method.POST);
request.AddHeader("X-API-Key", "<apiKey>");
IRestResponse response = client.Execute(request);
```

```swift Transactions_refundTransaction_example
import Foundation

let headers = ["X-API-Key": "<apiKey>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://public-api.alphax.asia/v1/transactions/transactionId/refund")! 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()
```