1. Tasks
  2. Get Stubbucks Usage

Tasks

Get Stubbucks Usage

Returns your organization's Stubbucks charges for a date range, totalled or grouped by template, draft or live, context, stub, stubpost, action, charge code, category, day or month. Useful for usage reports, cost alerts and showing what a process costs.

The task reports on the organization of the stub it runs in. It looks back at most 93 days.

TIP

For scheduled or large reports, set execution.ephemeral to true. The result is still available to the rest of the action, eg to build a PDF or send a summary, but isn't saved on the stubpost. Otherwise every run of the report is stored on its stubpost.

Basic usage

Total charges per template for November:

loading...

Permissions

The user who runs the action needs the view_billing permission in the organization. Actions that aren't run by a user, such as scheduled actions and actions triggered by messages on WhatsApp, email, SMS or webchat, run as the Stubber System user and are always allowed.

Parameters

date_from
required
string

The start of the range, as a date (2026-11-01) or a date and time without an offset (2026-11-01T08:00), in timezone. It can be at most 93 days ago.


date_to
required
string

The end of the range, in the same format. A date includes the whole day, a date and time is inclusive.


timezone
optional
string

The IANA time zone the dates are in, eg Africa/Johannesburg. It also decides where day and month groups start and end.

Default: UTC


group_by
optional
array

What to group the charges by. Combine several to group by all of them, eg ["template", "day"] gives one row per template per day. Leave it out for one row with the organization's total.

Value One row per Row fields
template template templateuuid, template_name
branch branch the action ran on: draft (testing) or live branch
context template context, eg default or _create context
stub stub stubref, templateuuid, template_name
stubpost stubpost (one run of an action) stubpostuuid, stubref, templateuuid, template_name, branch, context, action_name, created_at
action_name action, per template, since actions with the same name in different templates are different actions templateuuid, template_name, action_name, stubposts
code charge code, eg gpt_chat or whatsapp_out code, quantity
category charge category, eg llm or notifications category
day day, in timezone day (YYYY-MM-DD)
month month, in timezone month (YYYY-MM)

templateuuids, stubrefs, codes, action_names, branches, contexts
optional
array

Only count charges for these templates, stubs, charge codes or action names. Filters don't change the rows' fields, and they can be combined with any group_by.


limit
optional
number

The most rows to return, from 1 to 5000. The groups with the highest charges are kept, and the rest are added up in an _other row.

Default: 500

Result

loading...

Properties

payload.rows
array

One row per group, with the highest charges first. Rows grouped only by day or month are in date order. Each row has the fields of its groups (see group_by above) and these values:

Field Meaning
total_price_msb The charges in millistubbucks (1 Stubbuck = 1000 millistubbucks)
total_stubbucks The charges in Stubbucks
total_usd The charges in US dollars
charges How many charges there were
stubs How many different stubs had charges. Not included when grouping by stub, stubpost, action_name, branch or context
stubposts When grouping by action_name: how many times the action ran. Divide total_stubbucks by it for the cost per run
quantity When grouping by code: the units charged, eg tokens, seconds or messages

Charges that don't belong to a template or stub, such as platform charges, have null in those fields.


payload.totals
object

total_price_msb, total_stubbucks, total_usd, charges and stubs for all the charges in the range, including those in _other.


payload.truncated
boolean

true when there were more groups than limit. The last row then has _other in its group fields and holds the remaining charges, so the rows always add up to totals. _other has no stubs count.


payload.action_names_complete_until
string

Only when grouping or filtering by action_name, branch or context. These are filled in every 15 minutes, so the most recent charges don't have them yet. They're left out of the rows and totals, and this is the time (in timezone) up to which charges are included.

Charges whose stubpost can't be found, and charges that don't belong to a stubpost, have _unknown as their action name, branch and context. When grouping by stubpost, a stubpost that hasn't been filled in yet has null instead.

Errors

message Meaning
invalid_date_from, invalid_date_to The date isn't YYYY-MM-DD or YYYY-MM-DDTHH:mm[:ss]. Dates with an offset or Z aren't accepted, use timezone instead
date_from_too_old date_from is more than 93 days ago. error.details.earliest_allowed is the earliest you can use
date_from_after_date_to The range is the wrong way round
invalid_timezone timezone isn't an IANA time zone name
invalid_group_by A group_by value isn't in the list above
invalid_filter A filter isn't a non-empty array of strings, or a templateuuids value isn't a UUID
too_many_filter_values A filter has more than 1000 values
invalid_limit limit isn't a whole number from 1 to 5000
user_not_authorized The user who ran the action doesn't have view_billing
action_names_not_available_yet Grouping or filtering by action_name, branch or context before they have been filled in for the first time. Try again later

These are conceptual errors.

Reports are cached for 5 minutes, so running the same report again within 5 minutes returns the same result.

Examples

Daily cost of one template this month

loading...

What this template costs in production

Leave out draft testing with the branches filter:

loading...

Which actions cost the most

Group by action_name and use stubposts for the cost per run:

loading...

What a stub has cost so far

loading...