Get a worker's factory token spend over a window
Returns one worker’s factory token spend between startTime and endTime (epoch ms, inclusive) — totals, and breakdowns by source and model. Requires permission factories:read and cost:read, both at the deployment root.
v2 compatibility notes
GET /api/v2/factories/getWorkerSpend?workerId=&startTime=&endTime= returns one worker’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 worker 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 deployment root. 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 both factories:read and cost:read at the deployment root; holding them only below the root, or at a partner organization’s root, is refused with 403.
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.
One worker. workerId names one worker, a person’s or an agent’s, and the spend is that worker’s alone. The single humanWorkers row of getSpend applies only to getSpend. A missing workerId is 404 resource_missing with the message Worker not found; a worker with no recorded spend, including an unknown workerId, returns zero totals.Authorizations
Query Parameters
Response
Factory token spend
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.

