> ## 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リファレンス

> ZAFA PAY APIの概要

<Columns cols={2}>
  <Card title="OpenAPI仕様書" icon="file-code">
    OpenAPI仕様書をダウンロードして、クライアントライブラリの生成やPostmanなどのAPIツールにインポートできます。

    <a href="/api-reference/openapi.ja.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">
      OpenAPIをダウンロード (JSON)
    </a>
  </Card>

  <Card title="全ドキュメント" icon="file-lines">
    全ドキュメントをテキスト形式でダウンロードして、オフラインでの閲覧やAIツールへの入力に活用できます。

    <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">
      ドキュメントをダウンロード (TXT)
    </a>
  </Card>
</Columns>

## API エンドポイント

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

## 認証

全てのAPIリクエストにBearer token認証が必要です。

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

<Note>
  アクセストークンの取得方法は[認証](/ja/api-reference/authentication)を参照してください。
</Note>

## リクエスト形式

* Content-Type: `application/json`
* 文字エンコーディング: UTF-8

## レスポンス形式

全てのレスポンスはJSON形式で返されます。

**成功時（決済作成）:**

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

**成功時（決済取得）:**

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

**エラー時:**

```json theme={null}
{
  "error": {
    "type": "invalid_request_error",
    "code": "validation_error",
    "message": "エラーメッセージ",
    "request_id": "req_abc123xyz789"
  }
}
```

<Note>
  エラーコードの詳細は[エラーコード](/ja/api-reference/errors)を参照してください。
</Note>

## トランザクションステータス

| ステータス                | 説明                         |
| -------------------- | -------------------------- |
| `pending`            | 決済作成済み、顧客のアクション待ち（リダイレクト型） |
| `requires_action`    | フロントエンドでのアクション待ち（カード決済）    |
| `authorized`         | オーソリ完了（手動キャプチャ待ち）          |
| `completed`          | 決済完了                       |
| `failed`             | 決済失敗                       |
| `canceled`           | 決済キャンセル                    |
| `partially_refunded` | 一部返金済み                     |
| `refunded`           | 全額返金済み                     |
