Billing and projects
Funding and usage
Read funding, orders, paid lots, usage and refunds, quote a run, and raise Company budget ceilings. Billing is a shared platform foundation, not a product API.
Local preview only, contract 1. Fixture tariffs and confirmations do not prove live payments. The broader export and deletion lifecycle is not established.
Quickstart
Call billing from a trusted backend with a project credential and scope headers. Amounts are integer USD microdollars (USD1 = 1,000,000); times are UTC Unix milliseconds.
Authorization: Bearer <project credential>
X-Roye-Project: <projectId>
X-Roye-Environment: development
Roye-Contract-Version: 1
Content-Type: application/jsonEach thin SDK method maps to one route.
import { Roye } from '@roye-ai/client';
const roye = new Roye({ baseURL, projectId, environment: 'development', token });
const preview = await roye.billing.preview();
const status = await roye.billing.status();
const quote = await roye.billing.quote({
mode: definition.mode,
participants: definition.participants.map(({ id, model, maxOutputTokens }) => ({ id, model, maxOutputTokens })),
});
const usage = await roye.billing.usage.list({ limit: 25 });
const runBill = await roye.billing.usage.getRoundtableRun(runId);
const executionBill = await roye.billing.usage.getAgentExecution(executionId);
const evaluationBill = await roye.billing.usage.getEvaluationRun(evaluationRunId);
const budget = await roye.billing.companyBudgets.get(companyId);Authentication and scope
- Calls use current project management authority, rechecked on replay. Keep backend keys out of browsers. Without
Roye-Contract-Versionyou get contract 1. - Redeeming a code needs the organization owner's console sign-in.
- Roye staff record payments, refund outcomes and funding control under a restricted authority that no customer credential confers.
Response fields
Orders, lots, grants, refunds and usage also have id and scope.
| Resource | Fields |
|---|---|
| Status | currency, fundingState, reason, supportEmail, packsUsd, available/held/refundHeld/used/expired/refundedMicros, expiryPending, liabilityState |
| Order | organizationId, packUsd, amountMicros, currency, state, lotId, created/confirmedAt |
| Paid lot | orderId, purchasedAt, expiresAt, granted/available/held/used/refundHeld/refunded/expired/reversedMicros |
| Promotional grant | currency, grantedAt, expiresAt, granted/available/held/used/expiredMicros |
| Refund | lotId, orderId, amount/payout/roundingCost/originalRoutePayout/residualMicros, state, route, requested/due/escalate/updatedAt, originalRouteUntil |
| Usage | source, deprecated original, currency, maximum/held/charged/releasedMicros, pricing (only for originals of up to eight participants), state (reserved/pending/settled/waived), reason (completed/cancelled/failed/unknown_deadline or null), companyId, created/release/settledAt |
| Company budget | companyId, scope, currency, limit/packageLimit/held/chargedMicros, revision, created/updatedAt |
- Creating an order, refund or redemption returns
201and reads return200, as bare resource objects. - Server policy sets
packUsd,packsUsd,supportEmail, the preview limits and the refundroute. Keep unseen values, here and in usagesource; requests accept only listed ones.
Quotes
POST /v1/billing/quote is read-only: it reserves nothing and grants no permission to run.
| Shape | Body |
|---|---|
Roundtable (no module, or roundtable) | mode (single, opening, parallel) and 1 to 8 unique participants with id, model, maxOutputTokens. single takes one. |
Agents (module: "agents") | profile, model and maxOutputTokens (its defaults.maxOutputTokens) of the definition revision you will run. Prices one participant, agent. |
The response has maximumMicros, policyRevision and each participant's model, tariff revision, cache semantics, token bounds and rational unitMicros rates. An Agents quote's maximumMicros equals the execution's hold after admission while catalog and policy are unchanged.
POST /v1/billing/quote
{"module":"agents","profile":{"id":"structured","revision":"1"},
"model":"<definition model>","maxOutputTokens":1024}// revision: the Agents definition revision the execution will run
const quote = await roye.billing.quote({
module: 'agents',
profile: revision.profile,
model: revision.model,
maxOutputTokens: revision.defaults.maxOutputTokens,
});
// After admission the execution holds the same maximum.
const bill = await roye.billing.usage.getAgentExecution(executionId);
// bill.maximumMicros === quote.maximumMicros
// bill.source: { module: 'agents', type: 'execution', id: executionId }An unlisted Agents profile or other module returns unsupported_capability; a missing verified price or funded goodwill returns not_ready.
Packs, lots and grants
- Default packs are USD 10, 30 and 100 (
packsUsd), of equal value. No subscription or automatic top-up. - An order collects no funds and grants no credit. A confirmed order's paid lot expires 12 UTC calendar months after purchase (February 29 clamps to 28); delays, retries and recreation never extend it.
- Promotional grants are separate, nonrefundable credit with no purchase path, and expire one UTC calendar year after grant. Usage spends eligible grants first.
- The credits list's
purchasesAvailable, not a grant, says whether paid orders are open. expiryPendingandliabilityState: blockedare explicit containment states.
Refunds
A refund request reserves unused, unheld paid money on the original lot. accepted does not mean paid.
| Rule | Value |
|---|---|
| Eligibility | Within 150 days of purchase. |
| Target | Five UTC business days, Monday to Friday. |
| Escalation | Purchase day 165, or earlier on a known denial or unavailability. |
| Original route | PayPal's 180-day limit never writes off the obligation. |
| Rounding | Payouts round up to cents; Roye funds the fraction. |
| Residual | originalRoutePayoutMicros is the original route's capacity. residualMicros stays owed, never silently paid there or discarded. |
| Pending or unknown | No duplicate payment. |
| Bank fallback | Needs consent, the original payer as verified beneficiary, proof the original cannot complete, and separate transfer authority. |
| Reversal | Preserves obligations. |
| Support | Email only, support@roye.ai. First response target: two UTC business days. |
Company budgets
- Each Company has a shared lifetime ceiling and a per-package ceiling, USD 5 each by default, apart from supplier safety caps. No calendar reset, top-up or lowering; totals are projections, not charges.
- Only the organization owner with current project authority can raise them, even on replay. Send whole micros and the current
expectedRevision(a stale one returns409 revision_conflict); only increases are accepted.
Endpoints
Paths start with /v1/billing except the preview. POSTs except the quote take an idempotencyKey.
| Route | Purpose |
|---|---|
GET /v1/projects/:projectId/:environment/billing/preview | Lifetime units, content bytes, occupied Company and staff places. |
GET /status | Funding status and balances. |
GET /credits[/:id] | Promotional grants. |
POST /redemptions | Redeems a code; returns redemption and credit. |
POST /orders | Orders a listed pack. |
GET /orders[/:id] | Orders. |
GET /lots[/:id] | Paid lots. |
POST /refunds | Requests amountMicros above 0 from lotId. |
GET /refunds[/:id] | Refunds. |
GET /usage[/:id] | Original usage. |
GET /usage/roundtable/:runId | Usage of one Roundtable run. |
GET /usage/agents/:executionId | Usage of one Agents execution. |
GET /usage/evaluations/:runId | Usage of one Evaluations run. not_found for a run that planned no model call. |
GET /company-budgets/:companyId | Company ceilings. |
POST /company-budgets/:companyId/raise | expectedRevision, limitMicros, packageLimitMicros. |
POST /quote | Exact rates and a conservative maximum. |
SDK mutations persist and recover intents like other platform operations; the SDK executes no payment.
const order = await roye.billing.orders.create({ packUsd: 10, idempotencyKey: 'purchase-1' });
const lots = await roye.billing.lots.list({ limit: 25 });
// Use a verified original lot ID; acceptance reserves funds, it does not send money.
const refund = await roye.billing.refunds.request({
lotId: originalLotId, amountMicros: 1000000, idempotencyKey: 'refund-1',
});Limits
| Limit | Value |
|---|---|
| Lists | limit 1 to 25, opaque cursor up to 512 characters passed back unchanged; pages return items and next. |
| Identifiers | 1 to 80 URL-safe characters; references and reasons 1 to 120. |
| Quote output | maxOutputTokens 1 to 2,048. |
| Project preview | 1,000 original units and 10 MiB of content, shared by both environments. |
| Company and staff | One active Company and four staff places (proposed, hired, suspended or ending); withdrawn or ended ones free theirs. |
Unknown body fields and repeated or unsupported queries are refused.
Errors
Errors use the common envelope. Missing and inaccessible resources both return not_found; neither an error nor an empty page proves zero supplier exposure.
| Code | HTTP | What to do |
|---|---|---|
invalid_request, bounds_exceeded, payload_limit | 400, 400, 413 | Fix micros, pack, paging or headers. |
contract_version_unsupported, unsupported_capability | 400 | Use a served contract or capability. |
unauthorized, credential_expired, credential_revoked, forbidden, authority_revoked | 401, 403 | Get current scoped authority. |
not_found | 404 | Check the scoped ID; do not probe other tenants. |
idempotency_conflict | 409 | Recover the original input; never reuse a key for new input. |
invalid_transition, binding_invalid, effect_unresolved | 409 | Check original evidence. A pending or unknown payout blocks fallback until its route is denied. |
budget_exhausted, not_ready | 409 | Read status, unheld funds, liability and the original lot. |
operation_pending, operation_replay_expired | 202, 410 | Observe or recover the original with its key. |
rate_limited, unavailable | 429, 503 | Retry only as permitted, with the same input and key. |
promotion_unavailable, promotion_already_redeemed | 409 | Paused, expired or used up, or already redeemed by this organization or user. Nothing more is credited. |
Recovery
Before sending, persist the project, environment, module platform, kind, target, idempotencyKey and exact input.
| Kind | Target |
|---|---|
billing.orders.create | Empty |
billing.redemptions.create | Empty |
billing.refunds.request | Original lotId |
billing.company_budgets.raise | companyId |
- Same key and input replay the original with
Roye-Replayed: true; changed input conflicts. - After a lost response, call
operations.recoverwith the original scope and target first. Keep the key, body and revision. - No response or
unknownstate never justifies a replacement payment or refund. - Permanent originals replay even after operation history expires, without replenishing usage.
POST /v1/operations/recover
{"module":"platform","kind":"billing.refunds.request",
"target":{"lotId":"<originalLotId>"},"idempotencyKey":"refund-1"}
POST /v1/billing/refunds
{"idempotencyKey":"refund-1","lotId":"<originalLotId>","amountMicros":1000000}Usage
A usage row is one customer original, apart from supplier liabilities. It keeps the frozen pricing snapshot only when the original has at most eight participants; a larger original, such as an Evaluations run of more than eight calls, has no pricing. source is open: { module: "roundtable", type: "run", id } for a Roundtable run, { module: "agents", type: "execution", id } for an Agents execution and { module: "evaluations", type: "run", id } for an Evaluations run. Other module codes may appear.
Unknown customer holds release as Roye-funded goodwill by the original 72-hour ceiling. Supplier unknowns stay preserved, and late facts never recreate the debit.
The no-model preview counts each productive mutation once: each Communication recipient delivery, each Automation productive entry. Bounded copies count once; new content needs admission. Deletion, replay and time never refill it. Reads, stop and cleanup stay available; the preview creates no charge or model entitlement.