> ## Documentation Index
> Fetch the complete documentation index at: https://docs.swiftpay.cx/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Refund

> Retrieve a specific refund by ID

# Get Refund

Retrieves the details of an existing refund.

## Request

<ParamField header="Authorization" type="string" required>
  Bearer token with your API key
</ParamField>

<ParamField path="id" type="string" required>
  The unique identifier of the refund (e.g., `ref_xyz789`)
</ParamField>

## Response

<ResponseField name="success" type="boolean">
  Whether the request was successful
</ResponseField>

<ResponseField name="data" type="object">
  <Expandable title="properties">
    <ResponseField name="id" type="string">
      Unique refund identifier
    </ResponseField>

    <ResponseField name="checkoutSessionId" type="string">
      Associated checkout session ID
    </ResponseField>

    <ResponseField name="amountInCents" type="integer">
      Refund amount in cents
    </ResponseField>

    <ResponseField name="reason" type="string">
      Refund reason if provided
    </ResponseField>

    <ResponseField name="status" type="string">
      Current status: `pending`, `processing`, `completed`, `failed`
    </ResponseField>

    <ResponseField name="failureReason" type="string">
      Reason for failure (if status is `failed`)
    </ResponseField>

    <ResponseField name="completedAt" type="string">
      ISO 8601 completion timestamp (if completed)
    </ResponseField>

    <ResponseField name="requestedAt" type="string">
      ISO 8601 creation timestamp
    </ResponseField>
  </Expandable>
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl https://api.swiftpay.cx/api/refunds/ref_xyz789 \
    -H "Authorization: Bearer mp_live_your_api_key"
  ```

  ```javascript JavaScript theme={null}
  const refundId = "ref_xyz789";

  const response = await fetch(
     `https://api.swiftpay.cx/api/refunds/${refundId}`,
     {
        headers: {
           Authorization: "Bearer mp_live_your_api_key",
        },
     }
  );

  const refund = await response.json();

  switch (refund.data.status) {
     case "completed":
        console.log("Refund processed successfully");
        break;
     case "failed":
        console.log(`Refund failed: ${refund.data.failureReason}`);
        break;
     case "pending":
     case "processing":
        console.log("Refund still processing");
        break;
  }
  ```

  ```python Python theme={null}
  import requests

  refund_id = 'ref_xyz789'

  response = requests.get(
      f'https://api.swiftpay.cx/api/refunds/{refund_id}',
      headers={'Authorization': 'Bearer mp_live_your_api_key'}
  )

  refund = response.json()
  print(f"Refund status: {refund['data']['status']}")
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "success": true,
    "data": {
      "id": "ref_xyz789",
      "checkoutSessionId": "sess_abc123",
      "amountInCents": 2999,
      "reason": "Customer requested refund",
      "status": "completed",
      "completedAt": "2024-01-15T10:35:00Z",
      "createdAt": "2024-01-15T10:30:00Z"
    }
  }
  ```

  ```json 404 theme={null}
  {
     "success": false,
     "error": {
        "type": "not_found",
        "message": "Refund not found",
        "requestId": "req_abc123"
     }
  }
  ```
</ResponseExample>

## Refund Statuses

| Status       | Description                                     |
| ------------ | ----------------------------------------------- |
| `pending`    | Refund created, awaiting processing             |
| `processing` | Refund is being processed with payment provider |
| `completed`  | Refund successful, funds returned to customer   |
| `failed`     | Refund failed, check `failureReason`            |

<Tip>
  Use webhooks to get notified when refund status changes rather than polling
  this endpoint.
</Tip>
