メインコンテンツへスキップ

Documentation Index

Fetch the complete documentation index at: https://docs.qoder.com/llms.txt

Use this file to discover all available pages before exploring further.

このドキュメントについて

Credits の利用イベントとサマリーをメンバーまたは組織単位で取得し、組織の Shared Add-on Credits 明細を照会します。事前に API キーの取得 を完了し、共通仕様 を参照してください。

前提条件

  • 対象組織に紐づく有効な API キー。

API 一覧

1. 使用量イベント一覧

GET /v1/organizations/{organization_id}/members/{member_id}/usage-events 指定メンバーの集計済み Credits 使用量レコードをページネーションで取得します。

パスパラメータ

パラメータ必須説明
organization_idstringはい組織 ID
member_idstringはいメンバー ID

クエリパラメータ

パラメータ必須説明
startDatestringいいえ開始時間;RFC 3339 形式または Unix ミリ秒タイムスタンプ
endDatestringいいえ終了時間;RFC 3339 形式または Unix ミリ秒タイムスタンプ
sourcesstringいいえソースでフィルタ、カンマ区切り。値:IDECLIJetBrains PluginWebQoderWork
operationsstringいいえ操作でフィルタ、カンマ区切り。値:Inline ChatAskAgentRepo WikiQuestPlan ModeCode ReviewOptimize InputVoice InputExpertsImage
modelTiersstringいいえモデルティアでフィルタ、カンマ区切り。値:AutoPerformanceEfficientLiteUltimateVisionQwen-Coder-Qoder-1.0Kimi-K2.5GLM-5MiniMax-M2.5DeepSeek-V4.0Qwen3.5-PlusStandardPremiumEnterprise
maxResultsintegerいいえページサイズ(デフォルト 20、最大 100)
nextCreditsstringいいえページネーションカーソル

成功レスポンス(200 OK)

使用量レコードあり、次ページあり:
{
  "usages": [
    {
      "timestamp": 1719849600000,
      "userId": "user_abc123",
      "userEmail": "user@example.com",
      "source": "IDE",
      "operation": "Agent",
      "modelTier": "Ultimate",
      "credits": 0.35,
      "cost": 0.35
    },
    {
      "timestamp": 1719849500000,
      "userId": "user_abc123",
      "source": "CLI",
      "operation": "Completion",
      "credits": 0.02,
      "cost": 0.02
    }
  ],
  "maxResults": 20,
  "nextCredits": "eyJwYWdlIjogMn0="
}
一部のレコードでは userEmailmodelTier返されない場合があります。インテグレーション時はオプションフィールドとして処理してください。
使用量レコードなし / 最終ページ:
{

  "usages": [],

  "maxResults": 20
}
nextCredits が空または存在しない場合は最終ページです。

レスポンスフィールド

フィールド説明
usagesarray使用量レコードリスト
usages[].timestampint64開始時間(Unix ミリ秒タイムスタンプ)
usages[].userIdstringユーザー ID
usages[].userEmailstringユーザーメール(空の場合あり)
usages[].sourcestringソース:IDECLIJetBrains PluginWebQoderWork
usages[].operationstring操作:Inline ChatAskAgentRepo WikiQuestPlan ModeCode ReviewOptimize InputVoice InputExpertsImage
usages[].modelTierstringモデルティア(空の場合あり):AutoPerformanceEfficientLiteUltimateVisionQwen-Coder-Qoder-1.0Kimi-K2.5GLM-5MiniMax-M2.5DeepSeek-V4.0Qwen3.5-PlusStandardPremiumEnterprise
usages[].creditsfloat64消費 Credits(小数点以下2桁)
usages[].costfloat64課金換算後のコスト(小数点以下2桁);通常 credits と同額または固定換算比率
maxResultsint32このリクエストのページサイズ
nextCreditsstring次ページカーソル;空は最終ページ

2. 使用量サマリー取得

