Skip to main content
GET
Get a project's factory token spend over a window
The reference panel describes the current v3 operation. The notes below describe its v2 compatibility API. Follow the v3 request schema for current calls: v3 can move identifiers from the body or query into the URL. Keep the v2 method, path, and payload together when using the compatibility API.

v2 compatibility notes

GET /api/v2/factories/getProjectSpend?projectId=&startTime=&endTime= returns one project’s factory token spend between startTime and endTime (epoch milliseconds, inclusive) as a FactoryEntitySpend: totals, and breakdowns by source and model, summed across every factory. entity names the project that was read. Spend is factory token-event attribution; it is not the deployment cost rollup (GET /api/v2/cost/summary). For one factory’s spend, use Get a factory’s token spend. Two permissions at the project’s home. Your credential’s scopes must reach both factories:read and cost:read; they are checked on the request before anything is read, so a key scoped to factories:read alone is refused with 403 and requiredPermission: "cost:read". Your role grants must then hold factories:read, and then cost:read, at the project’s home org unit. A project you may read without cost:read at its home is refused the same way. Bounds. The window follows the same rules as getSpend. startTime and endTime are epoch-millisecond integers; startTime must not be after endTime (a one-millisecond window is valid), the window may span at most 30 days, and each parameter appears once. Anything else is 400 bad_request. The read sums at most 10,000 events, newest first. meta.partial is always present: when it is true, more events existed, and every event from coveredFrom through endTime was summed and none older. Continue with endTime set to coveredFrom - 1. Each breakdown holds at most 100 entries by costCents descending, and its truncated is true when more existed. Cost. Each costCents is summed in micro-dollars and rounded to cents once. A missing, malformed, or unreadable projectId is 404 resource_missing with the message Project not found.

Authorizations

Authorization
string
header
required

An External App: the JWT it obtains from POST /oauth/token with OAuth2 client_credentials. Pass as Authorization: Bearer <jwt>. An app's static companion key also authenticates as the app, but is deprecated and is not protected by Idempotency-Key.

Path Parameters

projectId
string
required

The project whose spend is summed.

Query Parameters

startTime
integer
required

Window start, epoch milliseconds (inclusive).

endTime
integer
required

Window end, epoch milliseconds (inclusive); at most 30 days after startTime.

Response

Factory token spend

data
object
required

One task's, project's or worker's factory token spend over a window, across every factory: totals and breakdowns by source and model. Each breakdown holds at most 100 entries by costCents descending, with truncated set when more existed. When the response's meta.partial is true, every event from coveredFrom through the window's end was summed and none older; otherwise coveredFrom is null. Each costCents is summed in micro-dollars and rounded to cents once.

meta
object
required