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

# Spend over time

> Dollar spend across the full requested range.



## OpenAPI

````yaml /api-reference/openapi.json get /api/observability/finops/spend-timeseries
openapi: 3.1.0
info:
  title: Nasiko API
  description: >-
    HTTP API for the Nasiko OpenRuntime: agents, coding harnesses, TokenOps,
    routing, MCP, and secrets. Spec is generated from annotated routes; some
    surfaces are documented on the hand-written pages alongside this file.
  license:
    name: ''
  version: 0.1.0
servers:
  - url: https://free.app.nasiko.com
    description: Nasiko Cloud Free
  - url: https://{workspace}.app.nasiko.com
    description: Nasiko Cloud paid workspace
    variables:
      workspace:
        default: your-workspace
        description: >-
          Your workspace's subdomain, as shown in the connect command on the
          dashboard's Nasiko CLI page
security:
  - bearer_auth: []
tags:
  - name: secrets
    description: Encrypted per-user agent secrets
  - name: catalog
    description: >-
      Agent catalog: registration, discovery, versions, per-agent secrets, and
      source import
  - name: agents
    description: >-
      Agent lifecycle: deployments, LLM routing config, update/rollback,
      upload-and-deploy
  - name: orchestrator
    description: >-
      A2A dispatch: routing-engine/ReAct orchestrator and direct agent chat,
      plus routing stats
  - name: users
    description: >-
      User management: CRUD, roles, credentials, accessible agents
      (superuser-only)
  - name: usage
    description: Per-user token usage and cost reporting
  - name: observability
    description: Sessions, traces, spans, agent logs, and FinOps reporting
  - name: llm-router
    description: LLM routing presets, provider/model catalog, and tier→model registry
  - name: context-selection
    description: >-
      Per-user chat-history selection preferences: strategy, PACMS budget tier,
      the on/off switch, a dry-run preview, and settings-change history
  - name: coding-agents
    description: >-
      The progress local clients report while they bring in the caller's coding
      agents
  - name: settings
    description: >-
      Workspace-wide settings, including the Optimization tiers a user's PACMS
      budget level resolves against
  - name: mcp
    description: >-
      MCP gateway: agent-facing JSON-RPC tool calls, connector
      registration/upload/sharing, credentials & OAuth, and per-agent tool
      permissions
paths:
  /api/observability/finops/spend-timeseries:
    get:
      tags:
        - observability
      summary: Spend over time
      description: Dollar spend across the full requested range.
      operationId: get_finops_spend_timeseries
      parameters:
        - name: start_time
          in: query
          description: >-
            ISO-8601 window start (default: 30 days ago). Ignored when `range`
            is set.
          required: false
          schema:
            type:
              - string
              - 'null'
        - name: end_time
          in: query
          description: >-
            ISO-8601 window end (default: now). Without it a past-month
            selection

            means "that month through today" rather than that month.
          required: false
          schema:
            type:
              - string
              - 'null'
        - name: range
          in: query
          description: '"24h" | "7d" | "30d" — quick-select range, overrides `start_time`.'
          required: false
          schema:
            type:
              - string
              - 'null'
        - name: agent_id
          in: query
          description: Agent UUID or name — scopes the whole response to one agent.
          required: false
          schema:
            type:
              - string
              - 'null'
        - name: model
          in: query
          description: Exact model id, matched against span model attributes.
          required: false
          schema:
            type:
              - string
              - 'null'
        - name: provider
          in: query
          description: Provider name filter (e.g. "openai", "anthropic").
          required: false
          schema:
            type:
              - string
              - 'null'
        - name: org_unit
          in: query
          description: >-
            Org-unit filter (Enterprise). Open-source servers accept it and
            ignore it.
          required: false
          schema:
            type:
              - string
              - 'null'
        - name: view
          in: query
          description: >-
            "agent" | "workflow" — which attribution source powers the
            response's

            `attributions` field (default "agent").
          required: false
          schema:
            type:
              - string
              - 'null'
        - name: my_agent
          in: query
          description: |-
            When `true`, restricts results to agents owned by the caller.
            Ignored when `agent_id` is also set (already scoped to one agent).
          required: false
          schema:
            type: boolean
        - name: compare
          in: query
          description: >-
            `previous` adds the preceding window of the same length to the same

            response, so a caller comparing two windows needs one request, not
            two.

            Anything else is ignored.
          required: false
          schema:
            type:
              - string
              - 'null'
        - name: group_by
          in: query
          description: >-
            `agent` (spend-timeseries only) adds a per-agent series for the top

            spenders plus an `other` aggregate, replacing one filtered request
            per

            driver. Any other value is a 400.
          required: false
          schema:
            type:
              - string
              - 'null'
        - name: top
          in: query
          description: |-
            How many agents get their own series under `group_by=agent`
            (default 5, clamped 1-20). The rest fold into `other`.
          required: false
          schema:
            type:
              - integer
              - 'null'
            format: int64
        - name: user_id
          in: query
          description: >-
            One user's usage only (a user UUID). An admin may name anyone;
            anyone else only

            themselves (403 otherwise).
          required: false
          schema:
            type:
              - string
              - 'null'
      responses:
        '200':
          description: Spend time series
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FinopsSpendTimeseriesResponse'
        '400':
          description: Malformed filter