GET /v1/organizations/{organization_id}/members/{member_id}/usage-summary 指定された期間内のメンバーの Credits 消費を指定ディメンションで集計します。期間は 7 日以内でなければなりません。

パスパラメータ

パラメータ必須説明
organization_idstringはい組織 ID
member_idstringはいメンバー ID

クエリパラメータ

パラメータ必須説明
startDatestringはい開始時間;RFC 3339 形式または Unix ミリ秒タイムスタンプ
endDatestringはい終了時間;RFC 3339 形式または Unix ミリ秒タイムスタンプ
groupBystringはいグループ化ディメンション:source(ソース別)または operation(操作別)

成功レスポンス(200 OK)

ソース別集計(**groupBy=source**):
{
  "summary": {
    "IDE": 12.50,
    "CLI": 3.25
  }
}
操作別集計(**groupBy=operation**):
{
  "summary": {
    "Agent": 8.40,
    "Completion": 5.10,
    "Inline Chat": 2.25
  }
}
使用量データなし:
{
  "summary": {}
}

レスポンスフィールド

フィールド説明
summaryobject集計結果;キーはグループ名(ソースまたは操作)、値は合計 Credits
summary.{key}float64そのグループの合計 Credits 消費(小数点以下2桁)

エラーレスポンス

必須パラメータ欠落(400)
{
  "requestId": "req_abc123",
  "code": "BadRequest",
  "message": "startDate is required"
}
期間超過(400)
{
  "requestId": "req_abc123",
  "code": "BadRequest",
  "message": "date range must not exceed 7 days"
}
無効な groupBy(400)
{
  "requestId": "req_abc123",
  "code": "BadRequest",
  "message": "groupBy is required and must be 'source' or 'operation'"
}

3. 組織使用量イベント一覧

GET /v1/organizations/{organization_id}/usage-events 指定組織の全メンバーの集計済みトークン使用量レコードをページネーションで取得します。レスポンス構造はメンバー使用量イベント API と同一です。

パスパラメータ

パラメータ必須説明
organization_idstringはい組織 ID

クエリパラメータ

パラメータ必須説明
startDatestringいいえ開始時間;RFC 3339 形式または Unix ミリ秒タイムスタンプ
endDatestringいいえ終了時間;RFC 3339 形式または Unix ミリ秒タイムスタンプ
sourcesstringいいえソースでフィルタ、カンマ区切り。値:IDECLIJetBrains PluginWebQoderWork
operationsstringいいえ操作でフィルタ、カンマ区切り。値:Inline ChatAskAgentRepo WikiQuestPlan ModeCode ReviewOptimize InputVoice InputExperts
modelTiersstringいいえモデルティアでフィルタ、カンマ区切り。値:AutoPerformanceEfficientLiteUltimateVisionQwen-Coder-Qoder-1.0Kimi-K2.5GLM-5MiniMax-M2.5DeepSeek-V4.0Qwen3.5-PlusStandardPremiumEnterprise
maxResultsintegerいいえページサイズ(デフォルト 20、最大 100)
nextTokenstringいいえページネーションカーソル

成功レスポンス(200 OK)

{
  "usages": [
    {
      "timestamp": 1719849600000,
      "userId": "user_abc123",
      "userEmail": "user@example.com",
      "source": "IDE",
      "operation": "Agent",
      "modelTier": "Ultimate",
      "credits": 0.35,
      "cost": 0.35
    },
    {
      "timestamp": 1719849500000,
      "userId": "user_def456",
      "source": "CLI",
      "operation": "Ask",
      "credits": -0.02,
      "cost": -0.02
    }
  ],
  "maxResults": 20,
  "nextToken": "eyJwYWdlIjogMn0="
}
一部のレコードでは userEmailmodelTier返されない場合があります。デフォルトではメンバー使用量イベント API と同じ動作をし、正の Credits レコードのみをフィルタしません。返金や修正などの負の値のレコードも返される場合があります。

