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

# Devin agent のツール呼び出しを取得する

> Devin Desktop および Devin CLI でチームが行ったエージェントのツール呼び出し（ウェブ検索やコマンド実行など）の回数を、ツール、ユーザー、モデル、IDE、OS 別に集計します。

<Note>
  これは **v2 エンドポイント**です。リクエストボディでサービスキーを渡す v1 の分析 API とは異なり、Bearer トークン認証とクエリパラメーターを利用します。詳しくは下記の[認証](#authentication)を参照してください。
</Note>

<Warning>
  このエンドポイントはリアルタイムの使用量監視を目的としたもの**ではありません**。レート制限は低く設定されています
  (チームごとに 1 時間あたり 10 リクエスト) 。定期的なレポート作成や一括エクスポートに利用してください。
</Warning>

<h2 id="authentication">
  認証
</h2>

このエンドポイントでは **Bearer トークン** 認証を利用します。`Authorization` ヘッダーにあなたのトークンを含めてください：

```
Authorization: Bearer <your_token>
```

**ローカル分析APIの使用** 権限を持つDevinサービスユーザーのAPIキー、または **アナリティクスの読み取り** 権限を持つWindsurf
サービスキーのいずれかを使用してください。それぞれの作成方法については、
[認証](/ja/desktop/accounts/api-reference/analytics-v2-introduction#authentication)を
参照してください。

v1 の [`cascade_tool_usage`](/ja/desktop/accounts/api-reference/cascade-analytics#cascade_tool_usage)
データソースとは異なり、このエンドポイントではDevinサービスユーザーのAPIキーを使用できます。そのため、Cognition プラットフォーム上のチームは
Windsurf のサービスキーがなくてもツール使用状況を取得できます。

<h2 id="metrics">
  メトリクス
</h2>

`metric` クエリパラメーターは必須で、現在は `calls`(エージェントが実行したツール呼び出しの回数)のみ指定できます。
この値は、各行に整数型の `calls` フィールドとして含まれます。`metric` を指定しないリクエスト、または
他のメトリクスを指定したリクエストは `400` エラーで失敗します。

ツール呼び出しは、モデルを問わず、エージェントが [Devin Desktop](/ja/desktop/introducing-devin-desktop)
または [Devin CLI](/ja/cli)(他のエディター内でエージェントとして動作する CLI を含む)でツールを呼び出した時点でカウントされます。
`product` パラメーターも必須で、現在は `agent` のみ指定できます。

<h2 id="tools">
  ツール
</h2>

`tool` でグループ化すると、呼び出しをツールのカテゴリ別に集計できます。この場合、各行には次のいずれかの値を持つ `tool` フィールドが含まれます。

| ツール | 説明 |
| - | - |
| `SEARCH_WEB` | ウェブ検索、ウェブフェッチ、ブラウザの利用 |
| `RUN_COMMAND` | シェルコマンドの実行と、実行中のプロセスとのやり取り |
| `VIEW_FILE` | ファイルおよびノートブックの読み取り |
| `CODE_ACTION` | ファイルの編集、書き込み、パッチ適用 |
| `GREP_SEARCH` | ファイル内容およびコードの検索 |
| `FIND` | ファイル名によるファイルの検索 |
| `LIST_DIRECTORY` | ディレクトリの一覧表示 |
| `MCP_TOOL` | MCPサーバーのツールの呼び出し、およびMCPサーバー、ツール、リソースの一覧表示 |
| `SKILL` | スキルの一覧表示、検索、呼び出し |
| `ASK_USER_QUESTION` | ユーザーへの質問 |
| `MEMORY` | メモリーの読み取りと書き込み |
| `PROPOSE_CODE` | コードの変更の提案 |
| `PROXY_WEB_SERVER` | ローカルウェブサーバーのブラウザプレビュー |
| `DEPLOY_WEB_APP` | ウェブアプリのデプロイ |
| `MQUERY` | コードベース検索 (Riptide) |
| `DEEPWIKI` | DeepWiki へのリクエスト |
| `CODEMAP_GENERATION`、`CODEMAP_SUGGESTIONS` | Codemaps へのリクエスト |
| `OTHER` | 上記のいずれのカテゴリにも該当しない Devin CLI のツール |

すべてのカテゴリがすべてのクライアントで使われるわけではありません。`LIST_DIRECTORY`、`MEMORY`、`PROPOSE_CODE`、
`PROXY_WEB_SERVER`、`DEPLOY_WEB_APP`、`MQUERY` は Devin Desktop のエージェントでのみ記録されます。また、
カテゴリがまだ割り当てられていない新しい Devin CLI のツールは `OTHER` として集計されます。

<h2 id="grouping-and-granularity">
  グループ化と時間粒度
</h2>

`granularity` と `group_by` を利用して、返されるデータの構造を制御します。

* **時間粒度もグループ化も指定しない場合** — 日付範囲全体を集計した 1 行を返します
* **`granularity=daily`** — 各行に `YYYY-MM-DD` 形式の `timestamp` が含まれます
* **`granularity=monthly`** — 各行に `YYYY-MM` 形式の `timestamp` が含まれます
* **`group_by=tool`** — 各行に `tool` が含まれます (上記の [ツール](#tools) を参照)
* **`group_by=user`** — 各行に `user_id` が含まれます。そのユーザーの `user_email` が記録されている場合は、それも含まれます
* **`group_by=model_uid`** — 各行に `model_uid` が含まれます
* **`group_by=ide`** — 各行に `ide` が含まれます
* **`group_by=ide,ide_version`** — 各行に `ide` と `ide_version` が含まれます (`ide_version` でグループ化する場合は、`ide` も指定する必要があります)
* **`group_by=os`** — 各行に `os` が含まれます (例：`darwin` (macOS) 、`windows`、`linux`)

ディメンションは組み合わせて指定できます。例えば `group_by=user,tool` では、各ユーザーが各
ツールを呼び出した回数を集計できます。[Get Output](/ja/desktop/accounts/api-reference/get-output) の `session` および `source` ディメンションは
ここではサポートされていません。
[Get Consumption](/ja/desktop/accounts/api-reference/get-consumption) と同じ `models`、`group_id`、`user_id` フィルターを利用できるほか、カウント対象を 1 つのツールカテゴリに絞り込む `tool` フィルターも指定できます (例：`tool=SEARCH_WEB`) 。`tool` を
受け付けるのはこのエンドポイントのみです。他の Analytics API v2 エンドポイントに指定すると、`400` エラーで失敗します。

<h2 id="example">
  例
</h2>

ユーザーごとのウェブ検索回数を1週間分集計します：

```bash theme={null}
curl "https://server.codeium.com/api/v2alpha/analytics/tools?metric=calls&product=agent&start_date=2026-10-13&end_date=2026-10-19&group_by=user&tool=SEARCH_WEB" \
  -H "Authorization: Bearer $DEVIN_API_KEY"
```

各行は、ユーザー1人あたりの `SEARCH_WEB` の件数を表します。ユーザーごとにすべてのカテゴリを表示したい場合は、`tool` フィルターを外し、代わりに `group_by=user,tool` を追加してください。

<h2 id="pagination">
  ページネーション
</h2>

結果はページ分割され、デフォルトのページサイズは 1,000 行(最大 10,000 行)です。さらに結果がある場合は、
レスポンスの `pagination` オブジェクトに `next_page_cursor` が含まれます。元のクエリパラメーターはそのままにして、この値を `page_cursor` クエリ
パラメーターとして追加したリクエストを送信してください。カーソルは発行元のエンドポイントに紐付けられているため、`/consumption` や `/output` から取得したカーソルは
`400` で拒否されます。

ページカーソルの有効期限は 24 時間です。後続ページのリクエストは、レート制限上の新しいクエリとしてはカウントされません。

<h2 id="rate-limits">
  レート制限
</h2>

このエンドポイントのレート制限は、Team ごとに **1 時間あたり 10 リクエスト** です。この制限を超えると、
サーバーは `Retry-After` ヘッダー付きで `429 Too Many Requests` を返します。

以前のクエリのページング (`next_page_cursor` をたどる操作) は、この制限にカウント**されません**。
カウントされるのは、各レポートの最初のクエリのみです。制限値が低めに設定されているのは、このエンドポイントが
リアルタイムの使用量監視ではなく、定期的なレポート作成向けであるためです。


## OpenAPI

````yaml ja/desktop/accounts/api-reference/analytics-v2-openapi.yaml GET /api/v2alpha/analytics/tools
openapi: 3.1.0
info:
  title: Devin Desktop Analytics API v2
  version: 2.0.0
  description: |
    Analytics API v2 は、Enterprise チーム向けにクレジットおよび ACU消費量、アクティブユーザー、エージェントの出力
    （採用されたコード行数）、エージェントのツール呼び出しの分析を提供します。データは時間単位の集計に基づいており、柔軟なフィルタリング、グループ化、
    カーソル方式のページネーションをサポートします。
servers:
  - url: https://server.codeium.com
security:
  - bearerAuth: []
paths:
  /api/v2alpha/analytics/tools:
    get:
      summary: エージェントのツール呼び出し分析を取得
      description: >
        認証済みチームのエージェントによるツール呼び出しを集計します。必須の `metric` パラメーターで指定できるのは

        `calls` のみです。これは、エージェントが Devin Desktop および Devin CLI で行ったツール呼び出し数で、各行の

        整数フィールドとして返されます。結果は日付範囲、製品、モデル、グループ、ユーザーでフィルタリングでき、

        消費量と同じディメンション（`session` を除く）に加え、`SEARCH_WEB` や `RUN_COMMAND` などの

        ツールカテゴリを表す `tool` でグループ化できます。


        これらのエンドポイントは、定期的なレポート作成と一括エクスポート向けに設計されています。リアルタイムの使用状況監視を目的としたものでは**ありません**。レート制限は低く設定されています（チームごとに1時間あたり10リクエスト）。
      operationId: getTools
      parameters:
        - name: metric
          in: query
          required: true
          schema:
            type: string
          description: |
            返すメトリクス。各行にフィールドとして含まれます。サポートされるメトリクス：
            - `calls` — エージェントが行ったツール呼び出し数
          example: calls
        - name: start_date
          in: query
          required: true
          schema:
            type: string
            format: date
          description: 日付範囲の開始日（当日を含む）。`YYYY-MM-DD` 形式。
          example: '2026-10-01T00:00:00.000Z'
        - name: end_date
          in: query
          required: true
          schema:
            type: string
            format: date
          description: 日付範囲の終了日（当日を含む）。`YYYY-MM-DD` 形式。範囲は90日以内である必要があります。
          example: '2026-10-31T00:00:00.000Z'
        - name: product
          in: query
          required: true
          schema:
            type: string
            enum:
              - agent
          description: ツール呼び出しをクエリする対象の製品。
          example: agent
        - name: granularity
          in: query
          required: false
          schema:
            type: string
            enum:
              - daily
              - monthly
          description: |
            結果をグループ化する際の時間粒度。指定すると、各行に `timestamp` フィールドが含まれます。
            省略すると、日付範囲全体で結果が集計されます。
        - name: group_by
          in: query
          required: false
          schema:
            type: string
          description: |
            結果のグループ化に利用するディメンションのカンマ区切りリスト。対応するディメンション：
            - `tool` — 各行に`tool`（`SEARCH_WEB`や`RUN_COMMAND`などのツールカテゴリ）を含めます
            - `user` — 各行に`user_id`を含めます。ユーザーの`user_email`が記録されている場合は、それも含めます
            - `model_uid` — 各行に`model_uid`を含めます
            - `ide` — 各行に`ide`を含めます
            - `ide_version` — 各行に`ide_version`を含めます。`ide`も含める必要があります
            - `os` — 各行に`os`を含めます
          example: user,tool
        - name: models
          in: query
          required: false
          schema:
            type: string
          description: 結果の絞り込みに利用するモデルUIDのカンマ区切りリスト。
          example: swe-2-high,claude-4-sonnet
        - name: tool
          in: query
          required: false
          schema:
            type: string
          description: |
            集計対象を`SEARCH_WEB`や`RUN_COMMAND`などの単一のツールカテゴリに限定します（完全一致）。
            このエンドポイントでのみ指定できます。
          example: SEARCH_WEB
        - name: group_id
          in: query
          required: false
          schema:
            type: string
          description: >-
            結果を特定のグループに属するユーザーに絞り込みます。サービスキーには、このグループへのアクセス権が必要です。DevinサービスユーザーのAPIキーでは利用できません。
        - name: user_id
          in: query
          required: false
          schema:
            type: string
          description: 結果を特定のユーザー（認証UID）に絞り込みます。
        - name: page_size
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 10000
            default: 1000
          description: 1ページあたりに返す最大行数。
        - name: page_cursor
          in: query
          required: false
          schema:
            type: string
          description: >-
            次のページを取得するための不透明なカーソル。前の応答の`pagination.next_page_cursor`から取得します。カーソルを発行したリクエストと同じ`metric`を渡してください。他のエンドポイントで発行されたカーソルは拒否されます。
      responses:
        '200':
          description: ツール呼び出しデータが正常に返されました。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ToolsResponse'
              examples:
                by_user_tool:
                  summary: ユーザーごとのウェブ検索とコマンド
                  value:
                    data:
                      - user_id: user_abc123
                        user_email: alice@example.com
                        tool: RUN_COMMAND
                        calls: 1842
                      - user_id: user_abc123
                        user_email: alice@example.com
                        tool: SEARCH_WEB
                        calls: 57
                    pagination:
                      next_page_cursor: null
                    metadata:
                      data_freshness: '2026-10-20T02:00:00.000Z'
                      query_time_ms: 1104
                      team_id: team_abc123
                daily_total:
                  summary: granularity=daily でグループ化なし
                  value:
                    data:
                      - timestamp: '2026-10-13T00:00:00.000Z'
                        calls: 48210
                      - timestamp: '2026-10-14T00:00:00.000Z'
                        calls: 51377
                    pagination:
                      next_page_cursor: null
                    metadata:
                      data_freshness: '2026-10-20T02:00:00.000Z'
                      query_time_ms: 870
                      team_id: team_abc123
        '400':
          description: リクエストパラメータが無効です。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                missing_metric:
                  value:
                    error: metric is required
                bad_metric:
                  value:
                    error: 'unsupported metric: loc_inserted (supported: calls)'
                missing_product:
                  value:
                    error: product is required
                bad_group_by:
                  value:
                    error: 'unsupported group_by dimension for tools: session'
        '401':
          description: 認証に失敗したか、権限が不足しています。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                missing_auth:
                  value:
                    error: missing Authorization header
                invalid_key:
                  value:
                    error: invalid service key
                insufficient_permissions:
                  value:
                    error: insufficient permissions
        '403':
          description: 指定されたページカーソルは、認証済みチームまたはリクエストで指定されたグループに属していません。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                cursor_team_mismatch:
                  value:
                    error: page cursor does not belong to this team
        '405':
          description: 許可されていないHTTPメソッドです（`GET`のみ対応）。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: レート制限超過（チームごとに1時間あたり10リクエスト）。以前のクエリのページネーションは、この制限の対象にはなりません。
          headers:
            Retry-After:
              schema:
                type: string
              description: 再試行までの推奨待機時間。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                rate_limited:
                  value:
                    error: rate limit exceeded
        '503':
          description: analytics サービスは利用できません（例：セルフホスト型デプロイメントの場合）。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - bearerAuth: []
components:
  schemas:
    ToolsResponse:
      type: object
      required:
        - data
        - pagination
        - metadata
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/ToolsRow'
          description: ツール呼び出しのデータ行の配列。
        pagination:
          type: object
          properties:
            next_page_cursor:
              type:
                - string
                - 'null'
              description: |
                結果の次のページを取得するための不透明なカーソル。後続のリクエストで、この値を `page_cursor`
                クエリパラメーターとして渡してください。次のページがない場合は `null` です。
                ページカーソルの有効期限は24時間です。
        metadata:
          type: object
          properties:
            data_freshness:
              type: string
              format: date-time
              description: 基になるデータの最終更新日時を示すタイムスタンプ（1時間未満を切り捨て）。
            query_time_ms:
              type: integer
              format: int64
              description: サーバー側のクエリ実行時間（ミリ秒）。
            team_id:
              type: string
              description: 認証済みサービスキーから決定されたチーム ID。
            group_id:
              type: string
              description: 結果の対象範囲となるグループ ID。`group_id` が指定された場合にのみ含まれます。
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: string
          description: 人が読んで理解できるエラーメッセージ。
    ToolsRow:
      type: object
      required:
        - calls
      properties:
        timestamp:
          type: string
          description: >
            この行の時間バケット。形式は `granularity` によって異なり、日単位では `YYYY-MM-DD`、月単位では
            `YYYY-MM` です。

            `granularity` が指定されている場合にのみ含まれます。
          examples:
            - '2026-10-15T00:00:00.000Z'
            - 2026-10
        user_id:
          type: string
          description: ユーザー識別子（認証UID）。`group_by` に `user` が含まれる場合にのみ含まれます。
        user_email:
          type: string
          description: >-
            ユーザーのメールアドレス。`group_by` に `user`
            が含まれ、そのユーザーのメールアドレスが記録されている場合にのみ含まれます。
          examples:
            - alice@example.com
        model_uid:
          type: string
          description: モデル識別子。`group_by` に `model_uid` が含まれる場合にのみ含まれます。
          examples:
            - swe-2-high
        ide:
          type: string
          description: IDE 名。`group_by` に `ide` が含まれる場合にのみ含まれます。
          examples:
            - windsurf
            - devin-cli
        ide_version:
          type: string
          description: IDE のバージョン。`group_by` に `ide_version` が含まれる場合にのみ含まれます（`ide` も必要です）。
          examples:
            - 3000.10.48
        os:
          type: string
          description: リクエスト元のオペレーティングシステム。`group_by` に `os` が含まれる場合にのみ含まれます。
          examples:
            - darwin
            - windows
            - linux
        tool:
          type: string
          description: >
            呼び出されたツールのカテゴリ。例：`SEARCH_WEB`、`RUN_COMMAND`、`VIEW_FILE`、

            `CODE_ACTION`、`GREP_SEARCH`、`FIND`、`MCP_TOOL`、`SKILL`、`ASK_USER_QUESTION`。Devin
            CLI のツールで

            カテゴリがないものは `OTHER` として報告されます。`group_by` に `tool` が含まれる場合にのみ含まれます。
          examples:
            - SEARCH_WEB
            - RUN_COMMAND
        calls:
          type: integer
          format: int64
          description: この行のエージェントによるツール呼び出し数。
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >
        `Authorization` ヘッダーで Bearer トークンとして渡す、**Analytics Read** 権限を持つサービスキー。


        サービスキーは、[チーム設定](https://windsurf.com/team/settings) の「Service
        Keys」セクションで作成します。

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.