Token spend is the number most teams want first, and the analytics endpoints answer it without exporting anything. This recipe queries token usage, call count, and unique users for a project over a date range, and shows that all three take the same request body.

The recipe

main.sh

How it works

  • Query project token usage is a POST, not a GET, because the date range and grouping travel in the body.
  • Every analytics measure shares one request shape: startDate, endDate, and an interval of day, hour, or month. Swapping the measure in the path is the only change needed, which is why this recipe queries three in a loop.
  • Dates are ISO 8601. A range whose end precedes its start returns an empty series rather than an error, so assert on the shape you expect.
  • The same measures exist at workspace and organization scope. See the Analytics section for the full list.
  • Usage attributed to individual functions, playbooks, and tools is a separate set of measures under the same prefix.

When it fails

Use the up and down arrow keys to select a result, Enter to open it, and Escape to close the search.