logo
开发者文档
搜索
Obtain Organization Credit Usage Distribution

Obtain Organization Credit Usage Distribution

Get the proportion ranking of an organization’s credits or tokens by Agent/Workflow, as well as trends by day, week, or month. You can view only Agents or only Workflows.

Note: Data can be queried for up to 92 days; only development spaces are counted. The statistical scope is described below under "Statistical Criteria".

Request Method

GET

Call URL

https://api-${endpoint}.gptbots.ai/v1/org/usage/distribution

Call Authentication

Use account-level DevKey/DevSecret with Basic authentication: Authorization: Basic ${BASIC_TOKEN}, where ${BASIC_TOKEN} is the Base64 encoding of DevKey:DevSecret.

  • The calling account must be a member of the organization corresponding to org_id and have "Usage View" permission (organization Owners and Administrators have it by default).
  • Please call the address of the data center where the organization is located. ${endpoint} should be taken from region returned by Query Organization List (SG → sg, TH → th, JP → jp). Calling other data centers will return "Not a member of this organization."

Call Frequency

  • Each developer key can call this API up to 10 times per minute.
  • Each call counts toward the organization’s package "Statistical API" per-minute quota and shares this quota with Agent API Key calls to statistical interfaces.
  • Query results are cached for 10 minutes. It is recommended to call once per day.

Request

Request Example

curl -X GET 'https://api-${endpoint}.gptbots.ai/v1/org/usage/distribution?org_id=${org_id}&start_time=1792425600000&end_time=1792684800000&agent_type=WORKFLOW&granularity=DAY' \ -H 'Authorization: Basic ${BASIC_TOKEN}'
                      
                      curl -X GET 'https://api-${endpoint}.gptbots.ai/v1/org/usage/distribution?org_id=${org_id}&start_time=1792425600000&end_time=1792684800000&agent_type=WORKFLOW&granularity=DAY' \
  -H 'Authorization: Basic ${BASIC_TOKEN}'

                    
此代码块在浮窗中显示

Request Headers

Field Type Description
Authorization Basic ${BASIC_TOKEN} Basic Token using DevKey:DevSecret Base64.

Request Parameters

Field Type Required Description
org_id String Yes Organization ID.
start_time Long Yes Start time, in milliseconds timestamp. Extend to 0:00 the same day according to the organization's time zone.
end_time Long Yes End time (exclusive), in milliseconds timestamp. The start and end dates can span up to 92 days.
metric String No CREDITS (credits, default) or TOKENS.
granularity String No Time granularity of the trend: DAY (default), WEEK (week starting Monday), MONTH.
agent_type String No AGENT only for Agents, WORKFLOW only for Workflows; if not provided, both types are ranked together.
top_n Integer No Number of trend series items to keep, from 1 to 50, default 50, the rest are merged into a OTHER row.

Response

Response Example

{ "code": 0, "message": "OK", "data": { "timezone": "+07:00", "data_since": "2026-10-15", "buckets": ["2026-10-16", "2026-10-17", "2026-10-18"], "total": 812.4411, "series": [ { "row_type": "ITEM", "agent_id": "65f0c2a1b4e8d93a1c7e5b2a", "name": "订单查询", "agent_type": "WORKFLOW", "total": 402.1200, "share": 49.49, "points": [130.5000, 141.0200, 130.6000] }, { "row_type": "OTHER", "agent_id": null, "name": null, "agent_type": null, "total": 410.3211, "share": 50.51, "points": [120.1000, 150.2000, 140.0211] } ], "ranking": [ { "row_type": "ITEM", "agent_id": "65f0c2a1b4e8d93a1c7e5b2a", "name": "订单查询", "agent_type": "WORKFLOW", "total": 402.1200, "share": 49.49 } ] } }
                      
                      {
    "code": 0,
    "message": "OK",
    "data": {
        "timezone": "+07:00",
        "data_since": "2026-10-15",
        "buckets": ["2026-10-16", "2026-10-17", "2026-10-18"],
        "total": 812.4411,
        "series": [
            {
                "row_type": "ITEM",
                "agent_id": "65f0c2a1b4e8d93a1c7e5b2a",
                "name": "订单查询",
                "agent_type": "WORKFLOW",
                "total": 402.1200,
                "share": 49.49,
                "points": [130.5000, 141.0200, 130.6000]
            },
            {
                "row_type": "OTHER",
                "agent_id": null,
                "name": null,
                "agent_type": null,
                "total": 410.3211,
                "share": 50.51,
                "points": [120.1000, 150.2000, 140.0211]
            }
        ],
        "ranking": [
            {
                "row_type": "ITEM",
                "agent_id": "65f0c2a1b4e8d93a1c7e5b2a",
                "name": "订单查询",
                "agent_type": "WORKFLOW",
                "total": 402.1200,
                "share": 49.49
            }
        ]
    }
}

                    
此代码块在浮窗中显示