レスポンスフィールド

レスポンスフィールドの定義は「1. 使用量イベント一覧」と同一です。

4. 組織共有 Shared Add-on Credits 一覧

GET /v1/organizations/{organization_id}/resource-packages 組織単位ですべての Shared Add-on Credits 明細をページネーションで返します。レスポンスには各パッケージのバッチ情報のみが含まれ、集計は含まれません(必要な場合はクライアント側で limitValue / usedValue / remainingValue を合計してください)。

パスパラメータ

パラメータ必須説明
organization_idstringはい組織 ID

クエリパラメータ

パラメータ必須説明
statusstringいいえステータスでフィルタ。値:activeexhaustedexpiredsuspended。未指定時は組織下の削除されていない全パッケージを返却
orderBystringいいえソートフィールド。値:expiresAt(デフォルト)、activatedAtremainingValue
orderstringいいえソート方向。値:asc(デフォルト)、desc
maxResultsintegerいいえページサイズ(デフォルト 20、最大 100)
nextTokenstringいいえ前回レスポンスの nextToken フィールドからのページネーションカーソル

成功レスポンス(200 OK)

Shared Add-on Credits あり、次ページあり:
{
  "resourcePackages": [
    {
      "id": "pkg-001",
      "name": "Enterprise Annual Pack",
      "source": "purchased",
      "status": "active",
      "activatedAt": "2025-01-01T00:00:00Z",
      "expiresAt": "2026-01-01T00:00:00Z",
      "limitValue": 3000.0,
      "usedValue": 800.0,
      "remainingValue": 2200.0,
      "unit": "credits"
    },
    {
      "id": "pkg-002",
      "name": "Trial Pack",
      "source": "trial",
      "status": "exhausted",
      "activatedAt": "2025-03-15T00:00:00Z",
      "expiresAt": "2025-09-15T00:00:00Z",
      "limitValue": 500.0,
      "usedValue": 500.0,
      "remainingValue": 0.0,
      "unit": "credits"
    }
  ],
  "maxResults": 20,
  "nextToken": "eyJwYWdlIjogMn0="
}
一部のパッケージでは activatedAt返されない場合があります(例:未アクティベートのバッチ)。インテグレーション時はオプションフィールドとして処理してください。
Shared Add-on Credits なし / 最終ページ:
{

  "resourcePackages": [],

  "maxResults": 20
}
nextToken が空または存在しない場合は最終ページです。

レスポンスフィールド

