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

# 現在の契約の取得

> 認証済みユーザーの現在の契約状態と詳細を返します。

## 概要

プラン内容、請求サイクル、更新日など、現在の契約情報を返します。セッション認証（JWT アクセストークン）が必要です。

<Note>
  **サードパーティ連携:** API キー認証で `GET /subscriptions/current/api` を利用してください。
</Note>

## 認証

<ParamField header="Authorization" type="string" required>
  JWT アクセストークン。形式: `Bearer YOUR_ACCESS_TOKEN`
</ParamField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X GET https://api.llmgenerator.com/api/v1/subscriptions/current \
    -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://api.llmgenerator.com/api/v1/subscriptions/current', {
    headers: {
      'Authorization': 'Bearer YOUR_ACCESS_TOKEN'
    }
  });
  const data = await response.json();
  ```

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

  response = requests.get(
      'https://api.llmgenerator.com/api/v1/subscriptions/current',
      headers={'Authorization': 'Bearer YOUR_ACCESS_TOKEN'}
  )
  data = response.json()
  ```
</RequestExample>

<ResponseExample>
  ```json 契約あり theme={null}
  {
    "hasSubscription": true,
    "subscription": {
      "plan": "professional",
      "status": "active",
      "billingCycle": "monthly",
      "currentPeriodStart": "2024-01-15T00:00:00Z",
      "currentPeriodEnd": "2024-02-15T00:00:00Z",
      "cancelAtPeriodEnd": false
    },
    "planDetails": {
      "id": "professional",
      "name": "Professional",
      "monthlyCredits": 3000,
      "price": 12.99,
      "features": [
        "3,000 credits/month",
        "Priority support",
        "Advanced analytics"
      ]
    }
  }
  ```

  ```json 契約なし theme={null}
  {
    "hasSubscription": false,
    "subscription": null,
    "planDetails": null
  }
  ```

  ```json 解約予定（現時点では有効） theme={null}
  {
    "hasSubscription": true,
    "subscription": {
      "plan": "professional",
      "status": "active",
      "billingCycle": "monthly",
      "currentPeriodStart": "2024-01-15T00:00:00Z",
      "currentPeriodEnd": "2024-02-15T00:00:00Z",
      "cancelAtPeriodEnd": true
    },
    "planDetails": {
      "id": "professional",
      "name": "Professional",
      "monthlyCredits": 3000,
      "price": 12.99,
      "features": [...]
    }
  }
  ```
</ResponseExample>

## レスポンスフィールド

<ResponseField name="hasSubscription" type="boolean">
  ユーザーに有効な契約があるかどうか。
</ResponseField>

<ResponseField name="subscription" type="object">
  契約詳細（契約がない場合は `null`）。

  <Expandable title="プロパティ">
    <ResponseField name="plan" type="string">
      プラン識別子（starter、professional、business、agency）。
    </ResponseField>

    <ResponseField name="status" type="string">
      現在の状態: `active`、`canceled`、`past_due`、`trialing`。
    </ResponseField>

    <ResponseField name="billingCycle" type="string">
      請求頻度: `monthly` または `yearly`。
    </ResponseField>

    <ResponseField name="currentPeriodStart" type="string">
      現在の請求期間の開始日（ISO 8601）。
    </ResponseField>

    <ResponseField name="currentPeriodEnd" type="string">
      現在の請求期間の終了日（ISO 8601）。
    </ResponseField>

    <ResponseField name="cancelAtPeriodEnd" type="boolean">
      `true` の場合、サブスクは `currentPeriodEnd` で終了します。
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="planDetails" type="object">
  プランの全体情報（契約がない場合は `null`）。
</ResponseField>

## 契約ステータス

| ステータス      | 説明                        |
| ---------- | ------------------------- |
| `active`   | 契約が有効で正常です                |
| `trialing` | 無料試用期中です                  |
| `past_due` | 支払い失敗があり、まもなく停止する可能性があります |
| `canceled` | 契約は完全に解約されています            |

## エラーレスポンス

<ResponseField name="401" type="error">
  未認証 — トークンが無効または未指定です。
</ResponseField>

***

## GET /subscriptions/current/api

API キー認証で現在の契約情報を返します。サードパーティ連携向けです。

### 認証

API キー認証が必要です。`Authorization` ヘッダーに API キーを付与します。

```
Authorization: Bearer llmgen_your_api_key_here
```

### レスポンス

`/subscriptions/current` と同一です。

<RequestExample>
  ```bash cURL theme={null}
  curl -X GET https://api.llmgenerator.com/api/v1/subscriptions/current/api \
    -H "Authorization: Bearer llmgen_your_api_key_here"
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://api.llmgenerator.com/api/v1/subscriptions/current/api', {
    headers: {
      'Authorization': 'Bearer llmgen_your_api_key_here'
    }
  });
  const data = await response.json();
  ```

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

  response = requests.get(
      'https://api.llmgenerator.com/api/v1/subscriptions/current/api',
      headers={'Authorization': 'Bearer llmgen_your_api_key_here'}
  )
  data = response.json()
  ```
</RequestExample>
