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

# List spend logs

> Lists the requests the instance served with its keys, newest first, one page at a time. The window defaults to the last 24 hours and spans at most 31 days. A row appears a few seconds after its request. The instance must be `ready`; otherwise the request answers `409`.



## OpenAPI

````yaml /openapi/source/external/agent-gateway/agent-gateway.json get /agent_gateways/{instance_id}/spend_logs
openapi: 3.1.0
info:
  version: 1.0.0
  title: Telnyx API
  x-latency-category: interactive
  x-endpoint-cost: light
  description: >-
    Agent Gateway authenticates, authorizes, and audits the requests agents send
    to models, tools, and other agents. Each gateway runs as a dedicated
    instance on the account's
    [*Network*](https://developers.telnyx.com/docs/network/overview). This API
    creates, lists, and deletes instances, and manages the keys, teams, spend
    logs, MCP servers, APIs, tool permissions, and guardrails on them. Each
    instance serves an OpenAI-compatible API at its `gateway_url`.
servers:
  - url: https://api.telnyx.com/v2
    description: Telnyx API v2
security:
  - bearerAuth: []
tags:
  - name: Agent Gateways
    description: Create, list, retrieve, and delete Agent Gateway instances.
  - name: Agent Gateway Keys
    description: Keys on an instance.
  - name: Agent Gateway Teams
    description: 'Teams on an instance: shared model lists, budgets, and rate limits.'
  - name: Agent Gateway Spend Logs
    description: The requests an instance served, with their cost.
  - name: Agent Gateway MCP Servers
    description: MCP servers on an instance, served to agents at one MCP endpoint.
  - name: Agent Gateway APIs
    description: REST APIs on an instance, served to agents as tools.
  - name: Agent Gateway Tool Permissions
    description: The MCP servers and tools a key or team may use.
  - name: Agent Gateway Guardrails
    description: Checks an instance runs on model and tool requests.
  - name: Agent Gateway Policies
    description: Named sets of guardrails an instance applies to requests.
  - name: Agent Gateway Policy Attachments
    description: Where an instance applies each policy.
paths:
  /agent_gateways/{instance_id}/spend_logs:
    get:
      tags:
        - Agent Gateway Spend Logs
      summary: List spend logs
      description: >-
        Lists the requests the instance served with its keys, newest first, one
        page at a time. The window defaults to the last 24 hours and spans at
        most 31 days. A row appears a few seconds after its request. The
        instance must be `ready`; otherwise the request answers `409`.
      operationId: ListAgentGatewaySpendLogs
      parameters:
        - name: instance_id
          in: path
          required: true
          description: The Agent Gateway's `id`.
          schema:
            type: string
            format: uuid
          example: ecffdf4b-93ea-4a7b-8295-51dfd2077996
        - name: page[number]
          in: query
          required: false
          description: The page to return, counting from 1.
          schema:
            type: integer
            minimum: 1
            default: 1
        - name: page[size]
          in: query
          required: false
          description: Results per page.
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 50
        - name: start
          in: query
          required: false
          description: >-
            The window's start, an RFC 3339 timestamp with an offset. Defaults
            to 24 hours before `end`.
          schema:
            type: string
            format: date-time
          example: '2026-10-21T00:00:00Z'
        - name: end
          in: query
          required: false
          description: >-
            The window's end, an RFC 3339 timestamp with an offset. Defaults to
            now.
          schema:
            type: string
            format: date-time
          example: '2026-10-22T00:00:00Z'
        - name: key_id
          in: query
          required: false
          description: Only the requests made with this key.
          schema:
            type: string
            pattern: ^[0-9a-f]{64}$
        - name: team_id
          in: query
          required: false
          description: Only the requests made with this team's keys.
          schema:
            type: string
            format: uuid
      responses:
        '200':
          description: One page of spend logs
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentGatewaySpendLogListResponse'
              example:
                data:
                  - id: chatcmpl-1c0032cc-3d9f-439f-af62-b7f2b6623da4
                    key_id: >-
                      5f1c3a0e9b7d4c2a8e6f0b1d3c5a7e9f2b4d6c8a0e1f3a5c7e9b1d3f5a7c9e0b
                    team_id: 0b6c5d4e-3f2a-4b1c-9d8e-7f6a5b4c3d2e
                    model: zai-org/GLM-5.3-Flash
                    operation: acompletion
                    status: success
                    spend: 0.00027747
                    prompt_tokens: 22
                    completion_tokens: 610
                    total_tokens: 632
                    started_at: '2026-10-21T19:41:02.114000Z'
                    ended_at: '2026-10-21T19:41:04.879000Z'
                    duration_ms: 2765
                meta:
                  total_results: 1
                  page_number: 1
                  page_size: 50
                  total_pages: 1
                  total_results_capped: false
        '400':
          description: The window is longer than 31 days
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TelnyxErrors'
              example:
                errors:
                  - code: '10033'
                    title: Value outside of range
                    detail: >-
                      The value is outside of allowed range the start to 31 days
                      after it
                    source:
                      parameter: end
                    meta:
                      url: https://developers.telnyx.com/docs/overview/errors/10033
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TelnyxErrors'
              example:
                errors:
                  - code: '10009'
                    title: Authentication failed
                    detail: >-
                      The required authentication headers were either invalid or
                      not included in the request.
                    meta:
                      url: https://developers.telnyx.com/docs/overview/errors/10009
        '404':
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TelnyxErrors'
              example:
                errors:
                  - code: '10005'
                    title: Resource not found
                    detail: The requested resource or URL could not be found.
                    meta:
                      url: https://developers.telnyx.com/docs/overview/errors/10005
        '409':
          description: The instance is not `ready`
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TelnyxErrors'
              example:
                errors:
                  - code: '99901'
                    title: Instance not ready
                    detail: The instance is not ready; its engine is not running.
        '502':
          description: The instance's engine did not answer
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TelnyxErrors'
              example:
                errors:
                  - code: '99903'
                    title: Engine unavailable
                    detail: The instance's engine did not answer; try again shortly.
components:
  schemas:
    AgentGatewaySpendLogListResponse:
      type: object
      required:
        - data
        - meta
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/AgentGatewaySpendLog'
        meta:
          $ref: '#/components/schemas/AgentGatewaySpendLogPageMeta'
    TelnyxErrors:
      type: object
      properties:
        errors:
          type: array
          items:
            $ref: '#/components/schemas/TelnyxError'
    AgentGatewaySpendLog:
      type: object
      description: One request the instance served.
      required:
        - id
        - key_id
        - team_id
        - model
        - operation
        - status
        - spend
        - prompt_tokens
        - completion_tokens
        - total_tokens
        - started_at
        - ended_at
        - duration_ms
      properties:
        id:
          type: string
          description: The request's ID.
        key_id:
          anyOf:
            - type: string
            - type: 'null'
          description: The key the request used.
        team_id:
          anyOf:
            - type: string
            - type: 'null'
          description: The key's team.
        model:
          anyOf:
            - type: string
            - type: 'null'
          description: >-
            The Telnyx Inference model that answered, such as
            `zai-org/GLM-5.3-Flash`. For an MCP tool request, `MCP: ` and the
            tool's name.
        operation:
          type: string
          description: >-
            The request type. `acompletion` is a chat completion, `aresponses` a
            response, `anthropic_messages` a message, `call_mcp_tool` an MCP
            tool request, and `list_mcp_tools` an MCP tool list.
        status:
          anyOf:
            - type: string
            - type: 'null'
          description: '`success` or `failure`.'
        spend:
          type: number
          description: >-
            What the request cost, in USD, with its tokens at Telnyx Inference
            prices.
        prompt_tokens:
          type: integer
          description: Input tokens.
        completion_tokens:
          type: integer
          description: Output tokens, reasoning included.
        total_tokens:
          type: integer
          description: Input and output tokens.
        started_at:
          type: string
          format: date-time
          description: When the request started.
        ended_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          description: When the request ended.
        duration_ms:
          anyOf:
            - type: integer
            - type: 'null'
          description: How long the request took, in milliseconds.
    AgentGatewaySpendLogPageMeta:
      type: object
      required:
        - total_results
        - page_number
        - page_size
        - total_pages
        - total_results_capped
      properties:
        total_results:
          type: integer
          description: Results across every page.
        page_number:
          type: integer
          description: The page returned, counting from 1.
        page_size:
          type: integer
          description: Results per page.
        total_pages:
          type: integer
          description: Pages that can be requested; 0 when nothing matched.
        total_results_capped:
          type: boolean
          description: >-
            `true` when the window holds more than 10,000 rows. The two totals
            are then lower bounds: narrow the window, or page until a page comes
            back empty.
    TelnyxError:
      type: object
      properties:
        code:
          type: string
        title:
          type: string
        detail:
          type: string
        source:
          type: object
          properties:
            pointer:
              type: string
            parameter:
              type: string
        meta:
          type: object
          properties:
            url:
              type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Telnyx API key

````