Successful Response

Field Type Description
timezone String The organization's timezone (UTC offset, e.g., +07:00).
data_since String The earliest date for which credits data is available (yyyy-MM-dd); intervals before this are incomplete; if no data is present yet, it is null.
buckets String[] Starting dates of the time buckets in ascending order: for daily by the day, for weekly by Monday (yyyy-MM-dd), for monthly by yyyy-MM. points corresponds in this order.
total Number Total amount in the interval (credits or tokens, depending on metric).
series Object[] Top top_n rows used for trends, sorted by total amount descending; the rest are merged into one row row_type = OTHER.
ranking Object[] Complete rankings, up to 500 rows; any excess is merged into one row OTHER. Does not include points.
series[].row_type / ranking[].row_type String ITEM indicates an Agent or Workflow; OTHER indicates a merged item; UNATTRIBUTED indicates consumption not belonging to any Agent (e.g., knowledge base storage, speech recognition); if agent_type is provided, this row is not returned.
series[].agent_id / ranking[].agent_id String ID of the Agent or Workflow; OTHER / UNATTRIBUTED behavior is null.
series[].name / ranking[].name String Name; OTHER / UNATTRIBUTED behavior is null.
series[].agent_type / ranking[].agent_type String AGENT or WORKFLOW; OTHER / UNATTRIBUTED behavior null.
series[].total / ranking[].total Number Total amount in the interval, rounded to 4 decimal places.
series[].share / ranking[].share Number Percentage of the total in the interval, from 0 to 100, rounded to 2 decimal places.
series[].points Number[] Values for each time bucket.

Failure Response

Field Type Description
code Integer Error code.
message String Error details.

Error Codes

The HTTP status code corresponds to the first three digits of the error code, for example, 40000 corresponds to 400, 40100 corresponds to 401, 403132 corresponds to 403.

Error Code Description
40000 Parameter error, such as missing required parameters or invalid parameter values.
40001 Too frequent calls: the developer key has exceeded the per-minute limit for this API.
40008 Exceeded the per-minute quota of the organization’s "Statistics API" package.
40010 The API is temporarily closed, please try again later.
40100 No permission: missing usage viewing permission.
40105 Not a member of the organization, or called the address of another data center.
40324 DevKey or DevSecret error.
403132 Invalid time range: start time is not earlier than the end time, or exceeds the maximum query range.

Statistical Scope

  • Scope of Statistics: Only counts the developer space, including API, share pages, web embedding, bubble components, LiveDesk, as well as various instant messaging and phone channels, and the developer space's Workflow; it does not include the usage of workspaces (GWork), nor does it include the parts of published Agents used within workspaces. Therefore, the total amount may be slightly lower than the same period shown on the console's "Organization → Usage" page.
  • Credits: All types of consumption (excluding expired credits and subscription payments); workflow consumption is recorded under the workflow itself.
  • Data Start Point: Available from the feature launch date (data_since), with no backfill of historical data.
  • Update Frequency: Updated in real time.