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

# API Reference

> Overview of ZAFA PAY API

<Columns cols={2}>
  <Card title="OpenAPI Specification" icon="file-code">
    Download our OpenAPI specification to generate client libraries or import into API tools like Postman.

    <a href="/api-reference/openapi.en.json" download="zafapay-openapi.json" className="inline-flex items-center gap-2 px-4 py-2 text-sm font-medium text-white bg-primary rounded-lg hover:opacity-90 no-underline mt-2">
      Download OpenAPI (JSON)
    </a>
  </Card>

  <Card title="Full Documentation" icon="file-lines">
    Download the complete documentation as a text file for offline reading or AI tool integration.

    <a href="/llms-full.txt" download="zafapay-docs.txt" className="inline-flex items-center gap-2 px-4 py-2 text-sm font-medium text-white bg-primary rounded-lg hover:opacity-90 no-underline mt-2">
      Download Docs (TXT)
    </a>
  </Card>
</Columns>

## API Endpoints

| Environment | Base URL                          |
| ----------- | --------------------------------- |
| Sandbox     | `https://api.sandbox.zafapay.com` |
| Production  | `https://api.zafapay.com`         |

## Authentication

All API requests require Bearer token authentication.

```bash theme={null}
Authorization: Bearer YOUR_ACCESS_TOKEN
```

<Note>
  For instructions on obtaining an access token, see [Authentication](/en/api-reference/authentication).
</Note>

## Request Format

* Content-Type: `application/json`
* Character encoding: UTF-8

## Response Format

All responses are returned in JSON format.

**Success (Create Payment):**

```json theme={null}
{
  "success": true,
  "status": "pending",
  "transaction_id": "tx_abc123",
  "gateway_transaction_id": "pi_xxxxx",
  ...
}
```

**Success (Get Payment):**

```json theme={null}
{
  "id": "tx_abc123",
  "status": "completed",
  "amount": 100,
  ...
}
```

**Error:**

```json theme={null}
{
  "error": {
    "type": "invalid_request_error",
    "code": "validation_error",
    "message": "Error message",
    "request_id": "req_abc123xyz789"
  }
}
```

<Note>
  For error code details, see [Error Codes](/en/api-reference/errors).
</Note>

## Transaction Status

| Status               | Description                                               |
| -------------------- | --------------------------------------------------------- |
| `pending`            | Payment created, awaiting customer action (redirect flow) |
| `requires_action`    | Awaiting frontend action (card payment)                   |
| `authorized`         | Authorization complete (awaiting manual capture)          |
| `completed`          | Payment completed                                         |
| `failed`             | Payment failed                                            |
| `canceled`           | Payment canceled                                          |
| `partially_refunded` | Partially refunded                                        |
| `refunded`           | Fully refunded                                            |