フィールド説明
resourcePackagesarrayShared Add-on Credits リスト
resourcePackages[].idstringShared Add-on Credits の一意 ID
resourcePackages[].namestringShared Add-on Credits 名
resourcePackages[].sourcestringクレジットのソース:purchased(購入)、bonus(贈呈)、trial(トライアル)、carryOver(繰り越し)、refund(返金)、dev(開発/テスト)、sales(営業設定)
resourcePackages[].statusstringクレジットステータス:active(有効)、exhausted(使い切り)、expired(期限切れ)、suspended(一時停止)
resourcePackages[].activatedAtstringアクティベーション時刻(RFC 3339 / ISO 8601 形式、UTC、空の場合あり)
resourcePackages[].expiresAtstring有効期限(RFC 3339 / ISO 8601 形式、UTC)
resourcePackages[].limitValuefloat64初期総額度
resourcePackages[].usedValuefloat64消費済み額度
resourcePackages[].remainingValuefloat64残り額度(= limitValue - usedValue
resourcePackages[].unitstring額度単位、通常は credits
maxResultsint32このリクエストのページサイズ
nextTokenstring次ページカーソル。最終ページの場合は返されません

エラーレスポンス

status パラメータ無効(400)
{
  "requestId": "req_abc123",
  "code": "BadRequest",
  "message": "invalid status, must be one of: active, exhausted, expired, suspended"
}
orderBy パラメータ無効(400)
{
  "requestId": "req_def456",
  "code": "BadRequest",
  "message": "invalid orderBy field, must be one of: expiresAt, activatedAt, remainingValue"
}
組織が存在しないまたはアクセス権なし(404)
{
  "requestId": "req_jkl012",
  "code": "NotFound",
  "message": "organization not found or not accessible"
}

ステータス説明

Shared Add-on Credits のステータスマシン:
ステータス説明遷移条件
active有効、消費可能アクティベーション後のデフォルトステータス
exhausted使い切り残り額度がゼロ(注意:使い切ったパッケージは期限切れでも自動的に expired にはなりませんexhausted のまま維持)
expired期限切れ毎時のスケジュールタスクが期限切れの active パッケージを expired に変更
suspended一時停止管理者による手動操作、停止中は消費不可
expired ステータスは毎時の非同期タスクにより更新されるため、実際の期限切れからステータス変更まで最大約 1 時間のウィンドウ期間があります。この期間中、パッケージの statusactive のままですが expiresAt < now となります。正確な「真の利用可能」判定には、クライアント側で status expiresAt を組み合わせて判断してください:
真の利用可能 = status == "active" AND expiresAt > now

使用例

メンバー使用量イベント一覧

curl -X GET "https://api.qoder.com/v1/organizations/org_xxx/members/member_abc123/usage-events?maxResults=20" \
  -H "Authorization: Bearer <api_key>"

日付範囲でフィルタ

curl -X GET "https://api.qoder.com/v1/organizations/org_xxx/members/member_abc123/usage-events?startDate=2025-06-01T00:00:00Z&endDate=2025-06-30T23:59:59Z" \
  -H "Authorization: Bearer <api_key>"

組織使用量イベント一覧

curl -X GET "https://api.qoder.com/v1/organizations/org_xxx/usage-events?maxResults=20" \
  -H "Authorization: Bearer <api_key>"

ソースと操作でフィルタ

curl -X GET "https://api.qoder.com/v1/organizations/org_xxx/members/member_abc123/usage-events?sources=IDE&operations=Ask,Agent" \
  -H "Authorization: Bearer <api_key>"

ソース別使用量サマリー

curl -X GET "https://api.qoder.com/v1/organizations/org_xxx/members/member_abc123/usage-summary?startDate=2026-03-13T00:00:00Z&endDate=2026-03-20T00:00:00Z&groupBy=source" \
  -H "Authorization: Bearer <api_key>"

操作別使用量サマリー

curl -X GET "https://api.qoder.com/v1/organizations/org_xxx/members/member_abc123/usage-summary?startDate=2026-03-13T00:00:00Z&endDate=2026-03-20T00:00:00Z&groupBy=operation" \
  -H "Authorization: Bearer <api_key>"

組織 Shared Add-on Credits 一覧

curl -X GET "https://api.qoder.com/v1/organizations/org_xxx/resource-packages?status=active&orderBy=expiresAt&order=asc&maxResults=20" \
  -H "Authorization: Bearer <api_key>"

Shared Add-on Credits のページネーション

curl -X GET "https://api.qoder.com/v1/organizations/org_xxx/resource-packages?nextToken=eyJwYWdlIjogMn0%3D" \
  -H "Authorization: Bearer <api_key>"
nextToken には URL 予約文字が含まれる場合があります。クエリパラメータとして渡す際は URL エンコードしてください(例:=%3D)。

エラーコード

エラーコードHTTP ステータス説明
BadRequest400リクエストパラメータが無効(例:member_id が空、日付形式が不正、期間超過、groupBy が無効)
Unauthorized401API キーが欠落または無効
Forbidden403この組織へのアクセス権限なし
NotFound404メンバーが見つからない
InternalError500サーバー内部エラー
エラーレスポンスの形式は 共通仕様エラーレスポンス を参照してください。