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

# トークンの生成

> カードバインドリクエストを開始し、フロントエンド SDK で使用する `tokenSessionId` を取得します。

```
POST /api/v1/tokenization/generate
```

## リクエストパラメータ

| パラメータ            | 型      | 必須  | 説明                            |
| ---------------- | ------ | --- | ----------------------------- |
| `tokenRequestId` | String | はい  | カードバインドリクエストの冪等性キー            |
| `merchantUserId` | String | はい  | 加盟店側のユーザー ID                  |
| `tokenType`      | String | はい  | トークン種別、`"CARD"` 固定            |
| `merchantInfo`   | Object | はい  | 加盟店情報（`merchantId` を含む）       |
| `notifyUrl`      | String | はい  | カードバインド結果の Webhook コールバック URL |
| `tokenData`      | Object | いいえ | カードデータ（PCI-DSS 加盟店のみ）         |

### tokenData（PCI-DSS 加盟店のみ）

| パラメータ    | 型      | 説明            |
| -------- | ------ | ------------- |
| `pan`    | String | カード番号         |
| `name`   | String | カード名義         |
| `expiry` | String | 有効期限（MM/YYYY） |
| `cvv`    | String | CVV           |

## レスポンスパラメータ

| パラメータ            | 型      | 説明                                                |
| ---------------- | ------ | ------------------------------------------------- |
| `tokenSessionId` | String | セッション ID。フロントエンド SDK の `tokenizationSubmit` に渡します |
| `tokenId`        | String | トークン ID（PCI-DSS 加盟店が直接送信した場合のみ返却）                 |

## リクエスト例

### 標準フロー（フロントエンド SDK 経由で送信）

```json theme={null}
{
  "tokenRequestId": "treq_a1b2c3d4e5f6",
  "merchantUserId": "user_123",
  "tokenType": "CARD",
  "merchantInfo": { "merchantId": "M000001" },
  "notifyUrl": "https://your-site.com/webhook/tokenization"
}
```

### レスポンス例

```json theme={null}
{
  "code": "0",
  "msg": "Success",
  "data": {
    "tokenSessionId": "tsess_xxxxxxxxxxxx"
  }
}
```

`tokenSessionId` を取得した後、フロントエンド SDK の `tokenizationSubmit` メソッドに渡してカード送信を完了します。

## カードバインド結果通知

カードバインド完了後、Waffo は `notifyUrl` に Webhook 通知を送信し、`tokenId` を含みます。加盟店はこの `tokenId` を保存し、以降の決済に使用する必要があります。
