Skip to main content
GET
Get a project's usage

Authorizations

Authorization
string
header
required

An API key, shaped spk_<key_id>_<secret><checksum>, sent as Authorization: Bearer spk_.... Each key belongs to one project and reaches only that project: an id from another project answers 404.

  • A service account's key runs your product. It acts as the service account, with the role the service account holds in the project, and keeps working when people leave. It reaches the project's public agents, never a private one. Only this key may send X-SP-End-User.
  • A personal key acts as the person who created it, with their role in the project. It is for building and testing: every response carries X-SP-Warning: personal API key, not for production, and X-SP-End-User is refused with 400.

Keys are created and revoked on the API keys page of the Priors application. No API endpoint creates or revokes a service account's key. A personal key lasts 30, 90, or 365 days (90 by default), and a person can hold 10 live personal keys in an organization. A service account's key lasts 90 or 365 days (365 by default), and a service account can hold 5 live keys. The secret is shown once, at creation, and cannot be recovered.

A personal key made before projects (spu_...) keeps working until it expires, in its organization's Default project.

Keep keys on your server: a request with a Sec-Fetch-Site header is refused with 400, and Priors sends no CORS headers.

Path Parameters

project_id
string
required

The project's identifier.

Pattern: ^proj_[0-9A-HJKMNP-TV-Z]{26}$

Query Parameters

from
string<date>
required

First day of the range, inclusive, in tz.

to
string<date>
required

Last day of the range, inclusive, in tz. The range is at most 366 days, counting both ends.

tz
string
required

IANA time zone the days are bucketed in.

Required string length: 1 - 64
Pattern: ^[A-Za-z0-9_+\-/]+$
Example:

"Asia/Kolkata"

agent_id
string | null

Only this agent's charges. A non-admin naming an agent they cannot reach gets 404.

Required string length: 1 - 200
route
enum<string> | null

Only charges made through this operation.

Available options:
observe,
observe-and-recall,
recall,
observe-and-respond,
respond
api_key_id
string | null

Only the charges made with this API key.

Required string length: 1 - 200

Response

Successful Response

A project's usage over a range: totals, by day, by agent, by API key and by operation.

enabled
boolean
required

False when this deployment records no credits; every value is then zero.

filters
ProjectUsageFilters · object
required

The filters the report applied.

totals
UsageSums · object
required

Usage totals.

daily
UsageDay · object[]
required

One bucket per day of the range, zero-filled.

by_agent
UsageByAgent · object[]
required

Highest credits first. A null agent_id groups charges with no recorded agent or, when agent_restricted is true, every agent the caller cannot reach.

project_id
string
required

The project the report covers.

by_api_key
UsageByApiKey · object[]
required

Highest credits first.

by_operation
UsageByOperation · object[]
required

Highest credits first.