components:
  schemas:
    FinopsSpendTimeseriesResponse:
      type: object
      required:
        - data
        - status_code
        - message
      properties:
        data:
          $ref: '#/components/schemas/FinopsSpendTimeseries'
        message:
          type: string
        status_code:
          type: integer
          format: int32
          minimum: 0
    FinopsSpendTimeseries:
      type: object
      required:
        - bucket
        - points
      properties:
        bucket:
          type: string
          description: '"hour" | "day"'
        points:
          type: array
          items:
            $ref: '#/components/schemas/SpendTimeseriesPoint'
        previous:
          type:
            - array
            - 'null'
          items:
            $ref: '#/components/schemas/SpendTimeseriesPoint'
          description: >-
            The preceding window of the same length, present only with

            `compare=previous`. Same bucketing, so points line up
            index-for-index

            once both are zero-filled.
        series:
          type:
            - array
            - 'null'
          items:
            $ref: '#/components/schemas/SpendAgentSeries'
          description: >-
            Per-agent series, present only with `group_by=agent`. The top `top`

            agents by spend over the whole window, plus one `other` series
            carrying

            everything below them, so the series still sum to `points`.


            Without this a caller charting the top N drivers had to issue one

            `agent_id=`-filtered request per driver — a fan-out whose size grew
            with

            the chart.
    SpendTimeseriesPoint:
      type: object
      required:
        - bucket_start
        - spend_usd
        - operations
        - tool_calls
      properties:
        bucket_start:
          type: string
          description: Bucket start, RFC3339.
        operations:
          type: integer
          minimum: 0
        p50_latency_ms:
          type:
            - number
            - 'null'
          format: double
          description: |-
            Fleet-wide latency percentiles across all traces in this bucket.
            `None` when no traces carry a latency measurement.
        p95_latency_ms:
          type:
            - number
            - 'null'
          format: double
        p99_latency_ms:
          type:
            - number
            - 'null'
          format: double
        spend_usd:
          type: number
          format: double
        tool_calls:
          type: integer
          format: int64
          description: Total tool calls across all agents in this bucket.
          minimum: 0
        top_agent_name:
          type:
            - string
            - 'null'
          description: Highest-spend agent in this bucket, for the hover breakdown.
        top_agent_spend_usd:
          type:
            - number
            - 'null'
          format: double
    SpendAgentSeries:
      type: object
      description: One agent's spend over the window's buckets.
      required:
        - is_other
        - total_spend_usd
        - points
      properties:
        agent_id:
          type:
            - string
            - 'null'
          description: >-
            Resolved agent UUID when exactly one live agent carries that name,
            so

            callers key on the id rather than the name (TK-3, H-5).
        agent_name:
          type:
            - string
            - 'null'
          description: >-
            Raw trace name, matching `top_agent_name` on the fleet points.
            `None` for

            the aggregate `other` series.
        is_other:
          type: boolean
          description: >-
            True for the single aggregate series holding every agent outside the
            top.
        points:
          type: array
          items:
            $ref: '#/components/schemas/SpendAgentPoint'
        total_spend_usd:
          type: number
          format: double
    SpendAgentPoint:
      type: object
      required:
        - bucket_start
        - spend_usd
        - operations
      properties:
        bucket_start:
          type: string
        operations:
          type: integer
          minimum: 0
        spend_usd:
          type: number
          format: double
  securitySchemes:
    bearer_auth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        Session JWT. After `nasiko auth login`, print it with `jq -r
        '.clusters[.active].token' ~/.nasiko/config.json`. API keys aren't
        supported.

````

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