> For the complete documentation index, see [llms.txt](https://docs.maiagent.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.maiagent.ai/api/ja/api-reference/credit.md).

# Credit

Credit カテゴリでは、組織の Credit の照会とクォータ配分を行えます。残高、有効期限が近い Credit、入金履歴、消費明細と合計、使用量統計、料金ルールと料金項目のほか、メンバー、ロール、対話プラットフォームそれぞれのクォータ設定（一覧取得、設定、更新、無効化、クォータ要否の設定）、ロール単位でのメンバークォータの一括配分や一括無効化に対応しています。

#### 事前説明 <a href="#credit-prerequisites" id="credit-prerequisites"></a>

**認証とパスパラメーター**

「料金ルール」と「料金項目」を除くすべての API では、HTTP ヘッダーに API キーを指定する必要があります。

```
Authorization: Api-Key {API_KEY}
```

API キーに基づいて、所属組織とメンバーが自動的に識別されます。`/api/v1/credit/` で始まる API では、組織の識別子を別途渡す必要はありません。パスに必要な ID は、次の方法で取得できます。

* `organizationPk`：`GET /api/v1/organizations/` を呼び出し、レスポンス内の組織の `id` を取得します。
* ウォレットの `id`：`GET /api/v1/organizations/{id}/` を呼び出し、レスポンス内の `creditWallet.id` を取得します。

**レート制限**

API キーが必要な API のレート制限は、**API キーごとに個別に設定された 1 分あたりのリクエスト数**です。組織管理者が「組織設定 → API キー」の「1 分あたりのリクエスト数（RPM）」で設定します。同じキーによるプラットフォーム上のすべての API 呼び出しが合算されます。上限を設定していないキーには、この制限は適用されません。上限を超えたリクエストは拒否され、HTTP 429 が返されます。次の分まで待ってから再試行してください。

「料金ルール」と「料金項目」には API キーが不要です。呼び出し上限は送信元 IP ごとに別途計算されます。各 API の注記を参照してください。

**クォータの仕組み**

メンバー、ロール、対話プラットフォームにはそれぞれクォータの階層があり、管理画面の「Credits → クォータ配分」にある 3 つのタブに対応しています。各階層は個別に集計されます。

* **メンバークォータ**：個々のメンバー自身の使用量上限です。
* **ロールクォータ**：ロールに所属するすべてのメンバーで共有する上限です。各メンバーの個別クォータとは別に集計されます。メンバーがクォータを必要とする複数のロールに所属している場合、使用量は各ロールに加算されます。いずれか 1 つのロールのクォータを使い切ると、利用が制限されます。
* **対話プラットフォームクォータ**：その対話プラットフォーム（Inbox）での AI 応答の使用量上限です。MaiGPT の対話プラットフォームにはクォータを設定できません。

各階層には、同じルールが適用されます。

* **クォータが必要**：メンバー、ロール、対話プラットフォームには、それぞれ「クォータが必要」の設定があります（レスポンスフィールド `creditQuotaRequired`）。無効の場合、この階層のチェックも集計も行わず、組織のウォレットを直接使用します。有効の場合、有効なクォータがなければ利用できません。有効なクォータがないと、メンバーとロールでは Credit を消費する機能が利用できなくなり、対話プラットフォームでは AI 応答が停止します。
* **クォータを設定すると、「クォータが必要」が自動的に有効になります**。同じ対象に対して、同時に有効にできるクォータは 1 件だけです。有効なクォータがある状態で再設定すると `400` が返されるため、先に古いクォータを無効化してください。
* **クォータを無効化しても、「クォータが必要」は無効になりません**：新しいクォータを設定するか、クォータ要件を解除するまで、対象は利用を制限されます。ロールと対話プラットフォームでは、それぞれの「クォータ要否の設定」API で解除します。メンバーの場合は、管理者が管理画面の「Credits → クォータ配分」で解除するか、[ロール単位でのクォータの一括無効化](#organizations-groups-batch-deactivate-credit-quota-create) に `removeQuotaRequirement: true` を指定して、ロールに所属するすべてのメンバーの要件を一括解除してください。無効化しても履歴は削除されません。無効化したクォータも「クォータ設定一覧」に表示され、`isActive` は `false` になります。
* クォータ設定のリクエストフィールド：`quotaLimit`（クォータ上限、必須）、`validFrom`（開始日時、必須）、`validUntil`（有効期限、任意。`validFrom` より後で、組織に入金された Credit のうち最も遅い有効期限を超えないこと）、`resetPeriod`（使用量のリセット周期：`none`、`daily`、`weekly`、`monthly`。デフォルトは `none`）、`note`（備考、任意）です。
* **日時形式**：リクエストの `validFrom` と `validUntil` には、`2026-12-31T23:59:59+08:00` などの ISO 8601 文字列を使用してください。日付のみ（`2026-12-31`）の場合は、台湾時間の当日 00:00 として扱われます。ミリ秒タイムスタンプ（例：`1798732799000`）は受け付けられず、`400` が返されます。レスポンスの日時フィールドは、13 桁のミリ秒タイムスタンプです。
* **新規メンバーのデフォルトクォータ**：新たに参加したメンバーに個人クォータを自動配分する設定を組織で行えます。[新規メンバーのデフォルトクォータ設定の取得](#credit-wallets-new-member-quota-policy-retrieve)を参照してください。招待時に、招待対象者ごとにクォータを指定することもできます。「組織とメンバー」の[メンバーを組織に招待](https://docs.maiagent.ai/api/api-reference/zu-zhi-he-cheng-yuan#auth-unified-invitations-create)を参照してください。
* パス内の ID：`memberPk` は[メンバーの現在のクォータ一覧の取得](#organizations-credit-quota-members-list)、`groupPk` は[ロールの現在のクォータ一覧の取得](#organizations-credit-quota-groups-list)、`inboxPk` は[対話プラットフォームの現在のクォータ一覧の取得](#organizations-credit-quota-inboxes-list)のレスポンス内の `id` から取得します。クォータ設定自体の `id` は、それぞれの「クォータ設定一覧」から取得します。

**権限と課金モード**

各 API の下に、必要な権限と課金モードの前提条件を記載しています。API キーは作成したメンバーとして呼び出しを行い、そのメンバーが所属するロールに基づいて権限が判定されます。次の 2 つの場合はリクエストが拒否され、HTTP 403 が返されます。

* **権限不足**：キーに紐づくメンバーのロールに、API に記載された権限（「Credit 管理権限」、「使用量統計権限」、または「組織概要権限」）がありません。組織管理者に依頼して、「組織設定 → ロール」でそのメンバーのロールに該当する権限を付与してください。
* **組織が Credit 課金モードではない**：「組織は Credit 課金モードである必要があります」と記載された API は、Credit 課金モードの組織のみ利用できます。`GET /api/v1/organizations/{id}/` を呼び出して確認できます。レスポンスの `organizationPlan.billingMode` が `credit` の場合、または組織にまだプランがなく `organizationPlan` が空の場合は、これらの API を利用できます。Credit 課金モードへの変更が必要な場合は、MaiAgent の担当者にお問い合わせください。

### Credit 残高の照会 <a href="#credit-wallets-list" id="credit-wallets-list"></a>

GET `/api/v1/credit/wallets/`

{% hint style="info" %}
**必要な権限**：Credit 管理権限。**課金モード**：制限はありません。どの課金モードの組織でも呼び出せます。
{% endhint %}

#### パラメータ

| パラメータ名     | 必須 | 型       | 説明                                             |
| ---------- | -- | ------- | ---------------------------------------------- |
| `page`     | ❌  | integer | A page number within the paginated result set. |
| `pageSize` | ❌  | integer | Number of results to return per page.          |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出し例 (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/credit/wallets/?page=1&pageSize=1" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/credit/wallets/?page=1&pageSize=1", config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/credit/wallets/?page=1&pageSize=1"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/credit/wallets/?page=1&pageSize=1", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンス内容

**ステータスコード: 200**

**レスポンス構造の例**

```typescript
{
  "count": integer
  "next"?: string (uri) // 任意
  "previous"?: string (uri) // 任意
  "results": [
    {
      "totalCredits": string (decimal)
      "autoTopup": object // Format auto-topup configuration.
      "balanceAlert": object // Format balance alert configuration.
      "nextGrant": object // Format the next grant, or None when nothing will actually be granted.

Amount-first: a missing/zero ``amount`` always wins over any schedule
(stale ``next_grant_at`` row, Stripe period_end with zero-grant plan),
so the frontend never receives a "scheduled in X days for 0 credits"
entry — the API decides whether the block renders at all.
      "lastGrant": object // Format the most recent PLAN_GRANT topup, or None when wallet has none.
      "consumptionHint": object // Return 7-day daily average consumption hint, or None if insufficient data.
      "billingProvider": string // Return the organization's billing provider so the Credit page can pick its card layout.
      "periodCreditGrant": string // Return current-period credit grant total; None unless AWS Marketplace billed.
      "periodMeteredUsage": string // Return current-period accepted metered usage; None unless AWS Marketplace billed.
    }
  ]
}
```

**レスポンス値の例**

```json
{
  "count": 123,
  "next": "http://api.example.org/accounts/?page=4",
  "previous": "http://api.example.org/accounts/?page=2",
  "results": [
    {
      "totalCredits": "レスポンス文字列",
      "autoTopup": {
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "name": "レスポンスの名前の例",
        "description": "レスポンスの説明の例"
      },
      "balanceAlert": {
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "name": "レスポンスの名前の例",
        "description": "レスポンスの説明の例"
      },
      "nextGrant": {
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "name": "レスポンスの名前の例",
        "description": "レスポンスの説明の例"
      },
      "lastGrant": {
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "name": "レスポンスの名前の例",
        "description": "レスポンスの説明の例"
      },
      "consumptionHint": {
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "name": "レスポンスの名前の例",
        "description": "レスポンスの説明の例"
      },
      "billingProvider": "レスポンス文字列",
      "periodCreditGrant": "レスポンス文字列",
      "periodMeteredUsage": "レスポンス文字列"
    }
  ]
}
```

***

### ウォレットの詳細取得 <a href="#credit-wallets-retrieve" id="credit-wallets-retrieve"></a>

GET `/api/v1/credit/wallets/{id}/`

{% hint style="info" %}
**必要な権限**：Credit 管理権限。**課金モード**：制限はありません。どの課金モードの組織でも呼び出せます。
{% endhint %}

#### パラメータ

| パラメータ名 | 必須 | 型      | 説明                                            |
| ------ | -- | ------ | --------------------------------------------- |
| `id`   | ✅  | string | A UUID string identifying this Credit Wallet. |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出し例 (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/credit/wallets/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/credit/wallets/550e8400-e29b-41d4-a716-446655440000/", config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/credit/wallets/550e8400-e29b-41d4-a716-446655440000/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/credit/wallets/550e8400-e29b-41d4-a716-446655440000/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンス内容

**ステータスコード: 200**

**レスポンス構造の例**

```typescript
{
  "totalCredits": string (decimal)
  "autoTopup": object // Format auto-topup configuration.
  "balanceAlert": object // Format balance alert configuration.
  "nextGrant": object // Format the next grant, or None when nothing will actually be granted.

Amount-first: a missing/zero ``amount`` always wins over any schedule
(stale ``next_grant_at`` row, Stripe period_end with zero-grant plan),
so the frontend never receives a "scheduled in X days for 0 credits"
entry — the API decides whether the block renders at all.
  "lastGrant": object // Format the most recent PLAN_GRANT topup, or None when wallet has none.
  "consumptionHint": object // Return 7-day daily average consumption hint, or None if insufficient data.
  "billingProvider": string // Return the organization's billing provider so the Credit page can pick its card layout.
  "periodCreditGrant": string // Return current-period credit grant total; None unless AWS Marketplace billed.
  "periodMeteredUsage": string // Return current-period accepted metered usage; None unless AWS Marketplace billed.
}
```

**レスポンス値の例**

```json
{
  "totalCredits": "レスポンス文字列",
  "autoTopup": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンスの名前の例",
    "description": "レスポンスの説明の例"
  },
  "balanceAlert": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンスの名前の例",
    "description": "レスポンスの説明の例"
  },
  "nextGrant": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンスの名前の例",
    "description": "レスポンスの説明の例"
  },
  "lastGrant": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンスの名前の例",
    "description": "レスポンスの説明の例"
  },
  "consumptionHint": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンスの名前の例",
    "description": "レスポンスの説明の例"
  },
  "billingProvider": "レスポンス文字列",
  "periodCreditGrant": "レスポンス文字列",
  "periodMeteredUsage": "レスポンス文字列"
}
```

***

### ウォレット残高の取得 <a href="#credit-wallets-balance-retrieve" id="credit-wallets-balance-retrieve"></a>

GET `/api/v1/credit/wallets/{id}/balance/`

{% hint style="info" %}
**必要な権限**：Credit 管理権限。**課金モード**：制限はありません。どの課金モードの組織でも呼び出せます。
{% endhint %}

#### パラメータ

| パラメータ名 | 必須 | 型      | 説明                                            |
| ------ | -- | ------ | --------------------------------------------- |
| `id`   | ✅  | string | A UUID string identifying this Credit Wallet. |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出し例 (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/credit/wallets/550e8400-e29b-41d4-a716-446655440000/balance/" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/credit/wallets/550e8400-e29b-41d4-a716-446655440000/balance/", config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/credit/wallets/550e8400-e29b-41d4-a716-446655440000/balance/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/credit/wallets/550e8400-e29b-41d4-a716-446655440000/balance/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンス内容

**ステータスコード: 200**

**レスポンス構造の例**

```typescript
{
  "totalCredits": string (decimal)
  "autoTopup": object // Format auto-topup configuration.
  "balanceAlert": object // Format balance alert configuration.
  "nextGrant": object // Format the next grant, or None when nothing will actually be granted.

Amount-first: a missing/zero ``amount`` always wins over any schedule
(stale ``next_grant_at`` row, Stripe period_end with zero-grant plan),
so the frontend never receives a "scheduled in X days for 0 credits"
entry — the API decides whether the block renders at all.
  "lastGrant": object // Format the most recent PLAN_GRANT topup, or None when wallet has none.
  "consumptionHint": object // Return 7-day daily average consumption hint, or None if insufficient data.
  "billingProvider": string // Return the organization's billing provider so the Credit page can pick its card layout.
  "periodCreditGrant": string // Return current-period credit grant total; None unless AWS Marketplace billed.
  "periodMeteredUsage": string // Return current-period accepted metered usage; None unless AWS Marketplace billed.
}
```

**レスポンス値の例**

```json
{
  "totalCredits": "レスポンス文字列",
  "autoTopup": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンスの名前の例",
    "description": "レスポンスの説明の例"
  },
  "balanceAlert": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンスの名前の例",
    "description": "レスポンスの説明の例"
  },
  "nextGrant": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンスの名前の例",
    "description": "レスポンスの説明の例"
  },
  "lastGrant": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンスの名前の例",
    "description": "レスポンスの説明の例"
  },
  "consumptionHint": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンスの名前の例",
    "description": "レスポンスの説明の例"
  },
  "billingProvider": "レスポンス文字列",
  "periodCreditGrant": "レスポンス文字列",
  "periodMeteredUsage": "レスポンス文字列"
}
```

***

### 有効期限が近い Credit の照会 <a href="#credit-wallets-expiring-credits-retrieve" id="credit-wallets-expiring-credits-retrieve"></a>

GET `/api/v1/credit/wallets/{id}/expiring-credits/`

{% hint style="info" %}
**必要な権限**：Credit 管理権限。**課金モード**：制限はありません。どの課金モードの組織でも呼び出せます。有効期限が設定された Credit のみ表示されます。有効期限のない Credit は結果に含まれないため、組織の全残高を表すものではありません。`days` パラメータで、何日以内に有効期限を迎える Credit を照会するかを指定します（デフォルトは 30 です。`all` を渡すと、有効期限が設定されたすべての Credit が表示されます）。
{% endhint %}

#### パラメータ

| パラメータ名 | 必須 | 型      | 説明                                            |
| ------ | -- | ------ | --------------------------------------------- |
| `id`   | ✅  | string | A UUID string identifying this Credit Wallet. |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出し例 (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/credit/wallets/550e8400-e29b-41d4-a716-446655440000/expiring-credits/" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/credit/wallets/550e8400-e29b-41d4-a716-446655440000/expiring-credits/", config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/credit/wallets/550e8400-e29b-41d4-a716-446655440000/expiring-credits/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/credit/wallets/550e8400-e29b-41d4-a716-446655440000/expiring-credits/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンス内容

**ステータスコード: 200**

**レスポンス構造の例**

```typescript
{
  "totalCredits": string (decimal)
  "autoTopup": object // Format auto-topup configuration.
  "balanceAlert": object // Format balance alert configuration.
  "nextGrant": object // Format the next grant, or None when nothing will actually be granted.

Amount-first: a missing/zero ``amount`` always wins over any schedule
(stale ``next_grant_at`` row, Stripe period_end with zero-grant plan),
so the frontend never receives a "scheduled in X days for 0 credits"
entry — the API decides whether the block renders at all.
  "lastGrant": object // Format the most recent PLAN_GRANT topup, or None when wallet has none.
  "consumptionHint": object // Return 7-day daily average consumption hint, or None if insufficient data.
  "billingProvider": string // Return the organization's billing provider so the Credit page can pick its card layout.
  "periodCreditGrant": string // Return current-period credit grant total; None unless AWS Marketplace billed.
  "periodMeteredUsage": string // Return current-period accepted metered usage; None unless AWS Marketplace billed.
}
```

**レスポンス値の例**

```json
{
  "totalCredits": "レスポンス文字列",
  "autoTopup": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンスの名前の例",
    "description": "レスポンスの説明の例"
  },
  "balanceAlert": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンスの名前の例",
    "description": "レスポンスの説明の例"
  },
  "nextGrant": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンスの名前の例",
    "description": "レスポンスの説明の例"
  },
  "lastGrant": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンスの名前の例",
    "description": "レスポンスの説明の例"
  },
  "consumptionHint": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンスの名前の例",
    "description": "レスポンスの説明の例"
  },
  "billingProvider": "レスポンス文字列",
  "periodCreditGrant": "レスポンス文字列",
  "periodMeteredUsage": "レスポンス文字列"
}
```

***

### チャージ履歴の照会 <a href="#credit-wallets-topup-history-retrieve" id="credit-wallets-topup-history-retrieve"></a>

GET `/api/v1/credit/wallets/{id}/topup-history/`

{% hint style="info" %}
**必要な権限**：Credit 管理権限。**課金モード**：制限はありません。どの課金モードの組織でも呼び出せます。
{% endhint %}

#### パラメータ

| パラメータ名 | 必須 | 型      | 説明                                            |
| ------ | -- | ------ | --------------------------------------------- |
| `id`   | ✅  | string | A UUID string identifying this Credit Wallet. |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出しの例 (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/credit/wallets/550e8400-e29b-41d4-a716-446655440000/topup-history/" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/credit/wallets/550e8400-e29b-41d4-a716-446655440000/topup-history/", config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/credit/wallets/550e8400-e29b-41d4-a716-446655440000/topup-history/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/credit/wallets/550e8400-e29b-41d4-a716-446655440000/topup-history/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンス内容

**ステータスコード: 200**

**レスポンス構造の例**

```typescript
{
  "totalCredits": string (decimal)
  "autoTopup": object // Format auto-topup configuration.
  "balanceAlert": object // Format balance alert configuration.
  "nextGrant": object // Format the next grant, or None when nothing will actually be granted.

Amount-first: a missing/zero ``amount`` always wins over any schedule
(stale ``next_grant_at`` row, Stripe period_end with zero-grant plan),
so the frontend never receives a "scheduled in X days for 0 credits"
entry — the API decides whether the block renders at all.
  "lastGrant": object // Format the most recent PLAN_GRANT topup, or None when wallet has none.
  "consumptionHint": object // Return 7-day daily average consumption hint, or None if insufficient data.
  "billingProvider": string // Return the organization's billing provider so the Credit page can pick its card layout.
  "periodCreditGrant": string // Return current-period credit grant total; None unless AWS Marketplace billed.
  "periodMeteredUsage": string // Return current-period accepted metered usage; None unless AWS Marketplace billed.
}
```

**レスポンス値の例**

```json
{
  "totalCredits": "レスポンス文字列",
  "autoTopup": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンスのサンプル名",
    "description": "レスポンスのサンプル説明"
  },
  "balanceAlert": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンスのサンプル名",
    "description": "レスポンスのサンプル説明"
  },
  "nextGrant": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンスのサンプル名",
    "description": "レスポンスのサンプル説明"
  },
  "lastGrant": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンスのサンプル名",
    "description": "レスポンスのサンプル説明"
  },
  "consumptionHint": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンスのサンプル名",
    "description": "レスポンスのサンプル説明"
  },
  "billingProvider": "レスポンス文字列",
  "periodCreditGrant": "レスポンス文字列",
  "periodMeteredUsage": "レスポンス文字列"
}
```

***

### 使用明細の一覧を取得 <a href="#credit-transactions-list" id="credit-transactions-list"></a>

GET `/api/v1/credit/transactions/`

{% hint style="info" %}
**必要な権限**：Credit 管理権限。**課金方式**：制限はありません。どの課金方式の組織でも呼び出せます。
{% endhint %}

#### パラメータ

| パラメータ名     | 必須 | 型       | 説明                                             |
| ---------- | -- | ------- | ---------------------------------------------- |
| `page`     | ❌  | integer | A page number within the paginated result set. |
| `pageSize` | ❌  | integer | Number of results to return per page.          |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出し例 (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/credit/transactions/?page=1&pageSize=1" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/credit/transactions/?page=1&pageSize=1", config)
  .then(response => {
    console.log('レスポンスを取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストエラー:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/credit/transactions/?page=1&pageSize=1"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("レスポンスを取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストエラー:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/credit/transactions/?page=1&pageSize=1", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストエラー: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンス内容

**ステータスコード: 200**

**レスポンススキーマの例**

```typescript
{
  "count": integer
  "next"?: string (uri) // 省略可能
  "previous"?: string (uri) // 省略可能
  "results": [
    {
      "id": string (uuid)
      "eventDatetime": string (timestamp)
      "createdAt": string (timestamp)
      "transactionType": string
      "creditItem": object
      "amount": string (decimal)
      "balanceAfter": string (decimal)
      "quantity": string (decimal)
      "provider": string
      "modelCode": string
      "unitPriceSnapshot": string (decimal)
      "member": object
      "description": string
      "metadata": object
      "parserName": string
      "quantityUnit": string
      "targetObject": object // Return frontend deep-link target for this transaction's GFK content.

``{kind: 'chat.message', objectId, chatbotId}`` opens the AgentOps record modal;
``{kind: 'dataset.evaluation', objectId, isMultiTurn}`` opens the evaluation results page.
Returns None when no GFK is attached, the content type is unsupported,
or the target no longer resolves inside this organization.
    }
  ]
}
```

**レスポンスの値の例**

```json
{
  "count": 123,
  "next": "http://api.example.org/accounts/?page=4",
  "previous": "http://api.example.org/accounts/?page=2",
  "results": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "eventDatetime": "レスポンス文字列",
      "createdAt": "レスポンス文字列",
      "transactionType": "レスポンス文字列",
      "creditItem": {
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "name": "レスポンスの名前の例",
        "description": "レスポンスの説明の例"
      },
      "amount": "レスポンス文字列",
      "balanceAfter": "レスポンス文字列",
      "quantity": "レスポンス文字列",
      "provider": "レスポンス文字列",
      "modelCode": "レスポンス文字列",
      "unitPriceSnapshot": "レスポンス文字列",
      "member": {
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "name": "レスポンスの名前の例",
        "description": "レスポンスの説明の例"
      },
      "description": "レスポンス文字列",
      "metadata": null,
      "parserName": "レスポンス文字列",
      "quantityUnit": "レスポンス文字列",
      "targetObject": {
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "name": "レスポンスの名前の例",
        "description": "レスポンスの説明の例"
      }
    }
  ]
}
```

***

### 個別の使用明細を取得 <a href="#credit-transactions-retrieve" id="credit-transactions-retrieve"></a>

GET `/api/v1/credit/transactions/{id}/`

{% hint style="info" %}
**必要な権限**：Credit 管理権限。**課金方式**：制限はありません。どの課金方式の組織でも呼び出せます。
{% endhint %}

#### パラメータ

| パラメータ名 | 必須 | 型      | 説明                                                 |
| ------ | -- | ------ | -------------------------------------------------- |
| `id`   | ✅  | string | A UUID string identifying this Credit Transaction. |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出し例 (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/credit/transactions/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/credit/transactions/550e8400-e29b-41d4-a716-446655440000/", config)
  .then(response => {
    console.log('レスポンスを取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストエラー:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/credit/transactions/550e8400-e29b-41d4-a716-446655440000/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("レスポンスを取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストエラー:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/credit/transactions/550e8400-e29b-41d4-a716-446655440000/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストエラー: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンス内容

**ステータスコード: 200**

**レスポンススキーマの例**

```typescript
{
  "id": string (uuid)
  "eventDatetime": string (timestamp)
  "createdAt": string (timestamp)
  "transactionType": string
  "creditItem": object
  "amount": string (decimal)
  "balanceAfter": string (decimal)
  "quantity": string (decimal)
  "provider": string
  "modelCode": string
  "unitPriceSnapshot": string (decimal)
  "member": object
  "description": string
  "metadata": object
  "parserName": string
  "quantityUnit": string
  "targetObject": object // Return frontend deep-link target for this transaction's GFK content.

``{kind: 'chat.message', objectId, chatbotId}`` opens the AgentOps record modal;
``{kind: 'dataset.evaluation', objectId, isMultiTurn}`` opens the evaluation results page.
Returns None when no GFK is attached, the content type is unsupported,
or the target no longer resolves inside this organization.
}
```

**レスポンスの値の例**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "eventDatetime": "レスポンス文字列",
  "createdAt": "レスポンス文字列",
  "transactionType": "レスポンス文字列",
  "creditItem": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンスの名前の例",
    "description": "レスポンスの説明の例"
  },
  "amount": "レスポンス文字列",
  "balanceAfter": "レスポンス文字列",
  "quantity": "レスポンス文字列",
  "provider": "レスポンス文字列",
  "modelCode": "レスポンス文字列",
  "unitPriceSnapshot": "レスポンス文字列",
  "member": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンスの名前の例",
    "description": "レスポンスの説明の例"
  },
  "description": "レスポンス文字列",
  "metadata": null,
  "parserName": "レスポンス文字列",
  "quantityUnit": "レスポンス文字列",
  "targetObject": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンスの名前の例",
    "description": "レスポンスの説明の例"
  }
}
```

***

### 使用履歴を照会 <a href="#credit-transactions-history-retrieve" id="credit-transactions-history-retrieve"></a>

GET `/api/v1/credit/transactions/history/`

{% hint style="info" %}
**必要な権限**：Credit 管理権限。**課金方式**：制限はありません。どの課金方式の組織でも呼び出せます。
{% endhint %}

#### パラメータ

| パラメータ名      | 必須 | 型       | 説明                                                                                                                                 |
| ----------- | -- | ------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| `category`  | ❌  | string  | Credit item category (e.g. llm\_token, platform\_fee); agent\_memory selects the AI memory lines, which llm\_token then leaves out |
| `endDate`   | ❌  | string  | End date (inclusive, whole day in the platform timezone Asia/Taipei), format: YYYY-MM-DD                                           |
| `limit`     | ❌  | integer | Rows per page, capped at 100                                                                                                       |
| `page`      | ❌  | integer | 1-based page number                                                                                                                |
| `search`    | ❌  | string  | Case-insensitive match against transaction description and metadata                                                                |
| `startDate` | ❌  | string  | Start date (inclusive, whole day in the platform timezone Asia/Taipei), format: YYYY-MM-DD                                         |
| `type`      | ❌  | string  | Which rows to include: all ledger entries, consumption only, or credited only                                                      |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出し例 (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/credit/transactions/history/?category=example&endDate=example&limit=1&page=1&search=example&startDate=example&type=all" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/credit/transactions/history/?category=example&endDate=example&limit=1&page=1&search=example&startDate=example&type=all", config)
  .then(response => {
    console.log('レスポンスを取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストエラー:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/credit/transactions/history/?category=example&endDate=example&limit=1&page=1&search=example&startDate=example&type=all"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("レスポンスを取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストエラー:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/credit/transactions/history/?category=example&endDate=example&limit=1&page=1&search=example&startDate=example&type=all", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストエラー: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンス内容

**ステータスコード: 200**

**レスポンススキーマの例**

```typescript
{
  "id": string (uuid)
  "eventDatetime": string (timestamp)
  "createdAt": string (timestamp)
  "transactionType": string
  "creditItem": object
  "amount": string (decimal)
  "balanceAfter": string (decimal)
  "quantity": string (decimal)
  "provider": string
  "modelCode": string
  "unitPriceSnapshot": string (decimal)
  "member": object
  "description": string
  "metadata": object
  "parserName": string
  "quantityUnit": string
  "targetObject": object // Return frontend deep-link target for this transaction's GFK content.

``{kind: 'chat.message', objectId, chatbotId}`` opens the AgentOps record modal;
``{kind: 'dataset.evaluation', objectId, isMultiTurn}`` opens the evaluation results page.
Returns None when no GFK is attached, the content type is unsupported,
or the target no longer resolves inside this organization.
}
```

**レスポンスの値の例**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "eventDatetime": "レスポンス文字列",
  "createdAt": "レスポンス文字列",
  "transactionType": "レスポンス文字列",
  "creditItem": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンスの名前の例",
    "description": "レスポンスの説明の例"
  },
  "amount": "レスポンス文字列",
  "balanceAfter": "レスポンス文字列",
  "quantity": "レスポンス文字列",
  "provider": "レスポンス文字列",
  "modelCode": "レスポンス文字列",
  "unitPriceSnapshot": "レスポンス文字列",
  "member": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンスの名前の例",
    "description": "レスポンスの説明の例"
  },
  "description": "レスポンス文字列",
  "metadata": null,
  "parserName": "レスポンス文字列",
  "quantityUnit": "レスポンス文字列",
  "targetObject": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンスの名前の例",
    "description": "レスポンスの説明の例"
  }
}
```

***

### 消費合計の照会 <a href="#credit-transactions-history-summary-retrieve" id="credit-transactions-history-summary-retrieve"></a>

GET `/api/v1/credit/transactions/history-summary/`

{% hint style="info" %}
**必要な権限**：Credit 管理権限。**課金モード**：制限はありません。どの課金モードの組織でも呼び出せます。
{% endhint %}

#### パラメータ

| パラメータ名      | 必須 | 型      | 説明                                                                                                          |
| ----------- | -- | ------ | ----------------------------------------------------------------------------------------------------------- |
| `category`  | ❌  | string | Credit 項目のカテゴリ（例：llm\_token、platform\_fee）。agent\_memory を指定すると AI メモリ関連の明細が対象となり、その場合 llm\_token からは除外されます |
| `endDate`   | ❌  | string | 終了日（その日を含む、プラットフォームのタイムゾーン Asia/Taipei で丸一日）、形式：YYYY-MM-DD                                                  |
| `search`    | ❌  | string | 取引の説明とメタデータに対して大文字小文字を区別せずに照合します                                                                            |
| `startDate` | ❌  | string | 開始日（その日を含む、プラットフォームのタイムゾーン Asia/Taipei で丸一日）、形式：YYYY-MM-DD                                                  |
| `type`      | ❌  | string | 対象とする明細：すべての台帳エントリ、消費のみ、または付与のみ                                                                             |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出し例 (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/credit/transactions/history-summary/?category=example&endDate=example&search=example&startDate=example&type=all" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/credit/transactions/history-summary/?category=example&endDate=example&search=example&startDate=example&type=all", config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/credit/transactions/history-summary/?category=example&endDate=example&search=example&startDate=example&type=all"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/credit/transactions/history-summary/?category=example&endDate=example&search=example&startDate=example&type=all", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンス内容

**ステータスコード: 200**

**レスポンス構造の例**

```typescript
{
  "consumedTotal": string (decimal)
  "creditedTotal": string (decimal)
  "count": integer
}
```

**レスポンス値の例**

```json
{
  "consumedTotal": "レスポンス文字列",
  "creditedTotal": "レスポンス文字列",
  "count": 456
}
```

***

### カテゴリ別の Credit 使用量の照会 <a href="#organizations-usage-statistics-credit-categories-list" id="organizations-usage-statistics-credit-categories-list"></a>

GET `/api/v1/organizations/{organizationPk}/usage-statistics/credit-categories/`

{% hint style="info" %}
**必要な権限**：使用量統計の権限。**課金方式**：組織は Credit 課金方式を使用している必要があります。
{% endhint %}

#### パラメータ

| パラメータ名            | 必須 | 型       | 説明                                             |
| ----------------- | -- | ------- | ---------------------------------------------- |
| `organizationPk`  | ✅  | string  | A UUID string identifying this 組織 ID           |
| `endDate`         | ❌  | string  | End date, format: YYYY-MM-DD                   |
| `page`            | ❌  | integer | A page number within the paginated result set. |
| `pageSize`        | ❌  | integer | Number of results to return per page.          |
| `startDate`       | ✅  | string  | Start date, format: YYYY-MM-DD                 |
| `timeGranularity` | ❌  | string  | Time granularity (hour/day/month)              |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出し例 (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/usage-statistics/credit-categories/?endDate=example&page=1&pageSize=1&startDate=example&timeGranularity=day" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/usage-statistics/credit-categories/?endDate=example&page=1&pageSize=1&startDate=example&timeGranularity=day", config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/usage-statistics/credit-categories/?endDate=example&page=1&pageSize=1&startDate=example&timeGranularity=day"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/usage-statistics/credit-categories/?endDate=example&page=1&pageSize=1&startDate=example&timeGranularity=day", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンス内容

**ステータスコード: 200**

**レスポンススキーマ例**

```typescript
{
  "count": integer
  "next"?: string (uri) // 任意
  "previous"?: string (uri) // 任意
  "results": [
    object
  ]
}
```

**レスポンスのサンプル値**

```json
{
  "count": 123,
  "next": "http://api.example.org/accounts/?page=4",
  "previous": "http://api.example.org/accounts/?page=2",
  "results": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "レスポンスのサンプル名",
      "description": "レスポンスのサンプル説明"
    }
  ]
}
```

***

### 単一カテゴリの Credit 使用量を取得 <a href="#organizations-usage-statistics-credit-categories-retrieve" id="organizations-usage-statistics-credit-categories-retrieve"></a>

GET `/api/v1/organizations/{organizationPk}/usage-statistics/credit-categories/{id}/`

{% hint style="info" %}
**必要な権限**：使用量統計の権限。**課金方式**：組織は Credit 課金方式を使用している必要があります。
{% endhint %}

#### パラメータ

| パラメータ名            | 必須 | 型      | 説明                                   |
| ----------------- | -- | ------ | ------------------------------------ |
| `id`              | ✅  | string |                                      |
| `organizationPk`  | ✅  | string | A UUID string identifying this 組織 ID |
| `endDate`         | ❌  | string | End date, format: YYYY-MM-DD         |
| `startDate`       | ✅  | string | Start date, format: YYYY-MM-DD       |
| `timeGranularity` | ❌  | string | Time granularity (hour/day/month)    |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出し例 (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/usage-statistics/credit-categories/550e8400-e29b-41d4-a716-446655440000/?endDate=example&startDate=example&timeGranularity=day" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/usage-statistics/credit-categories/550e8400-e29b-41d4-a716-446655440000/?endDate=example&startDate=example&timeGranularity=day", config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/usage-statistics/credit-categories/550e8400-e29b-41d4-a716-446655440000/?endDate=example&startDate=example&timeGranularity=day"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/usage-statistics/credit-categories/550e8400-e29b-41d4-a716-446655440000/?endDate=example&startDate=example&timeGranularity=day", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンス内容

**ステータスコード: 200**

**レスポンススキーマ例**

```typescript
object
```

**レスポンスのサンプル値**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "name": "レスポンスのサンプル名",
  "description": "レスポンスのサンプル説明"
}
```

***

### 課金項目のメンバー使用量を取得 <a href="#organizations-usage-statistics-credit-categories-members-list" id="organizations-usage-statistics-credit-categories-members-list"></a>

GET `/api/v1/organizations/{organizationPk}/usage-statistics/credit-categories/{itemPk}/members/`

{% hint style="info" %}
**必要な権限**：使用量統計の権限。**課金方式**：組織は Credit 課金方式を使用している必要があります。
{% endhint %}

#### パラメータ

| パラメータ名            | 必須 | 型       | 説明                                             |
| ----------------- | -- | ------- | ---------------------------------------------- |
| `itemPk`          | ✅  | string  |                                                |
| `organizationPk`  | ✅  | string  | A UUID string identifying this 組織 ID           |
| `endDate`         | ❌  | string  | End date, format: YYYY-MM-DD                   |
| `page`            | ❌  | integer | A page number within the paginated result set. |
| `pageSize`        | ❌  | integer | Number of results to return per page.          |
| `startDate`       | ✅  | string  | Start date, format: YYYY-MM-DD                 |
| `timeGranularity` | ❌  | string  | Time granularity (hour/day/month)              |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出し例 (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/usage-statistics/credit-categories/{itemPk}/members/?endDate=example&page=1&pageSize=1&startDate=example&timeGranularity=day" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/usage-statistics/credit-categories/{itemPk}/members/?endDate=example&page=1&pageSize=1&startDate=example&timeGranularity=day", config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/usage-statistics/credit-categories/{itemPk}/members/?endDate=example&page=1&pageSize=1&startDate=example&timeGranularity=day"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/usage-statistics/credit-categories/{itemPk}/members/?endDate=example&page=1&pageSize=1&startDate=example&timeGranularity=day", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンス内容

**ステータスコード: 200**

**レスポンススキーマ例**

```typescript
{
  "count": integer
  "next"?: string (uri) // 任意
  "previous"?: string (uri) // 任意
  "results": [
    object
  ]
}
```

**レスポンスのサンプル値**

```json
{
  "count": 123,
  "next": "http://api.example.org/accounts/?page=4",
  "previous": "http://api.example.org/accounts/?page=2",
  "results": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "レスポンスのサンプル名",
      "description": "レスポンスのサンプル説明"
    }
  ]
}
```

***

### 単一メンバーの課金項目使用量を取得 <a href="#organizations-usage-statistics-credit-categories-members-retrieve" id="organizations-usage-statistics-credit-categories-members-retrieve"></a>

GET `/api/v1/organizations/{organizationPk}/usage-statistics/credit-categories/{itemPk}/members/{id}/`

{% hint style="info" %}
**必要な権限**：使用量統計の権限。**課金方式**：組織は Credit 課金方式を使用している必要があります。
{% endhint %}

#### パラメータ

| パラメータ名            | 必須 | 型      | 説明                                   |
| ----------------- | -- | ------ | ------------------------------------ |
| `id`              | ✅  | string |                                      |
| `itemPk`          | ✅  | string |                                      |
| `organizationPk`  | ✅  | string | A UUID string identifying this 組織 ID |
| `endDate`         | ❌  | string | End date, format: YYYY-MM-DD         |
| `startDate`       | ✅  | string | Start date, format: YYYY-MM-DD       |
| `timeGranularity` | ❌  | string | Time granularity (hour/day/month)    |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出し例 (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/usage-statistics/credit-categories/{itemPk}/members/550e8400-e29b-41d4-a716-446655440000/?endDate=example&startDate=example&timeGranularity=day" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/usage-statistics/credit-categories/{itemPk}/members/550e8400-e29b-41d4-a716-446655440000/?endDate=example&startDate=example&timeGranularity=day", config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/usage-statistics/credit-categories/{itemPk}/members/550e8400-e29b-41d4-a716-446655440000/?endDate=example&startDate=example&timeGranularity=day"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/usage-statistics/credit-categories/{itemPk}/members/550e8400-e29b-41d4-a716-446655440000/?endDate=example&startDate=example&timeGranularity=day", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンス内容

**ステータスコード: 200**

**レスポンススキーマ例**

```typescript
object
```

**レスポンスのサンプル値**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "name": "レスポンスのサンプル名",
  "description": "レスポンスのサンプル説明"
}
```

***

### 新規メンバーのデフォルトクォータ設定を取得 <a href="#credit-wallets-new-member-quota-policy-retrieve" id="credit-wallets-new-member-quota-policy-retrieve"></a>

GET `/api/v1/credit/wallets/{id}/new-member-quota-policy/`

{% hint style="info" %}
**必要な権限**：Credit 管理権限。**課金モード**：制限はありません。パスの `id` はウォレット ID（`GET /api/v1/organizations/{id}/` のレスポンスに含まれる `creditWallet.id`）です。レスポンスのフィールドは、`newMemberQuotaEnabled`（自動割り当ての有効・無効）、`newMemberQuotaLimit`（クォータの上限）、`newMemberQuotaValidDays`（参加日からの有効日数。`null` は無期限）、`newMemberQuotaResetPeriod`（使用量のリセット周期）、`newMemberQuotaNote`（備考）、`requireQuotaBeforeConsumption`（新規メンバーにクォータがない場合に利用をブロックするかどうか）です。
{% endhint %}

#### パラメーター

| パラメーター名 | 必須 | 型      | 説明                                            |
| ------- | -- | ------ | --------------------------------------------- |
| `id`    | ✅  | string | A UUID string identifying this Credit Wallet. |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出し例 (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/credit/wallets/550e8400-e29b-41d4-a716-446655440000/new-member-quota-policy/" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/credit/wallets/550e8400-e29b-41d4-a716-446655440000/new-member-quota-policy/", config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストエラー:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/credit/wallets/550e8400-e29b-41d4-a716-446655440000/new-member-quota-policy/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストエラー:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/credit/wallets/550e8400-e29b-41d4-a716-446655440000/new-member-quota-policy/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストエラー: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンスボディ

**ステータスコード: 200**

**レスポンススキーマの例**

```typescript
{
  "newMemberQuotaEnabled"?: boolean // 省略可能
  "newMemberQuotaLimit"?: string (decimal) // 省略可能
  "newMemberQuotaValidDays"?: integer // 省略可能
  "newMemberQuotaResetPeriod"?: string (enum: none, daily, weekly, monthly) // * `none` - No Reset
* `daily` - Daily
* `weekly` - Weekly
* `monthly` - Monthly (省略可能)
  "newMemberQuotaNote"?: string // 省略可能
  "requireQuotaBeforeConsumption"?: boolean // 省略可能
}
```

**レスポンス値の例**

```json
{
  "newMemberQuotaEnabled": false,
  "newMemberQuotaLimit": "レスポンス文字列",
  "newMemberQuotaValidDays": 456,
  "newMemberQuotaResetPeriod": "none",
  "newMemberQuotaNote": "レスポンス文字列",
  "requireQuotaBeforeConsumption": false
}
```

***

### 新規メンバーのデフォルトクォータ設定を更新 <a href="#credit-wallets-new-member-quota-policy-partial-update" id="credit-wallets-new-member-quota-policy-partial-update"></a>

PATCH `/api/v1/credit/wallets/{id}/new-member-quota-policy/`

{% hint style="info" %}
**必要な権限**：Credit 管理権限。**課金モード**：組織が Credit 課金モードである必要があります。それ以外の場合は `400` を返します。変更するフィールドだけを送信してください。フィールドは設定取得時と同じです。`newMemberQuotaLimit` は負の値にできず、`newMemberQuotaEnabled` を有効にする場合は値が必須です。`newMemberQuotaValidDays` は 1～3650 または `null` を指定します。有効にすると、その後に招待、ディレクトリ同期、SSO、インポートで参加する新規メンバーに、参加時点から有効な個人クォータが自動的に割り当てられます。有効日数を設定する場合、有効期限は組織に最後に入金されたクォータの有効期限を超えません（`null` は無期限です）。招待時に `creditQuota` を指定した場合は、招待で指定したクォータが優先されます（指定したクォータが期限切れの場合や割り当てに失敗した場合は、このデフォルト設定を適用します）。`requireQuotaBeforeConsumption` を有効にすると、クォータを受け取っていない新規メンバーは、クォータが割り当てられるまで Credit を消費する機能を利用できません。設定を変更しても、割り当て済みのクォータや既存メンバーには影響しません。レスポンスには `message` と `config`（更新後の設定）が含まれます。
{% endhint %}

#### パラメーター

| パラメーター名 | 必須 | 型      | 説明                                            |
| ------- | -- | ------ | --------------------------------------------- |
| `id`    | ✅  | string | A UUID string identifying this Credit Wallet. |

#### リクエストボディ

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

| フィールド                         | 型                                           | 必須  | 説明                                                                         |
| ----------------------------- | ------------------------------------------- | --- | -------------------------------------------------------------------------- |
| newMemberQuotaEnabled         | boolean                                     | いいえ |                                                                            |
| newMemberQuotaLimit           | string (decimal)                            | いいえ |                                                                            |
| newMemberQuotaValidDays       | integer                                     | いいえ |                                                                            |
| newMemberQuotaResetPeriod     | string (enum: none, daily, weekly, monthly) | いいえ | `none`: No Reset ; `daily`: Daily ; `weekly`: Weekly ; `monthly`: Monthly; |
| newMemberQuotaNote            | string                                      | いいえ |                                                                            |
| requireQuotaBeforeConsumption | boolean                                     | いいえ |                                                                            |

**リクエストスキーマの例**

```typescript
{
  "newMemberQuotaEnabled"?: boolean // 省略可能
  "newMemberQuotaLimit"?: string (decimal) // 省略可能
  "newMemberQuotaValidDays"?: integer // 省略可能
  "newMemberQuotaResetPeriod"?: string (enum: none, daily, weekly, monthly) // * `none` - No Reset
* `daily` - Daily
* `weekly` - Weekly
* `monthly` - Monthly (省略可能)
  "newMemberQuotaNote"?: string // 省略可能
  "requireQuotaBeforeConsumption"?: boolean // 省略可能
}
```

**リクエスト値の例**

```json
{
  "newMemberQuotaEnabled": true,
  "newMemberQuotaLimit": "100",
  "newMemberQuotaValidDays": 30,
  "newMemberQuotaResetPeriod": "none",
  "requireQuotaBeforeConsumption": false
}
```

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出し例 (Shell)
curl -X PATCH "https://api.maiagent.ai/api/v1/credit/wallets/550e8400-e29b-41d4-a716-446655440000/new-member-quota-policy/" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "newMemberQuotaEnabled": true,
    "newMemberQuotaLimit": "100",
    "newMemberQuotaValidDays": 30,
    "newMemberQuotaResetPeriod": "none",
    "requireQuotaBeforeConsumption": false
  }'

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
};

// リクエストボディ (payload)
const data = {
    "newMemberQuotaEnabled": true,
    "newMemberQuotaLimit": "100",
    "newMemberQuotaValidDays": 30,
    "newMemberQuotaResetPeriod": "none",
    "requireQuotaBeforeConsumption": false
  };

axios.patch("https://api.maiagent.ai/api/v1/credit/wallets/550e8400-e29b-41d4-a716-446655440000/new-member-quota-policy/", data, config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストエラー:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/credit/wallets/550e8400-e29b-41d4-a716-446655440000/new-member-quota-policy/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY",
    "Content-Type": "application/json"
}

# リクエストボディ (payload)
data = {
    "newMemberQuotaEnabled": True,
    "newMemberQuotaLimit": "100",
    "newMemberQuotaValidDays": 30,
    "newMemberQuotaResetPeriod": "none",
    "requireQuotaBeforeConsumption": False
}

response = requests.patch(url, json=data, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストエラー:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->patch("https://api.maiagent.ai/api/v1/credit/wallets/550e8400-e29b-41d4-a716-446655440000/new-member-quota-policy/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY',
            'Content-Type' => 'application/json'
        ],
        'json' => [
            'newMemberQuotaEnabled' => true,
            'newMemberQuotaLimit' => '100',
            'newMemberQuotaValidDays' => 30,
            'newMemberQuotaResetPeriod' => 'none',
            'requireQuotaBeforeConsumption' => false
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストエラー: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンスボディ

**ステータスコード: 200**

**レスポンススキーマの例**

```typescript
{
  "message": string
  "config": { // Organization-level policy for new members: default personal quota plus the consumption guardrail.
  {
    "newMemberQuotaEnabled"?: boolean // 省略可能
    "newMemberQuotaLimit"?: string (decimal) // 省略可能
    "newMemberQuotaValidDays"?: integer // 省略可能
    "newMemberQuotaResetPeriod"?: string (enum: none, daily, weekly, monthly) // * `none` - No Reset
* `daily` - Daily
* `weekly` - Weekly
* `monthly` - Monthly (省略可能)
    "newMemberQuotaNote"?: string // 省略可能
    "requireQuotaBeforeConsumption"?: boolean // 省略可能
  }
  }
}
```

**レスポンス値の例**

```json
{
  "message": "レスポンス文字列",
  "config": {
    "newMemberQuotaEnabled": false,
    "newMemberQuotaLimit": "レスポンス文字列",
    "newMemberQuotaValidDays": 456,
    "newMemberQuotaResetPeriod": "none",
    "newMemberQuotaNote": "レスポンス文字列",
    "requireQuotaBeforeConsumption": false
  }
}
```

**ステータスコード: 400 - Validation failed, or the organization is not on credit billing.**

***

### メンバーの現在のクォータを一覧表示 <a href="#organizations-credit-quota-members-list" id="organizations-credit-quota-members-list"></a>

GET `/api/v1/organizations/{organizationPk}/credit-quota-members/`

{% hint style="info" %}
**必要な権限**：Credit 管理権限。**課金方式**：組織は Credit 課金方式を使用している必要があります。
{% endhint %}

#### パラメータ

| パラメータ名           | 必須 | 型       | 説明                                                                      |
| ---------------- | -- | ------- | ----------------------------------------------------------------------- |
| `organizationPk` | ✅  | string  | A UUID string identifying this 組織 ID                                    |
| `ordering`       | ❌  | string  | Sort field (default '-created\_at')                                     |
| `page`           | ❌  | integer | Page number                                                             |
| `pageSize`       | ❌  | integer | Rows per page (max 100)                                                 |
| `quotaStatus`    | ❌  | string  | Filter by quota status                                                  |
| `search`         | ❌  | string  | Filter by member name, email, or member ID (case-insensitive substring) |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出し例 (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/credit-quota-members/?ordering=-created_at&page=1&pageSize=1&quotaStatus=allocated&search=example" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/credit-quota-members/?ordering=-created_at&page=1&pageSize=1&quotaStatus=allocated&search=example", config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/credit-quota-members/?ordering=-created_at&page=1&pageSize=1&quotaStatus=allocated&search=example"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/credit-quota-members/?ordering=-created_at&page=1&pageSize=1&quotaStatus=allocated&search=example", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンス内容

**ステータスコード: 200**

**レスポンススキーマ例**

```typescript
{
  "count": integer
  "next"?: string (uri) // 任意
  "previous"?: string (uri) // 任意
  "results": [
    {
      "count"?: integer // 任意
      "next"?: string (uri) // 任意
      "previous"?: string (uri) // 任意
      "results"?: [ // 任意
        {
          "id"?: string (uuid) // 任意
          "name"?: string // 任意
          "email"?: string // 任意
          "credit_quota_required"?: boolean // 任意
          "active_quota"?: { // Most recent quota summary (active first); same shape as the members API active_quota. (任意)
          {
            "id"?: string (uuid) // 任意
            "quota_limit"?: string // 任意
            "consumed_amount"?: string // 任意
            "remaining"?: string // 任意
            "valid_from"?: string (date-time) // 任意
            "valid_until"?: string (date-time) // 任意
            "is_active"?: boolean // 任意
            "expired_at"?: string (date-time) // 任意
            "note"?: string // 任意
          }
          }
        }
      ]
      "stats"?: { // Organization-wide member counts, unaffected by search or quota_status filter. (任意)
      {
        "total"?: integer // 任意
        "allocated"?: integer // 任意
        "expired"?: integer // 任意
        "unallocated"?: integer // 任意
      }
      }
    }
  ]
}
```

**レスポンスのサンプル値**

```json
{
  "count": 123,
  "next": "http://api.example.org/accounts/?page=4",
  "previous": "http://api.example.org/accounts/?page=2",
  "results": [
    {
      "count": 456,
      "next": "https://example.com/file.jpg",
      "previous": "https://example.com/file.jpg",
      "results": [
        {
          "id": "550e8400-e29b-41d4-a716-446655440000",
          "name": "レスポンス文字列",
          "email": "レスポンス文字列",
          "credit_quota_required": false,
          "active_quota": {
            "id": "550e8400-e29b-41d4-a716-446655440000",
            "name": "レスポンスのサンプル名",
            "description": "レスポンスのサンプル説明"
          }
        }
      ],
      "stats": {
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "name": "レスポンスのサンプル名",
        "description": "レスポンスのサンプル説明"
      }
    }
  ]
}
```

***

### ロールの現在のクォータを一覧表示 <a href="#organizations-credit-quota-groups-list" id="organizations-credit-quota-groups-list"></a>

GET `/api/v1/organizations/{organizationPk}/credit-quota-groups/`

{% hint style="info" %}
**必要な権限**：Credit 管理権限。**課金方式**：組織は Credit 課金方式を使用している必要があります。
{% endhint %}

#### パラメータ

| パラメータ名           | 必須 | 型       | 説明                                                            |
| ---------------- | -- | ------- | ------------------------------------------------------------- |
| `organizationPk` | ✅  | string  | この組織 ID を識別する UUID 文字列                                        |
| `ordering`       | ❌  | string  | Sort field (default '-created\_at')                           |
| `page`           | ❌  | integer | Page number                                                   |
| `pageSize`       | ❌  | integer | Rows per page (max 100)                                       |
| `quotaStatus`    | ❌  | string  | Filter by quota status                                        |
| `search`         | ❌  | string  | Filter by group name or group ID (case-insensitive substring) |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出しの例 (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/credit-quota-groups/?ordering=-created_at&page=1&pageSize=1&quotaStatus=allocated&search=example" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/credit-quota-groups/?ordering=-created_at&page=1&pageSize=1&quotaStatus=allocated&search=example", config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/credit-quota-groups/?ordering=-created_at&page=1&pageSize=1&quotaStatus=allocated&search=example"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/credit-quota-groups/?ordering=-created_at&page=1&pageSize=1&quotaStatus=allocated&search=example", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンスボディ

**ステータスコード: 200**

**レスポンス構造の例**

```typescript
{
  "count": integer
  "next"?: string (uri) // 任意
  "previous"?: string (uri) // 任意
  "results": [
    {
      "count"?: integer // 任意
      "next"?: string (uri) // 任意
      "previous"?: string (uri) // 任意
      "results"?: [ // 任意
        {
          "id"?: string (uuid) // 任意
          "name"?: string // 任意
          "type"?: string (enum: owner, default, custom) // 任意
          "credit_quota_required"?: boolean // 任意
          "active_quota"?: { // Most recent quota summary (active first); same shape as the member/inbox variants. (任意)
          {
            "id"?: string (uuid) // 任意
            "quota_limit"?: string // 任意
            "consumed_amount"?: string // 任意
            "remaining"?: string // 任意
            "valid_from"?: string (date-time) // 任意
            "valid_until"?: string (date-time) // 任意
            "is_active"?: boolean // 任意
            "expired_at"?: string (date-time) // 任意
            "note"?: string // 任意
          }
          }
        }
      ]
      "stats"?: { // Organization-wide group counts, unaffected by search or quota_status filter. (任意)
      {
        "total"?: integer // 任意
        "allocated"?: integer // 任意
        "expired"?: integer // 任意
        "unallocated"?: integer // 任意
      }
      }
    }
  ]
}
```

**レスポンスの値の例**

```json
{
  "count": 123,
  "next": "http://api.example.org/accounts/?page=4",
  "previous": "http://api.example.org/accounts/?page=2",
  "results": [
    {
      "count": 456,
      "next": "https://example.com/file.jpg",
      "previous": "https://example.com/file.jpg",
      "results": [
        {
          "id": "550e8400-e29b-41d4-a716-446655440000",
          "name": "レスポンス文字列",
          "type": "owner",
          "credit_quota_required": false,
          "active_quota": {
            "id": "550e8400-e29b-41d4-a716-446655440000",
            "name": "レスポンス例の名前",
            "description": "レスポンス例の説明"
          }
        }
      ],
      "stats": {
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "name": "レスポンス例の名前",
        "description": "レスポンス例の説明"
      }
    }
  ]
}
```

***

### 対話プラットフォームの現在のクォータを一覧表示 <a href="#organizations-credit-quota-inboxes-list" id="organizations-credit-quota-inboxes-list"></a>

GET `/api/v1/organizations/{organizationPk}/credit-quota-inboxes/`

{% hint style="info" %}
**必要な権限**：Credit 管理権限。**課金モード**：組織は Credit 課金モードを使用する必要があります。
{% endhint %}

#### パラメータ

| パラメータ名           | 必須 | 型       | 説明                                                                                                                                                                                     |
| ---------------- | -- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `organizationPk` | ✅  | string  | この組織 ID を識別する UUID 文字列です。                                                                                                                                                              |
| `excludeBuiltIn` | ❌  | boolean | true の場合、公式の組み込み Agent（Agent マーケットプレイスでのレンタルによって作成されたロック済みインスタンス）のデータを除外し、組織が独自に作成したアシスタントのみを残します。「独自アシスタントとしてコピー」で作成されたコピーは、組織が独自に作成したものとして扱います。省略した場合や false の場合は、この条件による絞り込みを行いません。 |
| `ordering`       | ❌  | string  | Which field to use when ordering the results.                                                                                                                                          |
| `page`           | ❌  | integer | A page number within the paginated result set.                                                                                                                                         |
| `pageSize`       | ❌  | integer | Number of results to return per page.                                                                                                                                                  |
| `search`         | ❌  | string  | A search term.                                                                                                                                                                         |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出し例 (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/credit-quota-inboxes/?excludeBuiltIn=true&ordering=example&page=1&pageSize=1&search=example" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/credit-quota-inboxes/?excludeBuiltIn=true&ordering=example&page=1&pageSize=1&search=example", config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/credit-quota-inboxes/?excludeBuiltIn=true&ordering=example&page=1&pageSize=1&search=example"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/credit-quota-inboxes/?excludeBuiltIn=true&ordering=example&page=1&pageSize=1&search=example", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンス内容

**ステータスコード: 200**

**レスポンススキーマの例**

```typescript
{
  "count": integer
  "next"?: string (uri) // 任意
  "previous"?: string (uri) // 任意
  "results": [
    {
      "id": string (uuid)
      "name": string
      "channelType": 
      {
      }
      "channelTypeLabel": string
      "webChatAccessType": string // Sub-type for web channels (web = public embed, admin = internal Q&A, api = completions).

A chatbot ships with three same-named web inboxes, so the frontend needs
this to tell them apart. None for non-web channels. Reads the prefetched
generic ``channel`` relation (no extra query on the list path).
      "chatbot": object
      "creditQuotaRequired": boolean // When True, this inbox must have an active credit quota for the AI to reply
      "activeQuota": object // Return the most recent quota summary (active first), via prefetch to avoid N+1.
      "canUpdate": boolean // Return whether the current user can update this resource.
    }
  ]
}
```

**レスポンスの値の例**

```json
{
  "count": 123,
  "next": "http://api.example.org/accounts/?page=4",
  "previous": "http://api.example.org/accounts/?page=2",
  "results": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "レスポンス文字列",
      "channelType": {},
      "channelTypeLabel": "レスポンス文字列",
      "webChatAccessType": "レスポンス文字列",
      "chatbot": {
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "name": "レスポンスの名前の例",
        "description": "レスポンスの説明の例"
      },
      "creditQuotaRequired": false,
      "activeQuota": {
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "name": "レスポンスの名前の例",
        "description": "レスポンスの説明の例"
      },
      "canUpdate": false
    }
  ]
}
```

***

### メンバーのクォータ設定を一覧表示 <a href="#organizations-members-credit-quotas-list" id="organizations-members-credit-quotas-list"></a>

GET `/api/v1/organizations/{organizationPk}/members/{memberPk}/credit-quotas/`

{% hint style="info" %}
**必要な権限**：Credit 管理権限。**課金モード**：組織は Credit 課金モードを使用している必要があります。
{% endhint %}

#### パラメータ

| パラメータ名           | 必須 | 型       | 説明                                             |
| ---------------- | -- | ------- | ---------------------------------------------- |
| `memberPk`       | ✅  | string  |                                                |
| `organizationPk` | ✅  | string  | この組織 ID を識別する UUID 文字列                         |
| `page`           | ❌  | integer | A page number within the paginated result set. |
| `pageSize`       | ❌  | integer | Number of results to return per page.          |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出しの例 (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/members/{memberPk}/credit-quotas/?page=1&pageSize=1" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/members/{memberPk}/credit-quotas/?page=1&pageSize=1", config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/members/{memberPk}/credit-quotas/?page=1&pageSize=1"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/members/{memberPk}/credit-quotas/?page=1&pageSize=1", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンスボディ

**ステータスコード: 200**

**レスポンス構造の例**

```typescript
{
  "count": integer
  "next"?: string (uri) // 任意
  "previous"?: string (uri) // 任意
  "results": [
    {
      "id": string (uuid)
      "member": object
      "quotaLimit": string (decimal) // Maximum credits this member may consume
      "consumedAmount": string (decimal) // Credits consumed so far (updated via F() for concurrency safety)
      "remaining": string (decimal)
      "validFrom": string (timestamp)
      "validUntil": string (timestamp) // NULL means permanent
      "resetPeriod":  // Cycle on which consumed_amount is automatically zeroed; "none" keeps the one-shot ceiling

* `none` - No Reset
* `daily` - Daily
* `weekly` - Weekly
* `monthly` - Monthly
      {
      }
      "nextResetAt": string (timestamp) // Local-midnight boundary of the next automatic reset; NULL when reset_period is "none"
      "isActive": boolean
      "expiredAt": string (timestamp) // Actual deactivation time (cron or manual)
      "createdBy": object
      "note": string
      "createdAt": string (timestamp)
      "updatedAt": string (timestamp)
    }
  ]
}
```

**レスポンスの値の例**

```json
{
  "count": 123,
  "next": "http://api.example.org/accounts/?page=4",
  "previous": "http://api.example.org/accounts/?page=2",
  "results": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "member": {
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "name": "レスポンス例の名前",
        "description": "レスポンス例の説明"
      },
      "quotaLimit": "レスポンス文字列",
      "consumedAmount": "レスポンス文字列",
      "remaining": "レスポンス文字列",
      "validFrom": "レスポンス文字列",
      "validUntil": "レスポンス文字列",
      "resetPeriod": {},
      "nextResetAt": "レスポンス文字列",
      "isActive": false,
      "expiredAt": "レスポンス文字列",
      "createdBy": {
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "name": "レスポンス例の名前",
        "description": "レスポンス例の説明"
      },
      "note": "レスポンス文字列",
      "createdAt": "レスポンス文字列",
      "updatedAt": "レスポンス文字列"
    }
  ]
}
```

***

### メンバーのクォータ設定を1件取得 <a href="#organizations-members-credit-quotas-retrieve" id="organizations-members-credit-quotas-retrieve"></a>

GET `/api/v1/organizations/{organizationPk}/members/{memberPk}/credit-quotas/{id}/`

{% hint style="info" %}
**必要な権限**：Credit 管理権限。**課金モード**：組織は Credit 課金モードを使用している必要があります。
{% endhint %}

#### パラメータ

| パラメータ名           | 必須 | 型      | 説明                     |
| ---------------- | -- | ------ | ---------------------- |
| `id`             | ✅  | string |                        |
| `memberPk`       | ✅  | string |                        |
| `organizationPk` | ✅  | string | この組織 ID を識別する UUID 文字列 |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出しの例 (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/members/{memberPk}/credit-quotas/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/members/{memberPk}/credit-quotas/550e8400-e29b-41d4-a716-446655440000/", config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/members/{memberPk}/credit-quotas/550e8400-e29b-41d4-a716-446655440000/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/members/{memberPk}/credit-quotas/550e8400-e29b-41d4-a716-446655440000/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンスボディ

**ステータスコード: 200**

**レスポンス構造の例**

```typescript
{
  "id": string (uuid)
  "member": object
  "quotaLimit": string (decimal) // Maximum credits this member may consume
  "consumedAmount": string (decimal) // Credits consumed so far (updated via F() for concurrency safety)
  "remaining": string (decimal)
  "validFrom": string (timestamp)
  "validUntil": string (timestamp) // NULL means permanent
  "resetPeriod":  // Cycle on which consumed_amount is automatically zeroed; "none" keeps the one-shot ceiling

* `none` - No Reset
* `daily` - Daily
* `weekly` - Weekly
* `monthly` - Monthly
  {
  }
  "nextResetAt": string (timestamp) // Local-midnight boundary of the next automatic reset; NULL when reset_period is "none"
  "isActive": boolean
  "expiredAt": string (timestamp) // Actual deactivation time (cron or manual)
  "createdBy": object
  "note": string
  "createdAt": string (timestamp)
  "updatedAt": string (timestamp)
}
```

**レスポンスの値の例**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "member": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンス例の名前",
    "description": "レスポンス例の説明"
  },
  "quotaLimit": "レスポンス文字列",
  "consumedAmount": "レスポンス文字列",
  "remaining": "レスポンス文字列",
  "validFrom": "レスポンス文字列",
  "validUntil": "レスポンス文字列",
  "resetPeriod": {},
  "nextResetAt": "レスポンス文字列",
  "isActive": false,
  "expiredAt": "レスポンス文字列",
  "createdBy": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンス例の名前",
    "description": "レスポンス例の説明"
  },
  "note": "レスポンス文字列",
  "createdAt": "レスポンス文字列",
  "updatedAt": "レスポンス文字列"
}
```

***

### メンバーのクォータを設定 <a href="#organizations-members-credit-quotas-create" id="organizations-members-credit-quotas-create"></a>

POST `/api/v1/organizations/{organizationPk}/members/{memberPk}/credit-quotas/`

{% hint style="info" %}
**必要な権限**：Credit 管理権限。**課金モード**：組織は Credit 課金モードを使用している必要があります。リクエストボディとルールについては、[クォータの仕組み](#credit-quota-rules)を参照してください。メンバーに有効なクォータがすでにある場合は `400` が返されるため、先に無効化してください。
{% endhint %}

#### パラメーター

| パラメーター名          | 必須 | 型      | 説明                                             |
| ---------------- | -- | ------ | ---------------------------------------------- |
| `memberPk`       | ✅  | string |                                                |
| `organizationPk` | ✅  | string | A UUID string identifying this organization ID |

#### リクエストボディ

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

| フィールド       | 型                  | 必須  | 説明 |
| ----------- | ------------------ | --- | -- |
| quotaLimit  | string (decimal)   | はい  |    |
| validFrom   | string (date-time) | はい  |    |
| validUntil  | string (date-time) | いいえ |    |
| note        | string             | いいえ |    |
| resetPeriod | object             | いいえ |    |

**リクエストスキーマの例**

```typescript
{
  "quotaLimit": string (decimal)
  "validFrom": string (date-time)
  "validUntil"?: string (date-time) // 任意
  "note"?: string // 任意
  "resetPeriod"?:  // 任意
  {
  }
}
```

**リクエストの値の例**

```json
{
  "quotaLimit": "500",
  "validFrom": "2026-10-16T00:00:00+08:00",
  "validUntil": "2026-12-31T23:59:59+08:00",
  "resetPeriod": "monthly",
  "note": "Q4 budget"
}
```

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出し例 (Shell)
curl -X POST "https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/members/{memberPk}/credit-quotas/" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "quotaLimit": "500",
    "validFrom": "2026-10-16T00:00:00+08:00",
    "validUntil": "2026-12-31T23:59:59+08:00",
    "resetPeriod": "monthly",
    "note": "Q4 budget"
  }'

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
};

// リクエストボディ (payload)
const data = {
    "quotaLimit": "500",
    "validFrom": "2026-10-16T00:00:00+08:00",
    "validUntil": "2026-12-31T23:59:59+08:00",
    "resetPeriod": "monthly",
    "note": "Q4 budget"
  };

axios.post("https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/members/{memberPk}/credit-quotas/", data, config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/members/{memberPk}/credit-quotas/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY",
    "Content-Type": "application/json"
}

# リクエストボディ (payload)
data = {
    "quotaLimit": "500",
    "validFrom": "2026-10-16T00:00:00+08:00",
    "validUntil": "2026-12-31T23:59:59+08:00",
    "resetPeriod": "monthly",
    "note": "Q4 budget"
}

response = requests.post(url, json=data, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->post("https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/members/{memberPk}/credit-quotas/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY',
            'Content-Type' => 'application/json'
        ],
        'json' => [
            'quotaLimit' => '500',
            'validFrom' => '2026-10-16T00:00:00+08:00',
            'validUntil' => '2026-12-31T23:59:59+08:00',
            'resetPeriod' => 'monthly',
            'note' => 'Q4 budget'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンスボディ

**ステータスコード: 201**

**レスポンススキーマの例**

```typescript
{
  "id": string (uuid)
  "member": object
  "quotaLimit": string (decimal) // Maximum credits this member may consume
  "consumedAmount": string (decimal) // Credits consumed so far (updated via F() for concurrency safety)
  "remaining": string (decimal)
  "validFrom": string (timestamp)
  "validUntil": string (timestamp) // NULL means permanent
  "resetPeriod":  // Cycle on which consumed_amount is automatically zeroed; "none" keeps the one-shot ceiling

* `none` - No Reset
* `daily` - Daily
* `weekly` - Weekly
* `monthly` - Monthly
  {
  }
  "nextResetAt": string (timestamp) // Local-midnight boundary of the next automatic reset; NULL when reset_period is "none"
  "isActive": boolean
  "expiredAt": string (timestamp) // Actual deactivation time (cron or manual)
  "createdBy": object
  "note": string
  "createdAt": string (timestamp)
  "updatedAt": string (timestamp)
}
```

**レスポンスの値の例**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "member": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンスの名前の例",
    "description": "レスポンスの説明の例"
  },
  "quotaLimit": "レスポンス文字列",
  "consumedAmount": "レスポンス文字列",
  "remaining": "レスポンス文字列",
  "validFrom": "レスポンス文字列",
  "validUntil": "レスポンス文字列",
  "resetPeriod": {},
  "nextResetAt": "レスポンス文字列",
  "isActive": false,
  "expiredAt": "レスポンス文字列",
  "createdBy": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンスの名前の例",
    "description": "レスポンスの説明の例"
  },
  "note": "レスポンス文字列",
  "createdAt": "レスポンス文字列",
  "updatedAt": "レスポンス文字列"
}
```

***

### メンバーのクォータ設定を更新 <a href="#organizations-members-credit-quotas-partial-update" id="organizations-members-credit-quotas-partial-update"></a>

PATCH `/api/v1/organizations/{organizationPk}/members/{memberPk}/credit-quotas/{id}/`

{% hint style="info" %}
**必要な権限**：Credit 管理権限。**課金モード**：組織は Credit 課金モードを使用している必要があります。変更するフィールド（`quotaLimit`、`validUntil`、`resetPeriod`、`note`）のみを送信してください（有効開始日時は変更できません）。`quotaLimit` は消費済みの量を下回る値に設定できません。無効化されたクォータは更新できず、`400` が返されます。
{% endhint %}

#### パラメーター

| パラメーター名          | 必須 | 型      | 説明                                             |
| ---------------- | -- | ------ | ---------------------------------------------- |
| `id`             | ✅  | string |                                                |
| `memberPk`       | ✅  | string |                                                |
| `organizationPk` | ✅  | string | A UUID string identifying this organization ID |

#### リクエストボディ

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

| フィールド       | 型                                           | 必須  | 説明                                                                         |
| ----------- | ------------------------------------------- | --- | -------------------------------------------------------------------------- |
| quotaLimit  | string (decimal)                            | いいえ |                                                                            |
| validUntil  | string (date-time)                          | いいえ |                                                                            |
| note        | string                                      | いいえ |                                                                            |
| resetPeriod | string (enum: none, daily, weekly, monthly) | いいえ | `none`: No Reset ; `daily`: Daily ; `weekly`: Weekly ; `monthly`: Monthly; |

**リクエストスキーマの例**

```typescript
{
  "quotaLimit"?: string (decimal) // 任意
  "validUntil"?: string (date-time) // 任意
  "note"?: string // 任意
  "resetPeriod"?: string (enum: none, daily, weekly, monthly) // * `none` - No Reset
* `daily` - Daily
* `weekly` - Weekly
* `monthly` - Monthly (任意)
}
```

**リクエストの値の例**

```json
{
  "quotaLimit": "サンプル文字列",
  "validUntil": "2025-01-01T00:00:00.000Z",
  "note": "サンプル文字列",
  "resetPeriod": "none"
}
```

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出し例 (Shell)
curl -X PATCH "https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/members/{memberPk}/credit-quotas/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "quotaLimit": "サンプル文字列",
    "validUntil": "2025-01-01T00:00:00.000Z",
    "note": "サンプル文字列",
    "resetPeriod": "none"
  }'

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
};

// リクエストボディ (payload)
const data = {
    "quotaLimit": "サンプル文字列",
    "validUntil": "2025-01-01T00:00:00.000Z",
    "note": "サンプル文字列",
    "resetPeriod": "none"
  };

axios.patch("https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/members/{memberPk}/credit-quotas/550e8400-e29b-41d4-a716-446655440000/", data, config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/members/{memberPk}/credit-quotas/550e8400-e29b-41d4-a716-446655440000/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY",
    "Content-Type": "application/json"
}

# リクエストボディ (payload)
data = {
    "quotaLimit": "サンプル文字列",
    "validUntil": "2025-01-01T00:00:00.000Z",
    "note": "サンプル文字列",
    "resetPeriod": "none"
}

response = requests.patch(url, json=data, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->patch("https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/members/{memberPk}/credit-quotas/550e8400-e29b-41d4-a716-446655440000/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY',
            'Content-Type' => 'application/json'
        ],
        'json' => [
            'quotaLimit' => 'サンプル文字列',
            'validUntil' => '2025-01-01T00:00:00.000Z',
            'note' => 'サンプル文字列',
            'resetPeriod' => 'none'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンスボディ

**ステータスコード: 200**

**レスポンススキーマの例**

```typescript
{
  "id": string (uuid)
  "member": object
  "quotaLimit": string (decimal) // Maximum credits this member may consume
  "consumedAmount": string (decimal) // Credits consumed so far (updated via F() for concurrency safety)
  "remaining": string (decimal)
  "validFrom": string (timestamp)
  "validUntil": string (timestamp) // NULL means permanent
  "resetPeriod":  // Cycle on which consumed_amount is automatically zeroed; "none" keeps the one-shot ceiling

* `none` - No Reset
* `daily` - Daily
* `weekly` - Weekly
* `monthly` - Monthly
  {
  }
  "nextResetAt": string (timestamp) // Local-midnight boundary of the next automatic reset; NULL when reset_period is "none"
  "isActive": boolean
  "expiredAt": string (timestamp) // Actual deactivation time (cron or manual)
  "createdBy": object
  "note": string
  "createdAt": string (timestamp)
  "updatedAt": string (timestamp)
}
```

**レスポンスの値の例**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "member": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンスの名前の例",
    "description": "レスポンスの説明の例"
  },
  "quotaLimit": "レスポンス文字列",
  "consumedAmount": "レスポンス文字列",
  "remaining": "レスポンス文字列",
  "validFrom": "レスポンス文字列",
  "validUntil": "レスポンス文字列",
  "resetPeriod": {},
  "nextResetAt": "レスポンス文字列",
  "isActive": false,
  "expiredAt": "レスポンス文字列",
  "createdBy": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンスの名前の例",
    "description": "レスポンスの説明の例"
  },
  "note": "レスポンス文字列",
  "createdAt": "レスポンス文字列",
  "updatedAt": "レスポンス文字列"
}
```

***

### メンバーのクォータ設定を無効化 <a href="#organizations-members-credit-quotas-destroy" id="organizations-members-credit-quotas-destroy"></a>

DELETE `/api/v1/organizations/{organizationPk}/members/{memberPk}/credit-quotas/{id}/`

{% hint style="info" %}
**必要な権限**：Credit 管理権限。**課金モード**：組織が Credit 課金モードである必要があります。成功すると `204` が返されます。無効化後もメンバーの「クォータ必須」設定は有効のままなので、新しいクォータを設定するかクォータ制限を解除するまで、Credit を消費する機能は利用できません。すでに無効化されているクォータを再度無効化すると `400` が返されます。
{% endhint %}

#### パラメータ

| パラメータ名           | 必須 | 型      | 説明                                   |
| ---------------- | -- | ------ | ------------------------------------ |
| `id`             | ✅  | string |                                      |
| `memberPk`       | ✅  | string |                                      |
| `organizationPk` | ✅  | string | A UUID string identifying this 組織 ID |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出しの例 (Shell)
curl -X DELETE "https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/members/{memberPk}/credit-quotas/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

// リクエスト内容 (payload)
const data = null;

axios.delete("https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/members/{memberPk}/credit-quotas/550e8400-e29b-41d4-a716-446655440000/", data, config)
  .then(response => {
    console.log('レスポンスを取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/members/{memberPk}/credit-quotas/550e8400-e29b-41d4-a716-446655440000/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.delete(url, headers=headers)
try:
    print("レスポンスを取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->delete("https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/members/{memberPk}/credit-quotas/550e8400-e29b-41d4-a716-446655440000/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンス

| ステータスコード | 説明         |
| -------- | ---------- |
| 204      | レスポンスボディなし |

***

### ロールのクォータ設定の一覧を取得 <a href="#organizations-groups-credit-quotas-list" id="organizations-groups-credit-quotas-list"></a>

GET `/api/v1/organizations/{organizationPk}/groups/{groupPk}/credit-quotas/`

{% hint style="info" %}
**必要な権限**：Credit 管理権限。**課金モード**：組織は Credit 課金モードを使用している必要があります。
{% endhint %}

#### パラメータ

| パラメータ名           | 必須 | 型       | 説明                                             |
| ---------------- | -- | ------- | ---------------------------------------------- |
| `groupPk`        | ✅  | string  |                                                |
| `organizationPk` | ✅  | string  | この組織 ID を識別する UUID 文字列                         |
| `page`           | ❌  | integer | A page number within the paginated result set. |
| `pageSize`       | ❌  | integer | Number of results to return per page.          |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出しの例 (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/groups/{groupPk}/credit-quotas/?page=1&pageSize=1" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/groups/{groupPk}/credit-quotas/?page=1&pageSize=1", config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/groups/{groupPk}/credit-quotas/?page=1&pageSize=1"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/groups/{groupPk}/credit-quotas/?page=1&pageSize=1", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンスボディ

**ステータスコード: 200**

**レスポンススキーマの例**

```typescript
{
  "count": integer
  "next"?: string (uri) // 任意
  "previous"?: string (uri) // 任意
  "results": [
    {
      "id": string (uuid)
      "group": object
      "quotaLimit": string (decimal) // Maximum credits members of this group may consume
      "consumedAmount": string (decimal) // Credits consumed so far (updated via F() for concurrency safety)
      "remaining": string (decimal)
      "validFrom": string (timestamp)
      "validUntil": string (timestamp) // NULL means permanent
      "resetPeriod":  // Cycle on which consumed_amount is automatically zeroed; "none" keeps the one-shot ceiling

* `none` - No Reset
* `daily` - Daily
* `weekly` - Weekly
* `monthly` - Monthly
      {
      }
      "nextResetAt": string (timestamp) // Local-midnight boundary of the next automatic reset; NULL when reset_period is "none"
      "isActive": boolean
      "expiredAt": string (timestamp) // Actual deactivation time (cron or manual)
      "createdBy": object
      "note": string
      "createdAt": string (timestamp)
      "updatedAt": string (timestamp)
    }
  ]
}
```

**レスポンス値の例**

```json
{
  "count": 123,
  "next": "http://api.example.org/accounts/?page=4",
  "previous": "http://api.example.org/accounts/?page=2",
  "results": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "group": {
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "name": "レスポンス例の名前",
        "description": "レスポンス例の説明"
      },
      "quotaLimit": "レスポンス文字列",
      "consumedAmount": "レスポンス文字列",
      "remaining": "レスポンス文字列",
      "validFrom": "レスポンス文字列",
      "validUntil": "レスポンス文字列",
      "resetPeriod": {},
      "nextResetAt": "レスポンス文字列",
      "isActive": false,
      "expiredAt": "レスポンス文字列",
      "createdBy": {
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "name": "レスポンス例の名前",
        "description": "レスポンス例の説明"
      },
      "note": "レスポンス文字列",
      "createdAt": "レスポンス文字列",
      "updatedAt": "レスポンス文字列"
    }
  ]
}
```

***

### ロールのクォータ設定を1件取得 <a href="#organizations-groups-credit-quotas-retrieve" id="organizations-groups-credit-quotas-retrieve"></a>

GET `/api/v1/organizations/{organizationPk}/groups/{groupPk}/credit-quotas/{id}/`

{% hint style="info" %}
**必要な権限**：Credit 管理権限。**課金モード**：組織は Credit 課金モードを使用している必要があります。
{% endhint %}

#### パラメータ

| パラメータ名           | 必須 | 型      | 説明                     |
| ---------------- | -- | ------ | ---------------------- |
| `groupPk`        | ✅  | string |                        |
| `id`             | ✅  | string |                        |
| `organizationPk` | ✅  | string | この組織 ID を識別する UUID 文字列 |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出しの例 (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/groups/{groupPk}/credit-quotas/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/groups/{groupPk}/credit-quotas/550e8400-e29b-41d4-a716-446655440000/", config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/groups/{groupPk}/credit-quotas/550e8400-e29b-41d4-a716-446655440000/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/groups/{groupPk}/credit-quotas/550e8400-e29b-41d4-a716-446655440000/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンスボディ

**ステータスコード: 200**

**レスポンススキーマの例**

```typescript
{
  "id": string (uuid)
  "group": object
  "quotaLimit": string (decimal) // Maximum credits members of this group may consume
  "consumedAmount": string (decimal) // Credits consumed so far (updated via F() for concurrency safety)
  "remaining": string (decimal)
  "validFrom": string (timestamp)
  "validUntil": string (timestamp) // NULL means permanent
  "resetPeriod":  // Cycle on which consumed_amount is automatically zeroed; "none" keeps the one-shot ceiling

* `none` - No Reset
* `daily` - Daily
* `weekly` - Weekly
* `monthly` - Monthly
  {
  }
  "nextResetAt": string (timestamp) // Local-midnight boundary of the next automatic reset; NULL when reset_period is "none"
  "isActive": boolean
  "expiredAt": string (timestamp) // Actual deactivation time (cron or manual)
  "createdBy": object
  "note": string
  "createdAt": string (timestamp)
  "updatedAt": string (timestamp)
}
```

**レスポンス値の例**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "group": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンス例の名前",
    "description": "レスポンス例の説明"
  },
  "quotaLimit": "レスポンス文字列",
  "consumedAmount": "レスポンス文字列",
  "remaining": "レスポンス文字列",
  "validFrom": "レスポンス文字列",
  "validUntil": "レスポンス文字列",
  "resetPeriod": {},
  "nextResetAt": "レスポンス文字列",
  "isActive": false,
  "expiredAt": "レスポンス文字列",
  "createdBy": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンス例の名前",
    "description": "レスポンス例の説明"
  },
  "note": "レスポンス文字列",
  "createdAt": "レスポンス文字列",
  "updatedAt": "レスポンス文字列"
}
```

***

### ロールにクォータを設定 <a href="#organizations-groups-credit-quotas-create" id="organizations-groups-credit-quotas-create"></a>

POST `/api/v1/organizations/{organizationPk}/groups/{groupPk}/credit-quotas/`

{% hint style="info" %}
**必要な権限**：Credit 管理権限。**課金モード**：組織が Credit 課金モードを使用している必要があります。設定するのはロール内の全メンバーが共有するクォータで、個々のメンバーには割り当てられません。各メンバーに個別のクォータを設定する場合は、[ロール単位でクォータを一括割り当て](#organizations-groups-batch-distribute-credit-quota-create)を使用してください。リクエストボディとルールについては、[クォータの仕組み](#credit-quota-rules)を参照してください。ロールに有効なクォータがすでにある場合は `400` が返されるため、先に無効化してください。
{% endhint %}

#### パラメータ

| パラメータ名           | 必須 | 型      | 説明                                   |
| ---------------- | -- | ------ | ------------------------------------ |
| `groupPk`        | ✅  | string |                                      |
| `organizationPk` | ✅  | string | A UUID string identifying this 組織 ID |

#### リクエストボディ

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

| フィールド       | 型                  | 必須  | 説明 |
| ----------- | ------------------ | --- | -- |
| quotaLimit  | string (decimal)   | はい  |    |
| validFrom   | string (date-time) | はい  |    |
| validUntil  | string (date-time) | いいえ |    |
| note        | string             | いいえ |    |
| resetPeriod | object             | いいえ |    |

**リクエストスキーマの例**

```typescript
{
  "quotaLimit": string (decimal)
  "validFrom": string (date-time)
  "validUntil"?: string (date-time) // 任意
  "note"?: string // 任意
  "resetPeriod"?:  // 任意
  {
  }
}
```

**リクエストの値の例**

```json
{
  "quotaLimit": "500",
  "validFrom": "2026-10-16T00:00:00+08:00",
  "validUntil": "2026-12-31T23:59:59+08:00",
  "resetPeriod": "monthly",
  "note": "Q4 budget"
}
```

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出しの例 (Shell)
curl -X POST "https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/groups/{groupPk}/credit-quotas/" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "quotaLimit": "500",
    "validFrom": "2026-10-16T00:00:00+08:00",
    "validUntil": "2026-12-31T23:59:59+08:00",
    "resetPeriod": "monthly",
    "note": "Q4 budget"
  }'

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
};

// リクエストボディ (payload)
const data = {
    "quotaLimit": "500",
    "validFrom": "2026-10-16T00:00:00+08:00",
    "validUntil": "2026-12-31T23:59:59+08:00",
    "resetPeriod": "monthly",
    "note": "Q4 budget"
  };

axios.post("https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/groups/{groupPk}/credit-quotas/", data, config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/groups/{groupPk}/credit-quotas/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY",
    "Content-Type": "application/json"
}

# リクエストボディ (payload)
data = {
    "quotaLimit": "500",
    "validFrom": "2026-10-16T00:00:00+08:00",
    "validUntil": "2026-12-31T23:59:59+08:00",
    "resetPeriod": "monthly",
    "note": "Q4 budget"
}

response = requests.post(url, json=data, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->post("https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/groups/{groupPk}/credit-quotas/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY',
            'Content-Type' => 'application/json'
        ],
        'json' => [
            'quotaLimit' => '500',
            'validFrom' => '2026-10-16T00:00:00+08:00',
            'validUntil' => '2026-12-31T23:59:59+08:00',
            'resetPeriod' => 'monthly',
            'note' => 'Q4 budget'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンスボディ

**ステータスコード: 201**

**レスポンススキーマの例**

```typescript
{
  "id": string (uuid)
  "group": object
  "quotaLimit": string (decimal) // Maximum credits members of this group may consume
  "consumedAmount": string (decimal) // Credits consumed so far (updated via F() for concurrency safety)
  "remaining": string (decimal)
  "validFrom": string (timestamp)
  "validUntil": string (timestamp) // NULL means permanent
  "resetPeriod":  // Cycle on which consumed_amount is automatically zeroed; "none" keeps the one-shot ceiling

* `none` - No Reset
* `daily` - Daily
* `weekly` - Weekly
* `monthly` - Monthly
  {
  }
  "nextResetAt": string (timestamp) // Local-midnight boundary of the next automatic reset; NULL when reset_period is "none"
  "isActive": boolean
  "expiredAt": string (timestamp) // Actual deactivation time (cron or manual)
  "createdBy": object
  "note": string
  "createdAt": string (timestamp)
  "updatedAt": string (timestamp)
}
```

**レスポンスの値の例**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "group": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンスの名前の例",
    "description": "レスポンスの説明の例"
  },
  "quotaLimit": "レスポンス文字列",
  "consumedAmount": "レスポンス文字列",
  "remaining": "レスポンス文字列",
  "validFrom": "レスポンス文字列",
  "validUntil": "レスポンス文字列",
  "resetPeriod": {},
  "nextResetAt": "レスポンス文字列",
  "isActive": false,
  "expiredAt": "レスポンス文字列",
  "createdBy": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンスの名前の例",
    "description": "レスポンスの説明の例"
  },
  "note": "レスポンス文字列",
  "createdAt": "レスポンス文字列",
  "updatedAt": "レスポンス文字列"
}
```

***

### ロールのクォータ設定を更新 <a href="#organizations-groups-credit-quotas-partial-update" id="organizations-groups-credit-quotas-partial-update"></a>

PATCH `/api/v1/organizations/{organizationPk}/groups/{groupPk}/credit-quotas/{id}/`

{% hint style="info" %}
**必要な権限**：Credit 管理権限。**課金モード**：組織が Credit 課金モードを使用している必要があります。変更するフィールド（`quotaLimit`、`validUntil`、`resetPeriod`、`note`）のみを送信してください（適用開始日時は変更できません）。`quotaLimit` に使用済みの量を下回る値は設定できません。無効化済みのクォータは更新できず、`400` が返されます。
{% endhint %}

#### パラメータ

| パラメータ名           | 必須 | 型      | 説明                                   |
| ---------------- | -- | ------ | ------------------------------------ |
| `groupPk`        | ✅  | string |                                      |
| `id`             | ✅  | string |                                      |
| `organizationPk` | ✅  | string | A UUID string identifying this 組織 ID |

#### リクエストボディ

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

| フィールド       | 型                                           | 必須  | 説明                                                                         |
| ----------- | ------------------------------------------- | --- | -------------------------------------------------------------------------- |
| quotaLimit  | string (decimal)                            | いいえ |                                                                            |
| validUntil  | string (date-time)                          | いいえ |                                                                            |
| note        | string                                      | いいえ |                                                                            |
| resetPeriod | string (enum: none, daily, weekly, monthly) | いいえ | `none`: No Reset ; `daily`: Daily ; `weekly`: Weekly ; `monthly`: Monthly; |

**リクエストスキーマの例**

```typescript
{
  "quotaLimit"?: string (decimal) // 任意
  "validUntil"?: string (date-time) // 任意
  "note"?: string // 任意
  "resetPeriod"?: string (enum: none, daily, weekly, monthly) // * `none` - No Reset
* `daily` - Daily
* `weekly` - Weekly
* `monthly` - Monthly (任意)
}
```

**リクエストの値の例**

```json
{
  "quotaLimit": "サンプル文字列",
  "validUntil": "2025-01-01T00:00:00.000Z",
  "note": "サンプル文字列",
  "resetPeriod": "none"
}
```

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出しの例 (Shell)
curl -X PATCH "https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/groups/{groupPk}/credit-quotas/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "quotaLimit": "サンプル文字列",
    "validUntil": "2025-01-01T00:00:00.000Z",
    "note": "サンプル文字列",
    "resetPeriod": "none"
  }'

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
};

// リクエストボディ (payload)
const data = {
    "quotaLimit": "サンプル文字列",
    "validUntil": "2025-01-01T00:00:00.000Z",
    "note": "サンプル文字列",
    "resetPeriod": "none"
  };

axios.patch("https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/groups/{groupPk}/credit-quotas/550e8400-e29b-41d4-a716-446655440000/", data, config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/groups/{groupPk}/credit-quotas/550e8400-e29b-41d4-a716-446655440000/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY",
    "Content-Type": "application/json"
}

# リクエストボディ (payload)
data = {
    "quotaLimit": "サンプル文字列",
    "validUntil": "2025-01-01T00:00:00.000Z",
    "note": "サンプル文字列",
    "resetPeriod": "none"
}

response = requests.patch(url, json=data, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->patch("https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/groups/{groupPk}/credit-quotas/550e8400-e29b-41d4-a716-446655440000/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY',
            'Content-Type' => 'application/json'
        ],
        'json' => [
            'quotaLimit' => 'サンプル文字列',
            'validUntil' => '2025-01-01T00:00:00.000Z',
            'note' => 'サンプル文字列',
            'resetPeriod' => 'none'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンスボディ

**ステータスコード: 200**

**レスポンススキーマの例**

```typescript
{
  "id": string (uuid)
  "group": object
  "quotaLimit": string (decimal) // Maximum credits members of this group may consume
  "consumedAmount": string (decimal) // Credits consumed so far (updated via F() for concurrency safety)
  "remaining": string (decimal)
  "validFrom": string (timestamp)
  "validUntil": string (timestamp) // NULL means permanent
  "resetPeriod":  // Cycle on which consumed_amount is automatically zeroed; "none" keeps the one-shot ceiling

* `none` - No Reset
* `daily` - Daily
* `weekly` - Weekly
* `monthly` - Monthly
  {
  }
  "nextResetAt": string (timestamp) // Local-midnight boundary of the next automatic reset; NULL when reset_period is "none"
  "isActive": boolean
  "expiredAt": string (timestamp) // Actual deactivation time (cron or manual)
  "createdBy": object
  "note": string
  "createdAt": string (timestamp)
  "updatedAt": string (timestamp)
}
```

**レスポンスの値の例**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "group": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンスの名前の例",
    "description": "レスポンスの説明の例"
  },
  "quotaLimit": "レスポンス文字列",
  "consumedAmount": "レスポンス文字列",
  "remaining": "レスポンス文字列",
  "validFrom": "レスポンス文字列",
  "validUntil": "レスポンス文字列",
  "resetPeriod": {},
  "nextResetAt": "レスポンス文字列",
  "isActive": false,
  "expiredAt": "レスポンス文字列",
  "createdBy": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンスの名前の例",
    "description": "レスポンスの説明の例"
  },
  "note": "レスポンス文字列",
  "createdAt": "レスポンス文字列",
  "updatedAt": "レスポンス文字列"
}
```

***

### ロールの割り当て設定を無効化 <a href="#organizations-groups-credit-quotas-destroy" id="organizations-groups-credit-quotas-destroy"></a>

DELETE `/api/v1/organizations/{organizationPk}/groups/{groupPk}/credit-quotas/{id}/`

{% hint style="info" %}
**必要な権限**：Credit 管理権限。**課金モード**：組織が Credit 課金モードである必要があります。成功すると `204` が返されます。無効化後もロールの「割り当てが必要」設定はオンのままのため、新しい割り当てを設定するか割り当ての制限を解除するまで、ロール内のメンバーは Credit を消費する機能を使用できません。すでに無効化済みの割り当てを再度無効化すると `400` が返されます。
{% endhint %}

#### パラメータ

| パラメータ名           | 必須 | 型      | 説明                                   |
| ---------------- | -- | ------ | ------------------------------------ |
| `groupPk`        | ✅  | string |                                      |
| `id`             | ✅  | string |                                      |
| `organizationPk` | ✅  | string | A UUID string identifying this 組織 ID |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出し例 (Shell)
curl -X DELETE "https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/groups/{groupPk}/credit-quotas/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

// リクエスト内容 (payload)
const data = null;

axios.delete("https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/groups/{groupPk}/credit-quotas/550e8400-e29b-41d4-a716-446655440000/", data, config)
  .then(response => {
    console.log('レスポンスを取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/groups/{groupPk}/credit-quotas/550e8400-e29b-41d4-a716-446655440000/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.delete(url, headers=headers)
try:
    print("レスポンスを取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->delete("https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/groups/{groupPk}/credit-quotas/550e8400-e29b-41d4-a716-446655440000/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンス内容

| ステータスコード | 説明               |
| -------- | ---------------- |
| 204      | No response body |

***

### ロールの割り当て要否を設定 <a href="#organizations-credit-quota-groups-credit-quota-required-partial-update" id="organizations-credit-quota-groups-credit-quota-required-partial-update"></a>

PATCH `/api/v1/organizations/{organizationPk}/credit-quota-groups/{id}/credit-quota-required/`

{% hint style="info" %}
**必要な権限**：Credit 管理権限。**課金モード**：組織が Credit 課金モードである必要があります。リクエスト内容は `{"creditQuotaRequired": true}` または `false` で、パスの `id` はロール ID です。`false`（割り当ての制限を解除）に設定すると、ロールの有効な割り当ても同時に無効化され、メンバーは組織のウォレットを使用するようになります。`true` に設定すると、割り当てを設定するまでロール内のメンバーの利用がブロックされます。レスポンスは、そのロールの割り当ての現在の状況です。
{% endhint %}

#### パラメータ

| パラメータ名           | 必須 | 型      | 説明                                    |
| ---------------- | -- | ------ | ------------------------------------- |
| `id`             | ✅  | string | A UUID string identifying this Group. |
| `organizationPk` | ✅  | string | A UUID string identifying this 組織 ID  |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出し例 (Shell)
curl -X PATCH "https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/credit-quota-groups/550e8400-e29b-41d4-a716-446655440000/credit-quota-required/" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
};

// リクエスト内容 (payload)
const data = {};

axios.patch("https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/credit-quota-groups/550e8400-e29b-41d4-a716-446655440000/credit-quota-required/", data, config)
  .then(response => {
    console.log('レスポンスを取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/credit-quota-groups/550e8400-e29b-41d4-a716-446655440000/credit-quota-required/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY",
    "Content-Type": "application/json"
}

# リクエスト内容 (payload)
data = {}

response = requests.patch(url, json=data, headers=headers)
try:
    print("レスポンスを取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->patch("https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/credit-quota-groups/550e8400-e29b-41d4-a716-446655440000/credit-quota-required/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY',
            'Content-Type' => 'application/json'
        ],
        'json' => new \stdClass()
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンス内容

**ステータスコード: 200**

**レスポンス構造の例**

```typescript
{
  "id": string (uuid)
  "name": string
  "type": 
  {
  }
  "creditQuotaRequired": boolean // When True, this group must have an active credit quota for its members to consume credits
  "activeQuota": object // Return the most recent quota summary (active first), via prefetch to avoid N+1.
}
```

**レスポンスのサンプル値**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "name": "レスポンス文字列",
  "type": {},
  "creditQuotaRequired": false,
  "activeQuota": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンスのサンプル名",
    "description": "レスポンスのサンプル説明"
  }
}
```

***

### ロールに属するメンバーのクォータ統計を取得 <a href="#organizations-groups-credit-quota-stats-retrieve" id="organizations-groups-credit-quota-stats-retrieve"></a>

GET `/api/v1/organizations/{organizationPk}/groups/{id}/credit-quota-stats/`

{% hint style="info" %}
**必要な権限**：Credit 管理権限。**課金モード**：組織は Credit 課金モードを使用している必要があります。
{% endhint %}

#### パラメータ

| パラメータ名           | 必須 | 型      | 説明                                    |
| ---------------- | -- | ------ | ------------------------------------- |
| `id`             | ✅  | string | A UUID string identifying this Group. |
| `organizationPk` | ✅  | string | この組織 ID を識別する UUID 文字列                |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出しの例 (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/groups/550e8400-e29b-41d4-a716-446655440000/credit-quota-stats/" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/groups/550e8400-e29b-41d4-a716-446655440000/credit-quota-stats/", config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/groups/550e8400-e29b-41d4-a716-446655440000/credit-quota-stats/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/groups/550e8400-e29b-41d4-a716-446655440000/credit-quota-stats/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンスボディ

**ステータスコード: 200**

**レスポンススキーマの例**

```typescript
{
  "activeQuotaMembersCount": integer
  "quotaRequiredMembersCount": integer
}
```

**レスポンス値の例**

```json
{
  "activeQuotaMembersCount": 456,
  "quotaRequiredMembersCount": 456
}
```

***

### ロールごとにクォータを一括配分 <a href="#organizations-groups-batch-distribute-credit-quota-create" id="organizations-groups-batch-distribute-credit-quota-create"></a>

POST `/api/v1/organizations/{organizationPk}/groups/{id}/batch-distribute-credit-quota/`

{% hint style="info" %}
**必要な権限**：Credit 管理権限＋組織概要権限。**課金モード**：組織が Credit 課金モードである必要があります。ロール内の各メンバーに対してメンバーごとの割り当てを 1 件ずつ設定します。リクエストの内容は [メンバーのクォータを設定](#organizations-members-credit-quotas-create) と同じです。すでに有効な割り当てがあるメンバーはスキップされ、変更されません。レスポンス：`successCount`、`skippedCount`、`skippedMemberIds`、`failedCount`、`failedMembers`。
{% endhint %}

#### パラメータ

| パラメータ名           | 必須 | 型      | 説明                                    |
| ---------------- | -- | ------ | ------------------------------------- |
| `id`             | ✅  | string | A UUID string identifying this Group. |
| `organizationPk` | ✅  | string | A UUID string identifying this 組織 ID  |

#### リクエスト内容

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

| フィールド                    | 型       | 必須  | 説明                                                                                                                                                                                                          |
| ------------------------ | ------- | --- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| name                     | string  | はい  |                                                                                                                                                                                                             |
| canCreateChatbot         | boolean | いいえ |                                                                                                                                                                                                             |
| canCreateKnowledgeBase   | boolean | いいえ |                                                                                                                                                                                                             |
| canCreateInbox           | boolean | いいえ |                                                                                                                                                                                                             |
| canCreateDatabase        | boolean | いいえ |                                                                                                                                                                                                             |
| canCreateTool            | boolean | いいえ |                                                                                                                                                                                                             |
| canCreateAgentUiTool     | boolean | いいえ |                                                                                                                                                                                                             |
| canCreateSkill           | boolean | いいえ |                                                                                                                                                                                                             |
| maigptCanCodeInterpreter | boolean | いいえ | Whether members of this role may use the code interpreter built-in tool in MaiGPT.                                                                                                                          |
| maigptCanRag             | boolean | いいえ | Whether members of this role may use the knowledge base RAG built-in tool in MaiGPT.                                                                                                                        |
| maigptCanDeepResearch    | boolean | いいえ | Whether members of this role may use Deep Research in MaiGPT. Deep Research reaches the public internet through its own built-in search, so a role that revokes the official web-search tools needs this... |
| maigptCanBrowserTool     | boolean | いいえ | Whether members of this role may use the browser built-in tool in MaiGPT.                                                                                                                                   |
| maigptAllLlms            | boolean | いいえ | Whether members of this role may use every organization-available LLM in MaiGPT. Off = only the bound LLMs; an empty binding then means none.                                                               |
| maigptAllTools           | boolean | いいえ | Whether members of this role may call every official (global) tool in MaiGPT. Off = only the bound tools; an empty binding then means none.                                                                 |
| maigptAllConnectors      | boolean | いいえ | Whether members of this role may call every official (global) MCP connector in MaiGPT. Off = only the bound connectors; an empty binding then means none.                                                   |
| maigptAllSkills          | boolean | いいえ | Whether members of this role may use every official (global) skill in MaiGPT. Off = only the bound skills; an empty binding then means none.                                                                |
| usageStatisticsScope     | object  | いいえ | What this role's usage statistics permission shows: the whole organization, or only the AI assistants granted to the member's roles. A member with any organization-wide granting role sees the whole or... |

**リクエスト構造の例**

```typescript
{
  "name": string
  "canCreateChatbot"?: boolean // 任意
  "canCreateKnowledgeBase"?: boolean // 任意
  "canCreateInbox"?: boolean // 任意
  "canCreateDatabase"?: boolean // 任意
  "canCreateTool"?: boolean // 任意
  "canCreateAgentUiTool"?: boolean // 任意
  "canCreateSkill"?: boolean // 任意
  "maigptCanCodeInterpreter"?: boolean // Whether members of this role may use the code interpreter built-in tool in MaiGPT. (任意)
  "maigptCanRag"?: boolean // Whether members of this role may use the knowledge base RAG built-in tool in MaiGPT. (任意)
  "maigptCanDeepResearch"?: boolean // Whether members of this role may use Deep Research in MaiGPT. Deep Research reaches the public internet through its own built-in search, so a role that revokes the official web-search tools needs this switch too. (任意)
  "maigptCanBrowserTool"?: boolean // Whether members of this role may use the browser built-in tool in MaiGPT. (任意)
  "maigptAllLlms"?: boolean // Whether members of this role may use every organization-available LLM in MaiGPT. Off = only the bound LLMs; an empty binding then means none. (任意)
  "maigptAllTools"?: boolean // Whether members of this role may call every official (global) tool in MaiGPT. Off = only the bound tools; an empty binding then means none. (任意)
  "maigptAllConnectors"?: boolean // Whether members of this role may call every official (global) MCP connector in MaiGPT. Off = only the bound connectors; an empty binding then means none. (任意)
  "maigptAllSkills"?: boolean // Whether members of this role may use every official (global) skill in MaiGPT. Off = only the bound skills; an empty binding then means none. (任意)
  "usageStatisticsScope"?:  // What this role's usage statistics permission shows: the whole organization, or only the AI assistants granted to the member's roles. A member with any organization-wide granting role sees the whole organization.

* `organization` - Organization-wide
* `accessible_chatbots` - Authorized AI assistants only (任意)
  {
  }
}
```

**リクエストのサンプル値**

```json
{
  "name": "サンプル名",
  "canCreateChatbot": true,
  "canCreateKnowledgeBase": true,
  "canCreateInbox": true,
  "canCreateDatabase": true,
  "canCreateTool": true,
  "canCreateAgentUiTool": true,
  "canCreateSkill": true,
  "maigptCanCodeInterpreter": true,
  "maigptCanRag": true,
  "maigptCanDeepResearch": true,
  "maigptCanBrowserTool": true,
  "maigptAllLlms": true,
  "maigptAllTools": true,
  "maigptAllConnectors": true,
  "maigptAllSkills": true,
  "usageStatisticsScope": {}
}
```

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出し例 (Shell)
curl -X POST "https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/groups/550e8400-e29b-41d4-a716-446655440000/batch-distribute-credit-quota/" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "サンプル名",
    "canCreateChatbot": true,
    "canCreateKnowledgeBase": true,
    "canCreateInbox": true,
    "canCreateDatabase": true,
    "canCreateTool": true,
    "canCreateAgentUiTool": true,
    "canCreateSkill": true,
    "maigptCanCodeInterpreter": true,
    "maigptCanRag": true,
    "maigptCanDeepResearch": true,
    "maigptCanBrowserTool": true,
    "maigptAllLlms": true,
    "maigptAllTools": true,
    "maigptAllConnectors": true,
    "maigptAllSkills": true,
    "usageStatisticsScope": {}
  }'

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
};

// リクエスト内容 (payload)
const data = {
    "name": "サンプル名",
    "canCreateChatbot": true,
    "canCreateKnowledgeBase": true,
    "canCreateInbox": true,
    "canCreateDatabase": true,
    "canCreateTool": true,
    "canCreateAgentUiTool": true,
    "canCreateSkill": true,
    "maigptCanCodeInterpreter": true,
    "maigptCanRag": true,
    "maigptCanDeepResearch": true,
    "maigptCanBrowserTool": true,
    "maigptAllLlms": true,
    "maigptAllTools": true,
    "maigptAllConnectors": true,
    "maigptAllSkills": true,
    "usageStatisticsScope": {}
  };

axios.post("https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/groups/550e8400-e29b-41d4-a716-446655440000/batch-distribute-credit-quota/", data, config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/groups/550e8400-e29b-41d4-a716-446655440000/batch-distribute-credit-quota/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY",
    "Content-Type": "application/json"
}

# リクエスト内容 (payload)
data = {
    "name": "サンプル名",
    "canCreateChatbot": True,
    "canCreateKnowledgeBase": True,
    "canCreateInbox": True,
    "canCreateDatabase": True,
    "canCreateTool": True,
    "canCreateAgentUiTool": True,
    "canCreateSkill": True,
    "maigptCanCodeInterpreter": True,
    "maigptCanRag": True,
    "maigptCanDeepResearch": True,
    "maigptCanBrowserTool": True,
    "maigptAllLlms": True,
    "maigptAllTools": True,
    "maigptAllConnectors": True,
    "maigptAllSkills": True,
    "usageStatisticsScope": {}
}

response = requests.post(url, json=data, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->post("https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/groups/550e8400-e29b-41d4-a716-446655440000/batch-distribute-credit-quota/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY',
            'Content-Type' => 'application/json'
        ],
        'json' => [
            'name' => 'サンプル名',
            'canCreateChatbot' => true,
            'canCreateKnowledgeBase' => true,
            'canCreateInbox' => true,
            'canCreateDatabase' => true,
            'canCreateTool' => true,
            'canCreateAgentUiTool' => true,
            'canCreateSkill' => true,
            'maigptCanCodeInterpreter' => true,
            'maigptCanRag' => true,
            'maigptCanDeepResearch' => true,
            'maigptCanBrowserTool' => true,
            'maigptAllLlms' => true,
            'maigptAllTools' => true,
            'maigptAllConnectors' => true,
            'maigptAllSkills' => true,
            'usageStatisticsScope' => new \stdClass()
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンス内容

**ステータスコード: 200**

**レスポンス構造の例**

```typescript
{
  "id": string (uuid)
  "name": string
  "type": 
  {
  }
  "permissions": [
    object
  ]
  "membersPreview": [
    string
  ]
  "membersCount": integer // 残りのメンバー数（リストに表示される 3 人を除いた数）を返します。フロントエンドの +N バッジ表示に使用されます

リソースの count とは異なります：
- members_count: total - 3 を返します（+N バッジ用）。None は合計が 3 以下であることを示します
- chatbots_count/knowledge_bases_count/inboxes_count: 合計数を返します
  "chatbotsCount": integer
  "chatbotsPreview": [
    string
  ]
  "knowledgeBasesCount": integer
  "knowledgeBasesPreview": [
    string
  ]
  "inboxesCount": integer
  "inboxesPreview": [
    string
  ]
  "databasesCount": integer
  "databasesPreview": [
    string
  ]
  "canCreateChatbot"?: boolean // 任意
  "canCreateKnowledgeBase"?: boolean // 任意
  "canCreateInbox"?: boolean // 任意
  "canCreateDatabase"?: boolean // 任意
  "canCreateTool"?: boolean // 任意
  "canCreateAgentUiTool"?: boolean // 任意
  "canCreateSkill"?: boolean // 任意
  "maigptCanCodeInterpreter"?: boolean // Whether members of this role may use the code interpreter built-in tool in MaiGPT. (任意)
  "maigptCanRag"?: boolean // Whether members of this role may use the knowledge base RAG built-in tool in MaiGPT. (任意)
  "maigptCanDeepResearch"?: boolean // Whether members of this role may use Deep Research in MaiGPT. Deep Research reaches the public internet through its own built-in search, so a role that revokes the official web-search tools needs this switch too. (任意)
  "maigptCanBrowserTool"?: boolean // Whether members of this role may use the browser built-in tool in MaiGPT. (任意)
  "maigptAllLlms"?: boolean // Whether members of this role may use every organization-available LLM in MaiGPT. Off = only the bound LLMs; an empty binding then means none. (任意)
  "maigptAllTools"?: boolean // Whether members of this role may call every official (global) tool in MaiGPT. Off = only the bound tools; an empty binding then means none. (任意)
  "maigptAllConnectors"?: boolean // Whether members of this role may call every official (global) MCP connector in MaiGPT. Off = only the bound connectors; an empty binding then means none. (任意)
  "maigptAllSkills"?: boolean // Whether members of this role may use every official (global) skill in MaiGPT. Off = only the bound skills; an empty binding then means none. (任意)
  "usageStatisticsScope"?:  // What this role's usage statistics permission shows: the whole organization, or only the AI assistants granted to the member's roles. A member with any organization-wide granting role sees the whole organization.

* `organization` - Organization-wide
* `accessible_chatbots` - Authorized AI assistants only (任意)
  {
  }
  "createdAt": string (timestamp)
}
```

**レスポンス値の例**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "name": "レスポンス文字列",
  "type": {},
  "permissions": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "レスポンスの名前の例",
      "description": "レスポンスの説明の例"
    }
  ],
  "membersPreview": [
    "レスポンス文字列"
  ],
  "membersCount": 456,
  "chatbotsCount": 456,
  "chatbotsPreview": [
    "レスポンス文字列"
  ],
  "knowledgeBasesCount": 456,
  "knowledgeBasesPreview": [
    "レスポンス文字列"
  ],
  "inboxesCount": 456,
  "inboxesPreview": [
    "レスポンス文字列"
  ],
  "databasesCount": 456,
  "databasesPreview": [
    "レスポンス文字列"
  ],
  "canCreateChatbot": false,
  "canCreateKnowledgeBase": false,
  "canCreateInbox": false,
  "canCreateDatabase": false,
  "canCreateTool": false,
  "canCreateAgentUiTool": false,
  "canCreateSkill": false,
  "maigptCanCodeInterpreter": false,
  "maigptCanRag": false,
  "maigptCanDeepResearch": false,
  "maigptCanBrowserTool": false,
  "maigptAllLlms": false,
  "maigptAllTools": false,
  "maigptAllConnectors": false,
  "maigptAllSkills": false,
  "usageStatisticsScope": {},
  "createdAt": "レスポンス文字列"
}
```

***

### ロールごとにクォータを一括停止 <a href="#organizations-groups-batch-deactivate-credit-quota-create" id="organizations-groups-batch-deactivate-credit-quota-create"></a>

POST `/api/v1/organizations/{organizationPk}/groups/{id}/batch-deactivate-credit-quota/`

{% hint style="info" %}
**必要な権限**：Credit 管理権限＋組織概要権限。**課金モード**：組織が Credit 課金モードである必要があります。ロール内のすべてのメンバーについて、有効なメンバーの割り当てを停止します（ロール自体の割り当ては対象外です）。有効な割り当てがないメンバーはスキップとして扱われます。リクエストの内容 `removeQuotaRequirement` は任意で、デフォルトは `false` です。割り当てのみを停止し、メンバーの「割り当てが必要」設定はオンのままのため、割り当てを再配分するまで利用できません。`true` に設定すると、ロール内のすべてのメンバーの割り当て制限も解除し、組織のウォレットを使用するようになります。レスポンス：`successCount`、`skippedCount`、`skippedMemberIds`、`failedCount`、`failedMembers`、`requirementRemovedCount`。実行前に、[ロールメンバーの割り当て統計を照会](#organizations-groups-credit-quota-stats-retrieve) で影響を受ける人数を確認できます。
{% endhint %}

#### パラメータ

| パラメータ名           | 必須 | 型      | 説明                                    |
| ---------------- | -- | ------ | ------------------------------------- |
| `id`             | ✅  | string | A UUID string identifying this Group. |
| `organizationPk` | ✅  | string | A UUID string identifying this 組織 ID  |

#### リクエスト内容

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

| フィールド                    | 型       | 必須  | 説明                                                                                                                                                                                                          |
| ------------------------ | ------- | --- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| name                     | string  | はい  |                                                                                                                                                                                                             |
| canCreateChatbot         | boolean | いいえ |                                                                                                                                                                                                             |
| canCreateKnowledgeBase   | boolean | いいえ |                                                                                                                                                                                                             |
| canCreateInbox           | boolean | いいえ |                                                                                                                                                                                                             |
| canCreateDatabase        | boolean | いいえ |                                                                                                                                                                                                             |
| canCreateTool            | boolean | いいえ |                                                                                                                                                                                                             |
| canCreateAgentUiTool     | boolean | いいえ |                                                                                                                                                                                                             |
| canCreateSkill           | boolean | いいえ |                                                                                                                                                                                                             |
| maigptCanCodeInterpreter | boolean | いいえ | Whether members of this role may use the code interpreter built-in tool in MaiGPT.                                                                                                                          |
| maigptCanRag             | boolean | いいえ | Whether members of this role may use the knowledge base RAG built-in tool in MaiGPT.                                                                                                                        |
| maigptCanDeepResearch    | boolean | いいえ | Whether members of this role may use Deep Research in MaiGPT. Deep Research reaches the public internet through its own built-in search, so a role that revokes the official web-search tools needs this... |
| maigptCanBrowserTool     | boolean | いいえ | Whether members of this role may use the browser built-in tool in MaiGPT.                                                                                                                                   |
| maigptAllLlms            | boolean | いいえ | Whether members of this role may use every organization-available LLM in MaiGPT. Off = only the bound LLMs; an empty binding then means none.                                                               |
| maigptAllTools           | boolean | いいえ | Whether members of this role may call every official (global) tool in MaiGPT. Off = only the bound tools; an empty binding then means none.                                                                 |
| maigptAllConnectors      | boolean | いいえ | Whether members of this role may call every official (global) MCP connector in MaiGPT. Off = only the bound connectors; an empty binding then means none.                                                   |
| maigptAllSkills          | boolean | いいえ | Whether members of this role may use every official (global) skill in MaiGPT. Off = only the bound skills; an empty binding then means none.                                                                |
| usageStatisticsScope     | object  | いいえ | What this role's usage statistics permission shows: the whole organization, or only the AI assistants granted to the member's roles. A member with any organization-wide granting role sees the whole or... |

**リクエスト構造の例**

```typescript
{
  "name": string
  "canCreateChatbot"?: boolean // 任意
  "canCreateKnowledgeBase"?: boolean // 任意
  "canCreateInbox"?: boolean // 任意
  "canCreateDatabase"?: boolean // 任意
  "canCreateTool"?: boolean // 任意
  "canCreateAgentUiTool"?: boolean // 任意
  "canCreateSkill"?: boolean // 任意
  "maigptCanCodeInterpreter"?: boolean // Whether members of this role may use the code interpreter built-in tool in MaiGPT. (任意)
  "maigptCanRag"?: boolean // Whether members of this role may use the knowledge base RAG built-in tool in MaiGPT. (任意)
  "maigptCanDeepResearch"?: boolean // Whether members of this role may use Deep Research in MaiGPT. Deep Research reaches the public internet through its own built-in search, so a role that revokes the official web-search tools needs this switch too. (任意)
  "maigptCanBrowserTool"?: boolean // Whether members of this role may use the browser built-in tool in MaiGPT. (任意)
  "maigptAllLlms"?: boolean // Whether members of this role may use every organization-available LLM in MaiGPT. Off = only the bound LLMs; an empty binding then means none. (任意)
  "maigptAllTools"?: boolean // Whether members of this role may call every official (global) tool in MaiGPT. Off = only the bound tools; an empty binding then means none. (任意)
  "maigptAllConnectors"?: boolean // Whether members of this role may call every official (global) MCP connector in MaiGPT. Off = only the bound connectors; an empty binding then means none. (任意)
  "maigptAllSkills"?: boolean // Whether members of this role may use every official (global) skill in MaiGPT. Off = only the bound skills; an empty binding then means none. (任意)
  "usageStatisticsScope"?:  // What this role's usage statistics permission shows: the whole organization, or only the AI assistants granted to the member's roles. A member with any organization-wide granting role sees the whole organization.

* `organization` - Organization-wide
* `accessible_chatbots` - Authorized AI assistants only (任意)
  {
  }
}
```

**リクエストのサンプル値**

```json
{
  "name": "サンプル名",
  "canCreateChatbot": true,
  "canCreateKnowledgeBase": true,
  "canCreateInbox": true,
  "canCreateDatabase": true,
  "canCreateTool": true,
  "canCreateAgentUiTool": true,
  "canCreateSkill": true,
  "maigptCanCodeInterpreter": true,
  "maigptCanRag": true,
  "maigptCanDeepResearch": true,
  "maigptCanBrowserTool": true,
  "maigptAllLlms": true,
  "maigptAllTools": true,
  "maigptAllConnectors": true,
  "maigptAllSkills": true,
  "usageStatisticsScope": {}
}
```

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出し例 (Shell)
curl -X POST "https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/groups/550e8400-e29b-41d4-a716-446655440000/batch-deactivate-credit-quota/" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "サンプル名",
    "canCreateChatbot": true,
    "canCreateKnowledgeBase": true,
    "canCreateInbox": true,
    "canCreateDatabase": true,
    "canCreateTool": true,
    "canCreateAgentUiTool": true,
    "canCreateSkill": true,
    "maigptCanCodeInterpreter": true,
    "maigptCanRag": true,
    "maigptCanDeepResearch": true,
    "maigptCanBrowserTool": true,
    "maigptAllLlms": true,
    "maigptAllTools": true,
    "maigptAllConnectors": true,
    "maigptAllSkills": true,
    "usageStatisticsScope": {}
  }'

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
};

// リクエスト内容 (payload)
const data = {
    "name": "サンプル名",
    "canCreateChatbot": true,
    "canCreateKnowledgeBase": true,
    "canCreateInbox": true,
    "canCreateDatabase": true,
    "canCreateTool": true,
    "canCreateAgentUiTool": true,
    "canCreateSkill": true,
    "maigptCanCodeInterpreter": true,
    "maigptCanRag": true,
    "maigptCanDeepResearch": true,
    "maigptCanBrowserTool": true,
    "maigptAllLlms": true,
    "maigptAllTools": true,
    "maigptAllConnectors": true,
    "maigptAllSkills": true,
    "usageStatisticsScope": {}
  };

axios.post("https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/groups/550e8400-e29b-41d4-a716-446655440000/batch-deactivate-credit-quota/", data, config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/groups/550e8400-e29b-41d4-a716-446655440000/batch-deactivate-credit-quota/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY",
    "Content-Type": "application/json"
}

# リクエストボディ (payload)
data = {
    "name": "サンプル名",
    "canCreateChatbot": True,
    "canCreateKnowledgeBase": True,
    "canCreateInbox": True,
    "canCreateDatabase": True,
    "canCreateTool": True,
    "canCreateAgentUiTool": True,
    "canCreateSkill": True,
    "maigptCanCodeInterpreter": True,
    "maigptCanRag": True,
    "maigptCanDeepResearch": True,
    "maigptCanBrowserTool": True,
    "maigptAllLlms": True,
    "maigptAllTools": True,
    "maigptAllConnectors": True,
    "maigptAllSkills": True,
    "usageStatisticsScope": {}
}

response = requests.post(url, json=data, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->post("https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/groups/550e8400-e29b-41d4-a716-446655440000/batch-deactivate-credit-quota/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY',
            'Content-Type' => 'application/json'
        ],
        'json' => [
            'name' => 'サンプル名',
            'canCreateChatbot' => true,
            'canCreateKnowledgeBase' => true,
            'canCreateInbox' => true,
            'canCreateDatabase' => true,
            'canCreateTool' => true,
            'canCreateAgentUiTool' => true,
            'canCreateSkill' => true,
            'maigptCanCodeInterpreter' => true,
            'maigptCanRag' => true,
            'maigptCanDeepResearch' => true,
            'maigptCanBrowserTool' => true,
            'maigptAllLlms' => true,
            'maigptAllTools' => true,
            'maigptAllConnectors' => true,
            'maigptAllSkills' => true,
            'usageStatisticsScope' => new \stdClass()
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンス内容

**ステータスコード: 200**

**レスポンス構造の例**

```typescript
{
  "id": string (uuid)
  "name": string
  "type": 
  {
  }
  "permissions": [
    object
  ]
  "membersPreview": [
    string
  ]
  "membersCount": integer // 残りのメンバー数を返します（一覧に表示される 3 人を除いた数）。フロントエンドの +N バッジ表示に使用します

リソースの count とは異なります：
- members_count: total - 3 を返します（+N バッジ用）。None は合計が 3 以下であることを示します
- chatbots_count/knowledge_bases_count/inboxes_count: 合計数を返します
  "chatbotsCount": integer
  "chatbotsPreview": [
    string
  ]
  "knowledgeBasesCount": integer
  "knowledgeBasesPreview": [
    string
  ]
  "inboxesCount": integer
  "inboxesPreview": [
    string
  ]
  "databasesCount": integer
  "databasesPreview": [
    string
  ]
  "canCreateChatbot"?: boolean // 任意
  "canCreateKnowledgeBase"?: boolean // 任意
  "canCreateInbox"?: boolean // 任意
  "canCreateDatabase"?: boolean // 任意
  "canCreateTool"?: boolean // 任意
  "canCreateAgentUiTool"?: boolean // 任意
  "canCreateSkill"?: boolean // 任意
  "maigptCanCodeInterpreter"?: boolean // Whether members of this role may use the code interpreter built-in tool in MaiGPT. (任意)
  "maigptCanRag"?: boolean // Whether members of this role may use the knowledge base RAG built-in tool in MaiGPT. (任意)
  "maigptCanDeepResearch"?: boolean // Whether members of this role may use Deep Research in MaiGPT. Deep Research reaches the public internet through its own built-in search, so a role that revokes the official web-search tools needs this switch too. (任意)
  "maigptCanBrowserTool"?: boolean // Whether members of this role may use the browser built-in tool in MaiGPT. (任意)
  "maigptAllLlms"?: boolean // Whether members of this role may use every organization-available LLM in MaiGPT. Off = only the bound LLMs; an empty binding then means none. (任意)
  "maigptAllTools"?: boolean // Whether members of this role may call every official (global) tool in MaiGPT. Off = only the bound tools; an empty binding then means none. (任意)
  "maigptAllConnectors"?: boolean // Whether members of this role may call every official (global) MCP connector in MaiGPT. Off = only the bound connectors; an empty binding then means none. (任意)
  "maigptAllSkills"?: boolean // Whether members of this role may use every official (global) skill in MaiGPT. Off = only the bound skills; an empty binding then means none. (任意)
  "usageStatisticsScope"?:  // What this role's usage statistics permission shows: the whole organization, or only the AI assistants granted to the member's roles. A member with any organization-wide granting role sees the whole organization.

* `organization` - Organization-wide
* `accessible_chatbots` - Authorized AI assistants only (任意)
  {
  }
  "createdAt": string (timestamp)
}
```

**レスポンス値の例**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "name": "レスポンス文字列",
  "type": {},
  "permissions": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "レスポンス例の名前",
      "description": "レスポンス例の説明"
    }
  ],
  "membersPreview": [
    "レスポンス文字列"
  ],
  "membersCount": 456,
  "chatbotsCount": 456,
  "chatbotsPreview": [
    "レスポンス文字列"
  ],
  "knowledgeBasesCount": 456,
  "knowledgeBasesPreview": [
    "レスポンス文字列"
  ],
  "inboxesCount": 456,
  "inboxesPreview": [
    "レスポンス文字列"
  ],
  "databasesCount": 456,
  "databasesPreview": [
    "レスポンス文字列"
  ],
  "canCreateChatbot": false,
  "canCreateKnowledgeBase": false,
  "canCreateInbox": false,
  "canCreateDatabase": false,
  "canCreateTool": false,
  "canCreateAgentUiTool": false,
  "canCreateSkill": false,
  "maigptCanCodeInterpreter": false,
  "maigptCanRag": false,
  "maigptCanDeepResearch": false,
  "maigptCanBrowserTool": false,
  "maigptAllLlms": false,
  "maigptAllTools": false,
  "maigptAllConnectors": false,
  "maigptAllSkills": false,
  "usageStatisticsScope": {},
  "createdAt": "レスポンス文字列"
}
```

***

### 受信トレイのクォータ設定を一覧表示 <a href="#inboxes-credit-quotas-list" id="inboxes-credit-quotas-list"></a>

GET `/api/v1/inboxes/{inboxPk}/credit-quotas/`

{% hint style="info" %}
**必要な権限**：Credit 管理権限。**課金モード**：組織は Credit 課金モードである必要があります。無効化されたクォータも含まれ、新しい順に並びます。
{% endhint %}

#### パラメータ

| パラメータ名     | 必須 | 型       | 説明                                             |
| ---------- | -- | ------- | ---------------------------------------------- |
| `inboxPk`  | ✅  | string  |                                                |
| `page`     | ❌  | integer | A page number within the paginated result set. |
| `pageSize` | ❌  | integer | Number of results to return per page.          |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出し例 (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/inboxes/{inboxPk}/credit-quotas/?page=1&pageSize=1" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/inboxes/{inboxPk}/credit-quotas/?page=1&pageSize=1", config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/inboxes/{inboxPk}/credit-quotas/?page=1&pageSize=1"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/inboxes/{inboxPk}/credit-quotas/?page=1&pageSize=1", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンス内容

**ステータスコード: 200**

**レスポンス構造の例**

```typescript
{
  "count": integer
  "next"?: string (uri) // 任意
  "previous"?: string (uri) // 任意
  "results": [
    {
      "id": string (uuid)
      "inbox": object
      "quotaLimit": string (decimal) // Maximum credits this inbox may consume
      "consumedAmount": string (decimal) // Credits consumed so far (updated via F() for concurrency safety)
      "remaining": string (decimal)
      "validFrom": string (timestamp)
      "validUntil": string (timestamp) // NULL means permanent
      "resetPeriod":  // Cycle on which consumed_amount is automatically zeroed; "none" keeps the one-shot ceiling

* `none` - No Reset
* `daily` - Daily
* `weekly` - Weekly
* `monthly` - Monthly
      {
      }
      "nextResetAt": string (timestamp) // Local-midnight boundary of the next automatic reset; NULL when reset_period is "none"
      "isActive": boolean
      "expiredAt": string (timestamp) // Actual deactivation time (cron or manual)
      "createdBy": object
      "note": string
      "createdAt": string (timestamp)
      "updatedAt": string (timestamp)
    }
  ]
}
```

**レスポンス値の例**

```json
{
  "count": 123,
  "next": "http://api.example.org/accounts/?page=4",
  "previous": "http://api.example.org/accounts/?page=2",
  "results": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "inbox": {
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "name": "レスポンス例の名前",
        "description": "レスポンス例の説明"
      },
      "quotaLimit": "レスポンス文字列",
      "consumedAmount": "レスポンス文字列",
      "remaining": "レスポンス文字列",
      "validFrom": "レスポンス文字列",
      "validUntil": "レスポンス文字列",
      "resetPeriod": {},
      "nextResetAt": "レスポンス文字列",
      "isActive": false,
      "expiredAt": "レスポンス文字列",
      "createdBy": {
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "name": "レスポンス例の名前",
        "description": "レスポンス例の説明"
      },
      "note": "レスポンス文字列",
      "createdAt": "レスポンス文字列",
      "updatedAt": "レスポンス文字列"
    }
  ]
}
```

***

### 受信トレイの単一クォータ設定を取得 <a href="#inboxes-credit-quotas-retrieve" id="inboxes-credit-quotas-retrieve"></a>

GET `/api/v1/inboxes/{inboxPk}/credit-quotas/{id}/`

{% hint style="info" %}
**必要な権限**：Credit 管理権限。**課金モード**：組織は Credit 課金モードである必要があります。
{% endhint %}

#### パラメータ

| パラメータ名    | 必須 | 型      | 説明 |
| --------- | -- | ------ | -- |
| `id`      | ✅  | string |    |
| `inboxPk` | ✅  | string |    |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出し例 (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/inboxes/{inboxPk}/credit-quotas/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/inboxes/{inboxPk}/credit-quotas/550e8400-e29b-41d4-a716-446655440000/", config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/inboxes/{inboxPk}/credit-quotas/550e8400-e29b-41d4-a716-446655440000/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/inboxes/{inboxPk}/credit-quotas/550e8400-e29b-41d4-a716-446655440000/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンス内容

**ステータスコード: 200**

**レスポンス構造の例**

```typescript
{
  "id": string (uuid)
  "inbox": object
  "quotaLimit": string (decimal) // Maximum credits this inbox may consume
  "consumedAmount": string (decimal) // Credits consumed so far (updated via F() for concurrency safety)
  "remaining": string (decimal)
  "validFrom": string (timestamp)
  "validUntil": string (timestamp) // NULL means permanent
  "resetPeriod":  // Cycle on which consumed_amount is automatically zeroed; "none" keeps the one-shot ceiling

* `none` - No Reset
* `daily` - Daily
* `weekly` - Weekly
* `monthly` - Monthly
  {
  }
  "nextResetAt": string (timestamp) // Local-midnight boundary of the next automatic reset; NULL when reset_period is "none"
  "isActive": boolean
  "expiredAt": string (timestamp) // Actual deactivation time (cron or manual)
  "createdBy": object
  "note": string
  "createdAt": string (timestamp)
  "updatedAt": string (timestamp)
}
```

**レスポンス値の例**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "inbox": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンス例の名前",
    "description": "レスポンス例の説明"
  },
  "quotaLimit": "レスポンス文字列",
  "consumedAmount": "レスポンス文字列",
  "remaining": "レスポンス文字列",
  "validFrom": "レスポンス文字列",
  "validUntil": "レスポンス文字列",
  "resetPeriod": {},
  "nextResetAt": "レスポンス文字列",
  "isActive": false,
  "expiredAt": "レスポンス文字列",
  "createdBy": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンス例の名前",
    "description": "レスポンス例の説明"
  },
  "note": "レスポンス文字列",
  "createdAt": "レスポンス文字列",
  "updatedAt": "レスポンス文字列"
}
```

***

### 対話プラットフォームにクォータを設定 <a href="#inboxes-credit-quotas-create" id="inboxes-credit-quotas-create"></a>

POST `/api/v1/inboxes/{inboxPk}/credit-quotas/`

{% hint style="info" %}
**必要な権限**：Credit 管理権限。**課金モード**：組織は Credit 課金モードである必要があります。リクエスト内容とルールは [クォータの仕組み](#credit-quota-rules) を参照してください。対話プラットフォームに有効なクォータがすでにある場合は `400` を返します。先にそのクォータを無効化してください。MaiGPT の対話プラットフォームにはクォータを設定できず、`400` を返します。
{% endhint %}

#### パラメータ

| パラメータ名    | 必須 | 型      | 説明 |
| --------- | -- | ------ | -- |
| `inboxPk` | ✅  | string |    |

#### リクエストボディ

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

| フィールド       | 型                  | 必須  | 説明 |
| ----------- | ------------------ | --- | -- |
| quotaLimit  | string (decimal)   | はい  |    |
| validFrom   | string (date-time) | はい  |    |
| validUntil  | string (date-time) | いいえ |    |
| note        | string             | いいえ |    |
| resetPeriod | object             | いいえ |    |

**リクエストスキーマの例**

```typescript
{
  "quotaLimit": string (decimal)
  "validFrom": string (date-time)
  "validUntil"?: string (date-time) // 省略可能
  "note"?: string // 省略可能
  "resetPeriod"?:  // 省略可能
  {
  }
}
```

**リクエスト値の例**

```json
{
  "quotaLimit": "500",
  "validFrom": "2026-10-16T00:00:00+08:00",
  "validUntil": "2026-12-31T23:59:59+08:00",
  "resetPeriod": "monthly",
  "note": "Q4 budget"
}
```

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出しの例 (Shell)
curl -X POST "https://api.maiagent.ai/api/v1/inboxes/{inboxPk}/credit-quotas/" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "quotaLimit": "500",
    "validFrom": "2026-10-16T00:00:00+08:00",
    "validUntil": "2026-12-31T23:59:59+08:00",
    "resetPeriod": "monthly",
    "note": "Q4 budget"
  }'

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
};

// リクエストボディ (payload)
const data = {
    "quotaLimit": "500",
    "validFrom": "2026-10-16T00:00:00+08:00",
    "validUntil": "2026-12-31T23:59:59+08:00",
    "resetPeriod": "monthly",
    "note": "Q4 budget"
  };

axios.post("https://api.maiagent.ai/api/v1/inboxes/{inboxPk}/credit-quotas/", data, config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストエラー:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/inboxes/{inboxPk}/credit-quotas/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY",
    "Content-Type": "application/json"
}

# リクエストボディ (payload)
data = {
    "quotaLimit": "500",
    "validFrom": "2026-10-16T00:00:00+08:00",
    "validUntil": "2026-12-31T23:59:59+08:00",
    "resetPeriod": "monthly",
    "note": "Q4 budget"
}

response = requests.post(url, json=data, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストエラー:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->post("https://api.maiagent.ai/api/v1/inboxes/{inboxPk}/credit-quotas/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY',
            'Content-Type' => 'application/json'
        ],
        'json' => [
            'quotaLimit' => '500',
            'validFrom' => '2026-10-16T00:00:00+08:00',
            'validUntil' => '2026-12-31T23:59:59+08:00',
            'resetPeriod' => 'monthly',
            'note' => 'Q4 budget'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストエラー: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンスボディ

**ステータスコード: 201**

**レスポンススキーマの例**

```typescript
{
  "id": string (uuid)
  "inbox": object
  "quotaLimit": string (decimal) // Maximum credits this inbox may consume
  "consumedAmount": string (decimal) // Credits consumed so far (updated via F() for concurrency safety)
  "remaining": string (decimal)
  "validFrom": string (timestamp)
  "validUntil": string (timestamp) // NULL means permanent
  "resetPeriod":  // Cycle on which consumed_amount is automatically zeroed; "none" keeps the one-shot ceiling

* `none` - No Reset
* `daily` - Daily
* `weekly` - Weekly
* `monthly` - Monthly
  {
  }
  "nextResetAt": string (timestamp) // Local-midnight boundary of the next automatic reset; NULL when reset_period is "none"
  "isActive": boolean
  "expiredAt": string (timestamp) // Actual deactivation time (cron or manual)
  "createdBy": object
  "note": string
  "createdAt": string (timestamp)
  "updatedAt": string (timestamp)
}
```

**レスポンス値の例**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "inbox": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンスのサンプル名",
    "description": "レスポンスのサンプル説明"
  },
  "quotaLimit": "レスポンス文字列",
  "consumedAmount": "レスポンス文字列",
  "remaining": "レスポンス文字列",
  "validFrom": "レスポンス文字列",
  "validUntil": "レスポンス文字列",
  "resetPeriod": {},
  "nextResetAt": "レスポンス文字列",
  "isActive": false,
  "expiredAt": "レスポンス文字列",
  "createdBy": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンスのサンプル名",
    "description": "レスポンスのサンプル説明"
  },
  "note": "レスポンス文字列",
  "createdAt": "レスポンス文字列",
  "updatedAt": "レスポンス文字列"
}
```

***

### 対話プラットフォームのクォータ設定を更新 <a href="#inboxes-credit-quotas-partial-update" id="inboxes-credit-quotas-partial-update"></a>

PATCH `/api/v1/inboxes/{inboxPk}/credit-quotas/{id}/`

{% hint style="info" %}
**必要な権限**：Credit 管理権限。**課金モード**：組織は Credit 課金モードである必要があります。変更するフィールド（`quotaLimit`、`validUntil`、`resetPeriod`、`note`）のみを送信してください。有効期間の開始日時は変更できません。`quotaLimit` は使用済みのクレジット数以上である必要があります。無効化済みのクォータは更新できず、`400` を返します。
{% endhint %}

#### パラメータ

| パラメータ名    | 必須 | 型      | 説明 |
| --------- | -- | ------ | -- |
| `id`      | ✅  | string |    |
| `inboxPk` | ✅  | string |    |

#### リクエストボディ

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

| フィールド       | 型                                           | 必須  | 説明                                                                         |
| ----------- | ------------------------------------------- | --- | -------------------------------------------------------------------------- |
| quotaLimit  | string (decimal)                            | いいえ |                                                                            |
| validUntil  | string (date-time)                          | いいえ |                                                                            |
| note        | string                                      | いいえ |                                                                            |
| resetPeriod | string (enum: none, daily, weekly, monthly) | いいえ | `none`: No Reset ; `daily`: Daily ; `weekly`: Weekly ; `monthly`: Monthly; |

**リクエストスキーマの例**

```typescript
{
  "quotaLimit"?: string (decimal) // 省略可能
  "validUntil"?: string (date-time) // 省略可能
  "note"?: string // 省略可能
  "resetPeriod"?: string (enum: none, daily, weekly, monthly) // * `none` - No Reset
* `daily` - Daily
* `weekly` - Weekly
* `monthly` - Monthly (省略可能)
}
```

**リクエスト値の例**

```json
{
  "quotaLimit": "サンプル文字列",
  "validUntil": "2025-01-01T00:00:00.000Z",
  "note": "サンプル文字列",
  "resetPeriod": "none"
}
```

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出しの例 (Shell)
curl -X PATCH "https://api.maiagent.ai/api/v1/inboxes/{inboxPk}/credit-quotas/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "quotaLimit": "サンプル文字列",
    "validUntil": "2025-01-01T00:00:00.000Z",
    "note": "サンプル文字列",
    "resetPeriod": "none"
  }'

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
};

// リクエストボディ (payload)
const data = {
    "quotaLimit": "サンプル文字列",
    "validUntil": "2025-01-01T00:00:00.000Z",
    "note": "サンプル文字列",
    "resetPeriod": "none"
  };

axios.patch("https://api.maiagent.ai/api/v1/inboxes/{inboxPk}/credit-quotas/550e8400-e29b-41d4-a716-446655440000/", data, config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストエラー:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/inboxes/{inboxPk}/credit-quotas/550e8400-e29b-41d4-a716-446655440000/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY",
    "Content-Type": "application/json"
}

# リクエストボディ (payload)
data = {
    "quotaLimit": "サンプル文字列",
    "validUntil": "2025-01-01T00:00:00.000Z",
    "note": "サンプル文字列",
    "resetPeriod": "none"
}

response = requests.patch(url, json=data, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストエラー:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->patch("https://api.maiagent.ai/api/v1/inboxes/{inboxPk}/credit-quotas/550e8400-e29b-41d4-a716-446655440000/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY',
            'Content-Type' => 'application/json'
        ],
        'json' => [
            'quotaLimit' => 'サンプル文字列',
            'validUntil' => '2025-01-01T00:00:00.000Z',
            'note' => 'サンプル文字列',
            'resetPeriod' => 'none'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストエラー: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンスボディ

**ステータスコード: 200**

**レスポンススキーマの例**

```typescript
{
  "id": string (uuid)
  "inbox": object
  "quotaLimit": string (decimal) // Maximum credits this inbox may consume
  "consumedAmount": string (decimal) // Credits consumed so far (updated via F() for concurrency safety)
  "remaining": string (decimal)
  "validFrom": string (timestamp)
  "validUntil": string (timestamp) // NULL means permanent
  "resetPeriod":  // Cycle on which consumed_amount is automatically zeroed; "none" keeps the one-shot ceiling

* `none` - No Reset
* `daily` - Daily
* `weekly` - Weekly
* `monthly` - Monthly
  {
  }
  "nextResetAt": string (timestamp) // Local-midnight boundary of the next automatic reset; NULL when reset_period is "none"
  "isActive": boolean
  "expiredAt": string (timestamp) // Actual deactivation time (cron or manual)
  "createdBy": object
  "note": string
  "createdAt": string (timestamp)
  "updatedAt": string (timestamp)
}
```

**レスポンス値の例**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "inbox": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンスのサンプル名",
    "description": "レスポンスのサンプル説明"
  },
  "quotaLimit": "レスポンス文字列",
  "consumedAmount": "レスポンス文字列",
  "remaining": "レスポンス文字列",
  "validFrom": "レスポンス文字列",
  "validUntil": "レスポンス文字列",
  "resetPeriod": {},
  "nextResetAt": "レスポンス文字列",
  "isActive": false,
  "expiredAt": "レスポンス文字列",
  "createdBy": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンスのサンプル名",
    "description": "レスポンスのサンプル説明"
  },
  "note": "レスポンス文字列",
  "createdAt": "レスポンス文字列",
  "updatedAt": "レスポンス文字列"
}
```

***

### 対話プラットフォームのクォータ設定を無効化 <a href="#inboxes-credit-quotas-destroy" id="inboxes-credit-quotas-destroy"></a>

DELETE `/api/v1/inboxes/{inboxPk}/credit-quotas/{id}/`

{% hint style="info" %}
**必要な権限**：Credit 管理権限。**課金モード**：組織が Credit 課金モードである必要があります。成功時は `204` を返します。無効化後も対話プラットフォームの「クォータが必要」は有効のままで、新しいクォータを設定するかクォータ制限を解除するまで AI の返信は停止します。すでに無効化されているクォータを再度無効化すると `400` を返します。
{% endhint %}

#### パラメータ

| パラメータ名    | 必須 | 型      | 説明 |
| --------- | -- | ------ | -- |
| `id`      | ✅  | string |    |
| `inboxPk` | ✅  | string |    |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出し例 (Shell)
curl -X DELETE "https://api.maiagent.ai/api/v1/inboxes/{inboxPk}/credit-quotas/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

// リクエスト内容 (payload)
const data = null;

axios.delete("https://api.maiagent.ai/api/v1/inboxes/{inboxPk}/credit-quotas/550e8400-e29b-41d4-a716-446655440000/", data, config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/inboxes/{inboxPk}/credit-quotas/550e8400-e29b-41d4-a716-446655440000/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.delete(url, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->delete("https://api.maiagent.ai/api/v1/inboxes/{inboxPk}/credit-quotas/550e8400-e29b-41d4-a716-446655440000/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンス内容

| ステータスコード | 説明               |
| -------- | ---------------- |
| 204      | No response body |

***

### 対話プラットフォームでクォータを必須にするかを設定 <a href="#organizations-credit-quota-inboxes-credit-quota-required-partial-update" id="organizations-credit-quota-inboxes-credit-quota-required-partial-update"></a>

PATCH `/api/v1/organizations/{organizationPk}/credit-quota-inboxes/{id}/credit-quota-required/`

{% hint style="info" %}
**必要な権限**：Credit 管理権限。**課金モード**：組織が Credit 課金モードである必要があります。リクエスト内容は `{"creditQuotaRequired": true}` または `false` で、パスの `id` は対話プラットフォーム ID です。`false`（クォータ制限の解除）に設定すると、有効なクォータも併せて無効化され、AI の返信は組織のウォレットを使用します。`true` に設定すると、クォータを設定するまで対話プラットフォームでの AI の返信は停止します。レスポンスは、その対話プラットフォームの現在のクォータ状況です。
{% endhint %}

#### パラメータ

| パラメータ名           | 必須 | 型      | 説明                        |
| ---------------- | -- | ------ | ------------------------- |
| `id`             | ✅  | string |                           |
| `organizationPk` | ✅  | string | この組織 ID を識別する UUID 文字列です。 |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出し例 (Shell)
curl -X PATCH "https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/credit-quota-inboxes/550e8400-e29b-41d4-a716-446655440000/credit-quota-required/" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
};

// リクエスト内容 (payload)
const data = {};

axios.patch("https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/credit-quota-inboxes/550e8400-e29b-41d4-a716-446655440000/credit-quota-required/", data, config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/credit-quota-inboxes/550e8400-e29b-41d4-a716-446655440000/credit-quota-required/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY",
    "Content-Type": "application/json"
}

# リクエスト内容 (payload)
data = {}

response = requests.patch(url, json=data, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->patch("https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/credit-quota-inboxes/550e8400-e29b-41d4-a716-446655440000/credit-quota-required/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY',
            'Content-Type' => 'application/json'
        ],
        'json' => new \stdClass()
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンス内容

**ステータスコード: 200**

**レスポンス構造の例**

```typescript
{
  "id": string (uuid)
  "name": string
  "channelType": 
  {
  }
  "channelTypeLabel": string
  "webChatAccessType": string // Sub-type for web channels (web = public embed, admin = internal Q&A, api = completions).

A chatbot ships with three same-named web inboxes, so the frontend needs
this to tell them apart. None for non-web channels. Reads the prefetched
generic ``channel`` relation (no extra query on the list path).
  "chatbot": object
  "creditQuotaRequired": boolean // When True, this inbox must have an active credit quota for the AI to reply
  "activeQuota": object // Return the most recent quota summary (active first), via prefetch to avoid N+1.
  "canUpdate": boolean // Return whether the current user can update this resource.
}
```

**レスポンス値の例**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "name": "レスポンス文字列",
  "channelType": {},
  "channelTypeLabel": "レスポンス文字列",
  "webChatAccessType": "レスポンス文字列",
  "chatbot": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンスの名前の例",
    "description": "レスポンスの説明の例"
  },
  "creditQuotaRequired": false,
  "activeQuota": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンスの名前の例",
    "description": "レスポンスの説明の例"
  },
  "canUpdate": false
}
```

***

### 自分の割り当て枠を照会 <a href="#organizations-me-credit-quota-retrieve" id="organizations-me-credit-quota-retrieve"></a>

GET `/api/v1/organizations/{organizationPk}/me/credit-quota/`

{% hint style="info" %}
**必要な権限**：追加の権限は不要です。組織のすべてのメンバーが自分の割り当て枠を照会できます。**課金方式**：組織は Credit 課金方式を使用する必要があります。
{% endhint %}

#### パラメータ

| パラメータ名           | 必須 | 型      | 説明                                   |
| ---------------- | -- | ------ | ------------------------------------ |
| `organizationPk` | ✅  | string | A UUID string identifying this 組織 ID |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出し例 (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/me/credit-quota/" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/me/credit-quota/", config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/me/credit-quota/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/me/credit-quota/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンスボディ

| ステータスコード | 説明               |
| -------- | ---------------- |
| 200      | No response body |

***

### 自分が所属するロールの割り当て枠を照会 <a href="#organizations-me-group-credit-quotas-retrieve" id="organizations-me-group-credit-quotas-retrieve"></a>

GET `/api/v1/organizations/{organizationPk}/me/group-credit-quotas/`

{% hint style="info" %}
**必要な権限**：追加の権限は不要です。組織のすべてのメンバーが自分の割り当て枠を照会できます。**課金方式**：組織は Credit 課金方式を使用する必要があります。
{% endhint %}

#### パラメータ

| パラメータ名           | 必須 | 型      | 説明                                   |
| ---------------- | -- | ------ | ------------------------------------ |
| `organizationPk` | ✅  | string | A UUID string identifying this 組織 ID |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出し例 (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/me/group-credit-quotas/" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/me/group-credit-quotas/", config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/me/group-credit-quotas/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/organizations/550e8400-e29b-41d4-a716-446655440000/me/group-credit-quotas/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンスボディ

| ステータスコード | 説明               |
| -------- | ---------------- |
| 200      | No response body |

***

### 料金ルールの一覧を取得 <a href="#credit-pricing-rules-list" id="credit-pricing-rules-list"></a>

GET `/api/v1/credit/pricing-rules/`

{% hint style="info" %}
**認証不要**：API Key なしで呼び出せます。**呼び出し上限**：送信元 IP ごとに毎分 60 回です。上限を超えると HTTP 429 が返されます。
{% endhint %}

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出し例 (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/credit/pricing-rules/" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/credit/pricing-rules/", config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/credit/pricing-rules/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/credit/pricing-rules/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンスボディ

**ステータスコード: 200**

**レスポンス構造の例**

```typescript
[
  {
    "id": string (uuid)
    "creditItem": string (uuid)
    "provider": string
    "modelCode": string
    "creditPerUnit": string (decimal)
    "priority": integer // Higher priority = more specific (model-specific=20, provider-level=10)
    "effectiveFrom": string (timestamp)
    "effectiveUntil": string (timestamp)
    "isActive": boolean
    "notes": string // Internal notes about this pricing rule
  }
]
```

**レスポンス値の例**

```json
[
  {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "creditItem": "550e8400-e29b-41d4-a716-446655440000",
    "provider": "レスポンス文字列",
    "modelCode": "レスポンス文字列",
    "creditPerUnit": "レスポンス文字列",
    "priority": 456,
    "effectiveFrom": "レスポンス文字列",
    "effectiveUntil": "レスポンス文字列",
    "isActive": false,
    "notes": "レスポンス文字列"
  }
]
```

***

### 単一の料金ルールを取得 <a href="#credit-pricing-rules-retrieve" id="credit-pricing-rules-retrieve"></a>

GET `/api/v1/credit/pricing-rules/{id}/`

{% hint style="info" %}
**認証不要**：API Key なしで呼び出せます。**呼び出し上限**：送信元 IP ごとに毎分 60 回です。上限を超えると HTTP 429 が返されます。
{% endhint %}

#### パラメータ

| パラメータ名 | 必須 | 型      | 説明                                                  |
| ------ | -- | ------ | --------------------------------------------------- |
| `id`   | ✅  | string | A UUID string identifying this Credit Pricing Rule. |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出し例 (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/credit/pricing-rules/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/credit/pricing-rules/550e8400-e29b-41d4-a716-446655440000/", config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/credit/pricing-rules/550e8400-e29b-41d4-a716-446655440000/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/credit/pricing-rules/550e8400-e29b-41d4-a716-446655440000/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンス内容

**ステータスコード: 200**

**レスポンススキーマの例**

```typescript
{
  "id": string (uuid)
  "creditItem": string (uuid)
  "provider": string
  "modelCode": string
  "creditPerUnit": string (decimal)
  "priority": integer // Higher priority = more specific (model-specific=20, provider-level=10)
  "effectiveFrom": string (timestamp)
  "effectiveUntil": string (timestamp)
  "isActive": boolean
  "notes": string // Internal notes about this pricing rule
}
```

**レスポンス値の例**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "creditItem": "550e8400-e29b-41d4-a716-446655440000",
  "provider": "レスポンス文字列",
  "modelCode": "レスポンス文字列",
  "creditPerUnit": "レスポンス文字列",
  "priority": 456,
  "effectiveFrom": "レスポンス文字列",
  "effectiveUntil": "レスポンス文字列",
  "isActive": false,
  "notes": "レスポンス文字列"
}
```

***

### 課金項目の一覧を取得 <a href="#credit-items-list" id="credit-items-list"></a>

GET `/api/v1/credit/items/`

{% hint style="info" %}
**ログイン不要**：API Key なしで呼び出せます。**レート制限**：送信元 IP ごとに毎分 60 回です。上限を超えると HTTP 429 を返します。
{% endhint %}

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出しの例 (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/credit/items/" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/credit/items/", config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/credit/items/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/credit/items/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンス内容

**ステータスコード: 200**

**レスポンススキーマの例**

```typescript
[
  {
    "id": string (uuid)
    "code": string // Unique identifier like llm_input_token
    "name": string
    "category": 
    {
    }
    "unit": string // token, character, minute, etc.
    "creditPerUnit": string (decimal)
    "baseCreditPerUnit": string (decimal)
    "effectiveFrom": string (timestamp)
    "isActive": boolean
    "description": string
    "displayGroup": string // Items with the same display_group are merged into one expandable row on the pricing page. Empty means the item stands alone.
    "displayOrder": integer // Controls display ordering. Lower numbers appear first.
    "attachmentRetentionDays": integer // Current Config retention setting, so the pricing-page tooltip day count follows admin changes.
    "gatewayTrafficFeeDefaultPercent": string // System default AI Gateway traffic-fee percent, for pricing pages without an org context.

This endpoint is AllowAny with no organization, so it can only surface
the system default ("for reference only" on the frontend); logged-in
pricing pages read the organization's actual percent from the
organization detail API instead.
  }
]
```

**レスポンス値の例**

```json
[
  {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "code": "レスポンス文字列",
    "name": "レスポンス文字列",
    "category": {},
    "unit": "レスポンス文字列",
    "creditPerUnit": "レスポンス文字列",
    "baseCreditPerUnit": "レスポンス文字列",
    "effectiveFrom": "レスポンス文字列",
    "isActive": false,
    "description": "レスポンス文字列",
    "displayGroup": "レスポンス文字列",
    "displayOrder": 456,
    "attachmentRetentionDays": 456,
    "gatewayTrafficFeeDefaultPercent": "レスポンス文字列"
  }
]
```

***

### 単一の課金項目を取得 <a href="#credit-items-retrieve" id="credit-items-retrieve"></a>

GET `/api/v1/credit/items/{id}/`

{% hint style="info" %}
**ログイン不要**：API Key なしで呼び出せます。**レート制限**：送信元 IP ごとに毎分 60 回です。上限を超えると HTTP 429 を返します。
{% endhint %}

#### パラメータ

| パラメータ名 | 必須 | 型      | 説明                                          |
| ------ | -- | ------ | ------------------------------------------- |
| `id`   | ✅  | string | A UUID string identifying this Credit Item. |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出しの例 (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/credit/items/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/credit/items/550e8400-e29b-41d4-a716-446655440000/", config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/credit/items/550e8400-e29b-41d4-a716-446655440000/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/credit/items/550e8400-e29b-41d4-a716-446655440000/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンス内容

**ステータスコード: 200**

**レスポンススキーマの例**

```typescript
{
  "id": string (uuid)
  "code": string // Unique identifier like llm_input_token
  "name": string
  "category": 
  {
  }
  "unit": string // token, character, minute, etc.
  "creditPerUnit": string (decimal)
  "baseCreditPerUnit": string (decimal)
  "effectiveFrom": string (timestamp)
  "isActive": boolean
  "description": string
  "displayGroup": string // Items with the same display_group are merged into one expandable row on the pricing page. Empty means the item stands alone.
  "displayOrder": integer // Controls display ordering. Lower numbers appear first.
  "attachmentRetentionDays": integer // Current Config retention setting, so the pricing-page tooltip day count follows admin changes.
  "gatewayTrafficFeeDefaultPercent": string // System default AI Gateway traffic-fee percent, for pricing pages without an org context.

This endpoint is AllowAny with no organization, so it can only surface
the system default ("for reference only" on the frontend); logged-in
pricing pages read the organization's actual percent from the
organization detail API instead.
}
```

**レスポンス値の例**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "code": "レスポンス文字列",
  "name": "レスポンス文字列",
  "category": {},
  "unit": "レスポンス文字列",
  "creditPerUnit": "レスポンス文字列",
  "baseCreditPerUnit": "レスポンス文字列",
  "effectiveFrom": "レスポンス文字列",
  "isActive": false,
  "description": "レスポンス文字列",
  "displayGroup": "レスポンス文字列",
  "displayOrder": 456,
  "attachmentRetentionDays": 456,
  "gatewayTrafficFeeDefaultPercent": "レスポンス文字列"
}
```

***


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.maiagent.ai/api/ja/api-reference/credit.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
