Skip to main content

Usage APIs

Statistics use a completed data date, ds.

Statistics use a completed data date, ds. Prepare all data for that date before publishing it through Get latest statistics date. QwenWork reads the organization overview and every member page, validates them, and only then publishes a local snapshot.

Dates, periods and amounts

Parameter or fieldConvention
dsYYYY-MM-DD; a completed, immutable data date
timezoneAsia/Shanghai
period=cycleFrom the start of the billing cycle containing ds through ds
period=7d / 30dThe last 7 / 30 calendar days, including ds
period=monthFrom the start of the month containing ds through ds
period=last_monthThe complete calendar month before ds
last_data_update_timeMust equal the requested ds; a date, not an RFC3339 timestamp
Usage and balanceA nonnegative JSON number in credits, with at most four decimal places
RatiosPercentage points; 10 means 10%, not 0.1
Support all five periods with inclusive date boundaries. Return 0 when a day is known to have no consumption. Return null for unknown values only in nullable fields; do not fill incomplete data with zeros. Organization totals, member totals and daily trends must use consistent measurement rules. Every request includes the common headers. The following JSON is a complete success example: one test member on the same data date consumes 10 credits per day for the last seven days, totaling 70 credits.

Get latest statistics date

No request body or query parameters. HTTP 200:
Return a date only when the organization overview and all member pages for all five periods are readable. Return {"ds":null} when no complete data is available; do not default to today. Statistics refresh runs by default at 04:00 Beijing time plus a stable installation-specific delay of 0–1 hour. If data is behind T-1, it waits one hour and retries once by default. Confirm data readiness with the delivery team. The console shows the latest successfully published local date, which may differ from the date this endpoint just returned.

Query organization usage overview

ParameterTypeRequirement
dsstringRequired; a published data date
periodstringRequired; cycle/7d/30d/month/last_month
HTTP 200:
FieldTypeRequirement
qw_org_idstringQwenWork organization UUID from the request, not the enterprise ledger tenant ID
ds / last_data_update_timedate stringBoth must match the requested ds
subscribedbooleanMust be true for valid BYOK data, indicating statistics availability; no model subscription purchase is required
periodobjectkey matches the request; boundaries match the period; days is the actual day count
metrics.total_credits_usednumberEquals the sum of member usage and the sum of daily usage for the period
metrics.daily_average_creditsnumberTotal usage divided by days
metrics.active_member_countintegerDistinct members with consumption during the period
metrics.seat_countintegerPopulation used for statistics; does not grant QwenWork seats
metrics.active_member_ratenumber or nullactive / seat × 100; null when seat is 0
quota_snapshot.remaining_creditsnumber or nullRemaining cycle quota as of ds; null if unknown
quota_snapshot.cycle_start_date/cycle_end_datedate stringComplete billing-cycle boundaries containing ds, both inclusive
quota_snapshot.next_reset_datedate string or nullNext reset date; null if unknown
daily_trendarrayAscending, unique dates covering the entire selected period
timezone / retention_daysstring / integerFixed time zone and positive retention days matching the actual service agreement
For pure pay-as-you-go systems, keep the balance or next reset date null when unavailable. If there is no billing cycle, agree on a calendar month during integration and provide its actual boundaries. Do not fill a historical quota_snapshot with the current balance. Use Query organization quota for real-time quota. Ninety days is an example and recommendation, not a retention guarantee made by the platform on behalf of the enterprise.

Query member usage list

ParameterTypeConstraint
ds / periodstringSame as Query organization usage overview
page_nointegerStarts at 1
page_sizeinteger1–200
sortstringused_credits/quota_usage_rate/last_used_at
orderstringasc/desc
keywordoptional stringAt most 200 characters; no control characters
Return HTTP 400 for invalid parameters; do not silently change the page number or size. Break ties using external_user_id for stable ordering, with nulls last.
FieldTypeRequirement
rowsarray[] for no results; never null
rows[].external_user_idstringThe external ID currently bound in IAM; preserve case and leading zeros
rows[].used_creditsnumberConsumption within the requested period
rows[].cycle_used_creditsnumberConsumption from the start of the billing cycle containing ds through ds, regardless of the requested period
rows[].cycle_quota_creditsnumber or nullLimit for the cycle containing ds; null if unknown
rows[].quota_usage_ratenumber or nullCycle usage / cycle limit × 100; may exceed 100; null if the limit is 0 or unknown
rows[].last_used_atstring or nullRFC3339 recommended; null when there is no usage record
rows[].user_name/status/avatarstring or nullSupplemental information; QwenWork prefers the IAM snapshot for identity and department display
totalintegerComplete distinct member count for the current filter
page_no/page_sizeintegerMatch the request
has_morebooleanConsistent with the page number, row count and total
next_reset_datedate string or nullNext reset date
last_data_update_timedate stringEquals the requested ds
Pagination for a given ds must be stable: non-final pages must be full, users must not repeat across pages, and total must not change. QwenWork reads every page, not just the first 200 members. Duplicates, omissions, unbound identities or organization mismatches fail the entire batch and retain the previous published snapshot.

Query member daily usage trend

ParameterLocationRequirement
external_user_idpathExternal user ID, URL-encoded as a single path segment
dsqueryEnd date of the query
daysqueryInteger, 1–30
The response external_user_id must match the request. start_date is ds-(days-1), and end_date and last_data_update_time both equal ds. points must contain exactly days consecutive, ascending entries. credits is a nonnegative credit number; the name is nullable supplemental information. Member daily trends are read on demand. The enterprise service must retain at least the trend data for the two published batches still displayed by QwenWork. Return snapshot_not_found for expired data; do not silently query the latest date. Do not infer historical account ownership after an identity is unbound or a member is removed.
Usage APIs - QwenWork