> For the complete documentation index, see [llms.txt](https://roqqu-api-services.gitbook.io/ras/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://roqqu-api-services.gitbook.io/ras/transaction/refund-transaction.md).

# Refund Transaction

Request a refund for a failed send. The send must be at least one hour old. If an on-chain hash exists, the API verifies the send failed on-chain before queuing the refund.

**Endpoint:** `POST /transaction/refund`

**Authentication:** Required (`x-api-key` for live, `x-staging-api-key` for test)

#### Request Parameters <a href="#request-parameters-16" id="request-parameters-16"></a>

| Parameter | Type    | Required | Description                                         |
| --------- | ------- | -------- | --------------------------------------------------- |
| refid     | integer | Yes      | Reference ID of the send (`token_send_queue.refid`) |

#### Example Request <a href="#example-request-27" id="example-request-27"></a>

```
curl -X POST https://service.roqqu.com/v1/transaction/refund \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "refid=10704380386654367514"
```

#### **Example Response (Success)**

```
{
  "status": "success",
  "message": "token queued for refund successfully",
  "data": null
}
```

> When the refund is processed, a `token_refunded` webhook may be emitted. See **Coin Webhook Events**.

#### **Error Responses**

**Transaction does not exist:**

```
{
  "status": "fail",
  "message": "transaction does not exist"
}
```

**Too early (under one hour):**

```
{
  "status": "fail",
  "message": "transaction not up to an hour"
}
```

**Transaction did not fail on-chain:**

```
{
  "status": "fail",
  "message": "transaction did not fail"
}
```

**No on-chain receipt:**

```
{
  "status": "fail",
  "message": "no receipt for transaction on-chain"
}
```

**Already refunded:**

```
{
  "status": "fail",
  "message": "token already refunded successfully"
}
```

**Missing refid:**

```
{
  "status": "fail",
  "message": "(refid) not found in request body"
}
```
