---
updatedAt: 2026-09-02T17:35:26.000Z
agentTools:
  projectIndex: https://docs.go.v7labs.com/llms.txt
---

# Create a token usage report

Creates a new token usage report request. Returns immediately with report metadata
(status: pending). Report generation happens asynchronously via background worker.

Subscribe to WebSocket channel `workspace:{workspace_id}` to receive
`token_report:updated` events when the report completes.


# OpenAPI definition

```json
{
  "components": {
    "schemas": {
      "Common.APIErrorDetails": {
        "description": "Additional structured error context. Shape varies by error code.\n\n- For conflict errors: contains a `conflicts` array with conflicting resources\n- For other errors: may contain arbitrary error-specific context",
        "nullable": true,
        "oneOf": [
          {
            "$ref": "#/components/schemas/Common.ConflictErrorDetails"
          },
          {
            "additionalProperties": true,
            "description": "Generic error details for non-conflict errors",
            "type": "object",
            "x-struct": null,
            "x-validate": null
          }
        ],
        "title": "Common.APIErrorDetails",
        "x-struct": "Elixir.AgiDbWeb.Schemas.Common.APIErrorDetails",
        "x-validate": null
      },
      "TokenReports.ChatReportFilters": {
        "additionalProperties": false,
        "description": "Filters for chat reports",
        "properties": {
          "case_ids": {
            "description": "Filter to specific cases",
            "items": {
              "$ref": "#/components/schemas/Common.UUID"
            },
            "type": "array",
            "x-struct": null,
            "x-validate": null
          },
          "user_ids": {
            "description": "Filter to specific users",
            "items": {
              "$ref": "#/components/schemas/Common.UUID"
            },
            "type": "array",
            "x-struct": null,
            "x-validate": null
          }
        },
        "title": "TokenReports.ChatReportFilters",
        "type": "object",
        "x-struct": "Elixir.AgiDbWeb.Schemas.TokenReports.ChatReportFilters",
        "x-validate": null
      },
      "Common.ConflictErrorDetails": {
        "additionalProperties": false,
        "description": "Details for conflict errors",
        "properties": {
          "conflicts": {
            "description": "List of conflicting resources",
            "items": {
              "additionalProperties": true,
              "type": "object",
              "x-struct": null,
              "x-validate": null
            },
            "type": "array",
            "x-struct": null,
            "x-validate": null
          }
        },
        "required": [
          "conflicts"
        ],
        "title": "Common.ConflictErrorDetails",
        "type": "object",
        "x-struct": "Elixir.AgiDbWeb.Schemas.Common.ConflictErrorDetails",
        "x-validate": null
      },
      "TokenReports.Granularity": {
        "description": "Time granularity for aggregation.\n- `hourly`: Max 3 days date range\n- `daily`: Max 1 month date range\n- `weekly`: Max 3 months date range\n- `monthly`: Max 6 months date range\n\nWorkspaces with extended report ranges enabled accept up to 180 days\nfor daily and weekly granularities, and up to 1 year for monthly.\n",
        "enum": [
          "hourly",
          "daily",
          "weekly",
          "monthly"
        ],
        "title": "TokenReports.Granularity",
        "type": "string",
        "x-struct": "Elixir.AgiDbWeb.Schemas.TokenReports.Granularity",
        "x-validate": null
      },
      "TokenReports.CreateKnowledgeGraphReportRequest": {
        "additionalProperties": false,
        "description": "Request to create a knowledge graph token usage report",
        "properties": {
          "ephemeral": {
            "default": false,
            "description": "When true, the report is omitted from list endpoints and deleted after one day.",
            "type": "boolean",
            "x-struct": null,
            "x-validate": null
          },
          "from": {
            "$ref": "#/components/schemas/Common.DateTime"
          },
          "granularity": {
            "$ref": "#/components/schemas/TokenReports.Granularity"
          },
          "group_by": {
            "description": "Dimensions to group by. Default: [model]",
            "items": {
              "$ref": "#/components/schemas/TokenReports.KnowledgeGraphGroupByDimension"
            },
            "type": "array",
            "x-struct": null,
            "x-validate": null
          },
          "report_type": {
            "enum": [
              "knowledge_graph"
            ],
            "type": "string",
            "x-struct": null,
            "x-validate": null
          },
          "to": {
            "$ref": "#/components/schemas/Common.DateTime"
          }
        },
        "required": [
          "granularity",
          "from",
          "to",
          "report_type"
        ],
        "title": "TokenReports.CreateKnowledgeGraphReportRequest",
        "type": "object",
        "x-struct": "Elixir.AgiDbWeb.Schemas.TokenReports.CreateKnowledgeGraphReportRequest",
        "x-validate": null
      },
      "TokenReports.PendingReport": {
        "additionalProperties": false,
        "description": "Token report in pending status (waiting to be processed)",
        "properties": {
          "created_at": {
            "$ref": "#/components/schemas/Common.DateTime"
          },
          "created_by_id": {
            "$ref": "#/components/schemas/Common.UUID"
          },
          "filters": {
            "$ref": "#/components/schemas/TokenReports.ReportFilters"
          },
          "from": {
            "$ref": "#/components/schemas/Common.DateTime"
          },
          "granularity": {
            "$ref": "#/components/schemas/TokenReports.Granularity"
          },
          "group_by": {
            "items": {
              "$ref": "#/components/schemas/TokenReports.GroupByDimension"
            },
            "type": "array",
            "x-struct": null,
            "x-validate": null
          },
          "id": {
            "$ref": "#/components/schemas/Common.UUID"
          },
          "report_type": {
            "$ref": "#/components/schemas/TokenReports.ReportType"
          },
          "status": {
            "enum": [
              "pending"
            ],
            "type": "string",
            "x-struct": null,
            "x-validate": null
          },
          "to": {
            "$ref": "#/components/schemas/Common.DateTime"
          },
          "workspace_id": {
            "$ref": "#/components/schemas/Common.UUID"
          }
        },
        "required": [
          "id",
          "workspace_id",
          "report_type",
          "status",
          "granularity",
          "from",
          "to",
          "group_by",
          "created_at",
          "created_by_id"
        ],
        "title": "TokenReports.PendingReport",
        "type": "object",
        "x-struct": "Elixir.AgiDbWeb.Schemas.TokenReports.PendingReport",
        "x-validate": null
      },
      "Common.UUID": {
        "example": "e23ff3f3-8f77-4e78-9e81-fdb25abfb781",
        "format": "uuid",
        "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$",
        "title": "Common.UUID",
        "type": "string",
        "x-struct": null,
        "x-validate": null
      },
      "TokenReports.ReportFilters": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/TokenReports.AgentReportFilters"
          },
          {
            "$ref": "#/components/schemas/TokenReports.ChatReportFilters"
          },
          {
            "$ref": "#/components/schemas/TokenReports.PlaybookReportFilters"
          }
        ],
        "description": "Report filters (varies by report_type)",
        "title": "TokenReports.ReportFilters",
        "x-struct": "Elixir.AgiDbWeb.Schemas.TokenReports.ReportFilters",
        "x-validate": null
      },
      "TokenReports.KnowledgeGraphGroupByDimension": {
        "description": "Grouping dimension for knowledge graph reports",
        "enum": [
          "model"
        ],
        "title": "TokenReports.KnowledgeGraphGroupByDimension",
        "type": "string",
        "x-struct": "Elixir.AgiDbWeb.Schemas.TokenReports.KnowledgeGraphGroupByDimension",
        "x-validate": null
      },
      "TokenReports.CreateSummaryReportRequest": {
        "additionalProperties": false,
        "description": "Request to create a workspace summary token usage report",
        "properties": {
          "ephemeral": {
            "default": false,
            "description": "When true, the report is omitted from list endpoints and deleted after one day.",
            "type": "boolean",
            "x-struct": null,
            "x-validate": null
          },
          "from": {
            "$ref": "#/components/schemas/Common.DateTime"
          },
          "granularity": {
            "$ref": "#/components/schemas/TokenReports.Granularity"
          },
          "group_by": {
            "description": "Dimensions to group by. Default: [model]",
            "items": {
              "$ref": "#/components/schemas/TokenReports.SummaryGroupByDimension"
            },
            "type": "array",
            "x-struct": null,
            "x-validate": null
          },
          "report_type": {
            "enum": [
              "summary"
            ],
            "type": "string",
            "x-struct": null,
            "x-validate": null
          },
          "to": {
            "$ref": "#/components/schemas/Common.DateTime"
          }
        },
        "required": [
          "granularity",
          "from",
          "to",
          "report_type"
        ],
        "title": "TokenReports.CreateSummaryReportRequest",
        "type": "object",
        "x-struct": "Elixir.AgiDbWeb.Schemas.TokenReports.CreateSummaryReportRequest",
        "x-validate": null
      },
      "TokenReports.PlaybookReportFilters": {
        "additionalProperties": false,
        "description": "Filters for playbook reports",
        "properties": {
          "playbook_ids": {
            "description": "Filter to specific playbooks",
            "items": {
              "$ref": "#/components/schemas/Common.UUID"
            },
            "type": "array",
            "x-struct": null,
            "x-validate": null
          }
        },
        "title": "TokenReports.PlaybookReportFilters",
        "type": "object",
        "x-struct": "Elixir.AgiDbWeb.Schemas.TokenReports.PlaybookReportFilters",
        "x-validate": null
      },
      "TokenReports.CreateAgentReportRequest": {
        "additionalProperties": false,
        "description": "Request to create an agent token usage report",
        "properties": {
          "ephemeral": {
            "default": false,
            "description": "When true, the report is omitted from list endpoints and deleted after one day.",
            "type": "boolean",
            "x-struct": null,
            "x-validate": null
          },
          "filters": {
            "$ref": "#/components/schemas/TokenReports.AgentReportFilters"
          },
          "from": {
            "$ref": "#/components/schemas/Common.DateTime"
          },
          "granularity": {
            "$ref": "#/components/schemas/TokenReports.Granularity"
          },
          "group_by": {
            "description": "Dimensions to group by. Default: [model]",
            "items": {
              "$ref": "#/components/schemas/TokenReports.AgentGroupByDimension"
            },
            "type": "array",
            "x-struct": null,
            "x-validate": null
          },
          "report_type": {
            "enum": [
              "agent"
            ],
            "type": "string",
            "x-struct": null,
            "x-validate": null
          },
          "to": {
            "$ref": "#/components/schemas/Common.DateTime"
          }
        },
        "required": [
          "granularity",
          "from",
          "to",
          "report_type"
        ],
        "title": "TokenReports.CreateAgentReportRequest",
        "type": "object",
        "x-struct": "Elixir.AgiDbWeb.Schemas.TokenReports.CreateAgentReportRequest",
        "x-validate": null
      },
      "TokenReports.GroupByDimension": {
        "description": "Grouping dimension. Available options vary by report type:\n- agent: `model`, `property`\n- hub: `model`\n- chat: `case`, `user`, `model`\n- playbook: `model`, `playbook_run`\n- summary: `model`\n- user_usage: no grouping dimensions\n",
        "enum": [
          "model",
          "case",
          "user",
          "property",
          "playbook_run"
        ],
        "title": "TokenReports.GroupByDimension",
        "type": "string",
        "x-struct": "Elixir.AgiDbWeb.Schemas.TokenReports.GroupByDimension",
        "x-validate": null
      },
      "TokenReports.ChatGroupByDimension": {
        "description": "Grouping dimension for chat reports",
        "enum": [
          "model",
          "case",
          "user"
        ],
        "title": "TokenReports.ChatGroupByDimension",
        "type": "string",
        "x-struct": "Elixir.AgiDbWeb.Schemas.TokenReports.ChatGroupByDimension",
        "x-validate": null
      },
      "TokenReports.CreateHubReportRequest": {
        "additionalProperties": false,
        "description": "Request to create a hub token usage report",
        "properties": {
          "ephemeral": {
            "default": false,
            "description": "When true, the report is omitted from list endpoints and deleted after one day.",
            "type": "boolean",
            "x-struct": null,
            "x-validate": null
          },
          "from": {
            "$ref": "#/components/schemas/Common.DateTime"
          },
          "granularity": {
            "$ref": "#/components/schemas/TokenReports.Granularity"
          },
          "group_by": {
            "description": "Dimensions to group by. Default: [model]",
            "items": {
              "$ref": "#/components/schemas/TokenReports.HubGroupByDimension"
            },
            "type": "array",
            "x-struct": null,
            "x-validate": null
          },
          "report_type": {
            "enum": [
              "hub"
            ],
            "type": "string",
            "x-struct": null,
            "x-validate": null
          },
          "to": {
            "$ref": "#/components/schemas/Common.DateTime"
          }
        },
        "required": [
          "granularity",
          "from",
          "to",
          "report_type"
        ],
        "title": "TokenReports.CreateHubReportRequest",
        "type": "object",
        "x-struct": "Elixir.AgiDbWeb.Schemas.TokenReports.CreateHubReportRequest",
        "x-validate": null
      },
      "TokenReports.CreateChatReportRequest": {
        "additionalProperties": false,
        "description": "Request to create a chat token usage report",
        "properties": {
          "ephemeral": {
            "default": false,
            "description": "When true, the report is omitted from list endpoints and deleted after one day.",
            "type": "boolean",
            "x-struct": null,
            "x-validate": null
          },
          "filters": {
            "$ref": "#/components/schemas/TokenReports.ChatReportFilters"
          },
          "from": {
            "$ref": "#/components/schemas/Common.DateTime"
          },
          "granularity": {
            "$ref": "#/components/schemas/TokenReports.Granularity"
          },
          "group_by": {
            "description": "Dimensions to group by. Default: [case, model]",
            "items": {
              "$ref": "#/components/schemas/TokenReports.ChatGroupByDimension"
            },
            "type": "array",
            "x-struct": null,
            "x-validate": null
          },
          "report_type": {
            "enum": [
              "chat"
            ],
            "type": "string",
            "x-struct": null,
            "x-validate": null
          },
          "to": {
            "$ref": "#/components/schemas/Common.DateTime"
          }
        },
        "required": [
          "granularity",
          "from",
          "to",
          "report_type"
        ],
        "title": "TokenReports.CreateChatReportRequest",
        "type": "object",
        "x-struct": "Elixir.AgiDbWeb.Schemas.TokenReports.CreateChatReportRequest",
        "x-validate": null
      },
      "TokenReports.CreatePlaybookReportRequest": {
        "additionalProperties": false,
        "description": "Request to create a playbook token usage report. The usage of a run is the usage of its\nrun chat and of each chat that claimed the run. Only workspaces with Playbooks enabled\naccept this report type.\n",
        "properties": {
          "ephemeral": {
            "default": false,
            "description": "When true, the report is omitted from list endpoints and deleted after one day.",
            "type": "boolean",
            "x-struct": null,
            "x-validate": null
          },
          "filters": {
            "$ref": "#/components/schemas/TokenReports.PlaybookReportFilters"
          },
          "from": {
            "$ref": "#/components/schemas/Common.DateTime"
          },
          "granularity": {
            "$ref": "#/components/schemas/TokenReports.Granularity"
          },
          "group_by": {
            "description": "Dimensions to group by. Default: one row per playbook and period",
            "items": {
              "$ref": "#/components/schemas/TokenReports.PlaybookGroupByDimension"
            },
            "type": "array",
            "x-struct": null,
            "x-validate": null
          },
          "report_type": {
            "enum": [
              "playbook"
            ],
            "type": "string",
            "x-struct": null,
            "x-validate": null
          },
          "to": {
            "$ref": "#/components/schemas/Common.DateTime"
          }
        },
        "required": [
          "granularity",
          "from",
          "to",
          "report_type"
        ],
        "title": "TokenReports.CreatePlaybookReportRequest",
        "type": "object",
        "x-struct": "Elixir.AgiDbWeb.Schemas.TokenReports.CreatePlaybookReportRequest",
        "x-validate": null
      },
      "TokenReports.CreateReportRequest": {
        "description": "Request to create a token usage report",
        "oneOf": [
          {
            "$ref": "#/components/schemas/TokenReports.CreateAgentReportRequest"
          },
          {
            "$ref": "#/components/schemas/TokenReports.CreateHubReportRequest"
          },
          {
            "$ref": "#/components/schemas/TokenReports.CreateChatReportRequest"
          },
          {
            "$ref": "#/components/schemas/TokenReports.CreatePlaybookReportRequest"
          },
          {
            "$ref": "#/components/schemas/TokenReports.CreateSummaryReportRequest"
          },
          {
            "$ref": "#/components/schemas/TokenReports.CreateUserUsageReportRequest"
          },
          {
            "$ref": "#/components/schemas/TokenReports.CreateKnowledgeGraphReportRequest"
          }
        ],
        "title": "TokenReports.CreateReportRequest",
        "x-struct": "Elixir.AgiDbWeb.Schemas.TokenReports.CreateReportRequest",
        "x-validate": null
      },
      "TokenReports.SummaryGroupByDimension": {
        "description": "Grouping dimension for summary reports",
        "enum": [
          "model"
        ],
        "title": "TokenReports.SummaryGroupByDimension",
        "type": "string",
        "x-struct": "Elixir.AgiDbWeb.Schemas.TokenReports.SummaryGroupByDimension",
        "x-validate": null
      },
      "TokenReports.ReportType": {
        "description": "Type of token usage report",
        "enum": [
          "agent",
          "hub",
          "chat",
          "playbook",
          "summary",
          "user_usage",
          "knowledge_graph"
        ],
        "title": "TokenReports.ReportType",
        "type": "string",
        "x-struct": "Elixir.AgiDbWeb.Schemas.TokenReports.ReportType",
        "x-validate": null
      },
      "TokenReports.PlaybookGroupByDimension": {
        "description": "Grouping dimension for playbook reports:\n- `model`: one row per model and provider\n- `playbook_run`: one row per run instead of one row per playbook\n",
        "enum": [
          "model",
          "playbook_run"
        ],
        "title": "TokenReports.PlaybookGroupByDimension",
        "type": "string",
        "x-struct": "Elixir.AgiDbWeb.Schemas.TokenReports.PlaybookGroupByDimension",
        "x-validate": null
      },
      "Common.DateTime": {
        "description": "DateTime in RFC3339 format",
        "example": "2020-01-20T14:00:00Z",
        "format": "date-time",
        "title": "Common.DateTime",
        "type": "string",
        "x-struct": "Elixir.AgiDbWeb.Schemas.Common.DateTime",
        "x-validate": null
      },
      "Common.APIError": {
        "additionalProperties": false,
        "properties": {
          "code": {
            "example": "bad_request",
            "type": "string",
            "x-struct": null,
            "x-validate": null
          },
          "details": {
            "$ref": "#/components/schemas/Common.APIErrorDetails"
          },
          "message": {
            "example": "Bad Request",
            "type": "string",
            "x-struct": null,
            "x-validate": null
          }
        },
        "required": [
          "code",
          "message"
        ],
        "title": "Common.APIError",
        "type": "object",
        "x-struct": "Elixir.AgiDbWeb.Schemas.Common.APIError",
        "x-validate": null
      },
      "TokenReports.CreateUserUsageReportRequest": {
        "additionalProperties": false,
        "description": "Request to create a per-user workspace usage report",
        "properties": {
          "ephemeral": {
            "default": false,
            "description": "When true, the report is omitted from list endpoints and deleted after one day.",
            "type": "boolean",
            "x-struct": null,
            "x-validate": null
          },
          "from": {
            "$ref": "#/components/schemas/Common.DateTime"
          },
          "report_type": {
            "enum": [
              "user_usage"
            ],
            "type": "string",
            "x-struct": null,
            "x-validate": null
          },
          "to": {
            "$ref": "#/components/schemas/Common.DateTime"
          }
        },
        "required": [
          "report_type",
          "from",
          "to"
        ],
        "title": "TokenReports.CreateUserUsageReportRequest",
        "type": "object",
        "x-struct": "Elixir.AgiDbWeb.Schemas.TokenReports.CreateUserUsageReportRequest",
        "x-validate": null
      },
      "TokenReports.AgentGroupByDimension": {
        "description": "Grouping dimension for agent reports",
        "enum": [
          "model",
          "property"
        ],
        "title": "TokenReports.AgentGroupByDimension",
        "type": "string",
        "x-struct": "Elixir.AgiDbWeb.Schemas.TokenReports.AgentGroupByDimension",
        "x-validate": null
      },
      "TokenReports.AgentReportFilters": {
        "additionalProperties": false,
        "description": "Filters for agent reports",
        "properties": {
          "project_ids": {
            "description": "Filter to specific root projects",
            "items": {
              "$ref": "#/components/schemas/Common.UUID"
            },
            "type": "array",
            "x-struct": null,
            "x-validate": null
          }
        },
        "title": "TokenReports.AgentReportFilters",
        "type": "object",
        "x-struct": "Elixir.AgiDbWeb.Schemas.TokenReports.AgentReportFilters",
        "x-validate": null
      },
      "TokenReports.HubGroupByDimension": {
        "description": "Grouping dimension for hub reports",
        "enum": [
          "model"
        ],
        "title": "TokenReports.HubGroupByDimension",
        "type": "string",
        "x-struct": "Elixir.AgiDbWeb.Schemas.TokenReports.HubGroupByDimension",
        "x-validate": null
      }
    },
    "securitySchemes": {
      "ApiKeyAuth": {
        "in": "header",
        "name": "X-API-KEY",
        "type": "apiKey"
      },
      "BearerAuth": {
        "scheme": "bearer",
        "type": "http"
      }
    }
  },
  "info": {
    "title": "V7 Go API",
    "version": "0.1.0"
  },
  "openapi": "3.0.0",
  "paths": {
    "/api/workspaces/{workspace_id}/reports/token_reports": {
      "post": {
        "callbacks": {},
        "description": "Creates a new token usage report request. Returns immediately with report metadata\n(status: pending). Report generation happens asynchronously via background worker.\n\nSubscribe to WebSocket channel `workspace:{workspace_id}` to receive\n`token_report:updated` events when the report completes.\n",
        "operationId": "token-reports-create",
        "parameters": [
          {
            "description": "",
            "in": "path",
            "name": "workspace_id",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/Common.UUID"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TokenReports.CreateReportRequest"
              }
            }
          },
          "description": "TokenReports.CreateReportRequest",
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TokenReports.PendingReport"
                }
              }
            },
            "description": "TokenReports.PendingReport"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Common.APIError"
                }
              }
            },
            "description": "Common.APIError"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Common.APIError"
                }
              }
            },
            "description": "Common.APIError"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Common.APIError"
                }
              }
            },
            "description": "Common.APIError"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Common.APIError"
                }
              }
            },
            "description": "Common.APIError"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Common.APIError"
                }
              }
            },
            "description": "Common.APIError"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Common.APIError"
                }
              }
            },
            "description": "Common.APIError"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Common.APIError"
                }
              }
            },
            "description": "Common.APIError"
          }
        },
        "summary": "Create a token usage report",
        "tags": [
          "Token Reports"
        ]
      }
    }
  },
  "security": [
    {
      "BearerAuth": []
    },
    {
      "ApiKeyAuth": []
    }
  ],
  "servers": [
    {
      "description": "EU",
      "url": "https://go.v7labs.com",
      "variables": {}
    },
    {
      "description": "US",
      "url": "https://go.us.v7labs.com",
      "variables": {}
    },
    {
      "description": "UAE",
      "url": "https://go.uae.v7labs.com",
      "variables": {}
    }
  ]
}
```