Skip to main content

Quota APIs

The enterprise quota system is authoritative for applied limits and usage.

The enterprise quota system is authoritative for applied limits and usage. QwenWork sets an absolute member limit; the enterprise system enforces it and returns the actual result.

Units and validity

All quota amounts are nonnegative decimal integer strings in credit_minor: 10000 minor = 1 credit, with a maximum of 9223372036854775807. Do not return JSON numbers, floating-point values or negative amounts. This guide uses a synthetic scenario: a member limit of 500 credits, 70 used, 430 remaining, and an organization total of 1000 credits. The current product accepts only integer credit limits with a minimum of 500. A lower minimum from Query quota rules and period does not relax product validation.
validityexpires_atMeaning
permanentnullA permanent limit configuration; consumption is still measured by billing cycle
current_cycleRFC3339 timestampValid for the current cycle; expiration is an exclusive boundary
See Quick start and Error handling for common headers and errors.

Query quota rules and period

No request body or query parameters. QwenWork uses this endpoint to read the configurable range and current period; it does not return the real-time organization balance.
FieldTypeRequirement
organization_idstringExactly matches the requested organization
unit / scalestring / integerFixed at credit_minor / 10000
minimum_allowancestringMinimum accepted limit
maximum_allowancestring or nullAt least minimum; null means no known configuration ceiling, not unlimited member quota
cycle_idstringNonempty identifier for the current cycle
cycle_start / cycle_endRFC3339 stringInclusive start, exclusive end; end strictly later than start
metering_modestringFixed at periodic_ceiling
updated_atRFC3339 stringQuota context update time
Provide every field above; only maximum_allowance may be null. Do not enable the extension if billing periods or limit enforcement are unavailable.

Query member quotas

This is a read-only POST. The request contains 1–200 distinct external user IDs. Return one result per ID in request order, without omissions.
HTTP 200:
FieldTypeRequirement when applied
external_user_idstringMatches the corresponding request ID verbatim
statusstringapplied, not_configured or not_found
binding_idstringNonempty; from the applied Set member limit request
applied_revisionintegerApplied revision, greater than 0
allowance / used / remainingstringActual limit, usage and remaining amount, all in minor units
validity / cycle_idstringValidity type and nonempty cycle ID
expires_atstring or nullConsistent with the validity type
updated_atRFC3339 stringActual quota update time
error_codenullSuccessful items must not contain an error code
Explicitly return null values when no configuration exists:
Use not_found when the user does not exist, without fabricating a zero quota. Organization authorization failures must return HTTP 403. A queued target revision that has not executed must not be reported as applied. The SDK provides explicit queries, but product quota dispatch does not require a read-after-write call to Query member quotas. Do not treat local configuration or a dispatch acknowledgement as a real-time query result.

Set member limit

Each request contains exactly one member. QwenWork dispatches quota changes in the background and retries failures through its existing mechanism. This is not a top-up request: do not add allowance to the previous limit or reset usage. Complete request example, using the terminal variables from Quick start; execute only for a test member:
Request fieldTypeRequirement
binding_idstringNonempty binding identifier supplied by the caller; echo verbatim
itemsarrayExactly one item
items[].external_user_idstringExternal user ID in the current organization
items[].desired_revisionintegerTarget revision greater than 0
items[].allowancestringAbsolute limit in minor units
items[].validitystringpermanent or current_cycle
items[].cycle_idstringQuota cycle for this write
items[].expires_atstring or nullnull for permanent; expiration time for current_cycle
HTTP 200 must return the applied response from Query member quotas, with organization, user, binding, revision, allowance, validity, cycle_id and expires_at matching this write. The successful query example above is the acknowledgement for this write. Return success only after the enterprise service has applied the change and it can be read back. Retries for the same organization and write intent use the same idempotency key. The enterprise service must avoid executing the same write twice and must not treat a duplicate as a new top-up. QwenWork does not promise exactly-once execution or cross-system transactions. A timeout does not mean the enterprise service did not execute the write. Mismatched acknowledgements are failures and follow the existing retry flow.

Query organization quota

No request body or query parameters, and no member identity mapping is required. QwenWork reads this endpoint when querying organization quota; it does not derive the result from member quotas or historical statistics.
All three fields are required. The organization must match the request; allowance and used are minor-unit integer strings. The example represents a total of 1000 credits with 70 used. used may exceed allowance to report actual overuse. Unknown values must produce an error, not nulls, omitted fields or fabricated zeros. Query organization quota returns real-time data, while Query organization usage overview returns a historical snapshot. They need not return identical values at different times. A 404 does not mean the extension is disabled and does not trigger a fallback to a default quota.