DealSleek API · Billing
PreviewRate Usage Period
Legacy supplied-facts rating is rejected at commit. Use DRAFT_BILLING_CYCLE with a stored sealed period and independent Finance review.
/api/v1/billing/dispatchHeaders
AuthorizationstringRequiredAccess token of the signed-in user, as a Bearer token. It identifies the user, their role and the workspace.
X-CQRS-ActionstringRequiredNames the command to run. Must be
RATE_USAGE_PERIODfor this endpoint.Content-TypestringRequiredAlways
application/json.X-Idempotency-KeystringOptionalA key you choose that is unique to this attempt. A command repeated with the same key is not applied a second time.
X-Correlation-IdstringOptionalYour own identifier for the request. Returned in the
x-correlation-idresponse header; generated when you leave it out.
Request body
current_statusenumRequiredA metering period's progress from open to invoiced.
- Allowed values
- OPEN
- CLOSING
- CLOSED
- INVOICED
- NO_CHARGE
- CARRIED_FORWARD
- OPEN
- Accepting usage events.
- CLOSING
- Boundary passed; inside the late-arrival grace window.
- CLOSED
- Sealed. Late events go to the next open period.
- INVOICED
- Rated onto an invoice.
- NO_CHARGE
- Independently reviewed zero-charge period.
- CARRIED_FORWARD
- Positive charges retained for a subsequent invoice.
metersarray of objectRequiredRAW events per meter, not pre-computed totals.
3 child fields
meterobjectRequiredA tenant-defined meter.
9 child fields
aggregationenumRequiredHow a period's events collapse to one number.
- Allowed values
- SUM
- MAX
- LAST
- UNIQUE_COUNT
- SUM
- Total consumption over the period.
- MAX
- Highest value seen — peak provisioning.
- LAST
- Value at period close — current state, e.g. storage.
- UNIQUE_COUNT
- Distinct subjects — monthly active users.
codestringRequiredStable identifier used by producers and printed on invoices. Immutable once events reference it — renaming a meter orphans its history.
- minimum length 1
- maximum length 64
created_atdate-timeRequiredNo description yet.
display_namestringRequiredNo description yet.
- minimum length 1
iduuidRequiredNo description yet.
statusenumRequiredLifecycle of a meter definition. Meters are archived, never deleted: usage events reference them and an invoice must stay explicable years later.
- Allowed values
- ACTIVE
- ARCHIVED
tenant_iduuidRequiredNo description yet.
unitstringRequiredNo description yet.
system_metricenum or nullOptionalSet when this meter is one of the built-ins, so system-emitted usage and tenant-defined usage share one pipeline.
- Allowed values
- API_CALL
- AGENT_TASK
- MEETING_MINUTES
- EMAIL_SENT
- CONTRACT_GENERATED
- ACTIVE_SEATS
priceobjectRequiredA resolved price for a product — Salesforce's PricebookEntry, Stripe's Price. Split out from the product because ONE product legitimately has many prices: per currency, per billing cycle, per pricing model. Holding a single
base_priceon the product is what forces every tiered plan to bill as flat.12 child fields
billing_cycleenumRequiredNo description yet.
- Allowed values
- MONTHLY
- QUARTERLY
- ANNUAL
- SEMI_ANNUAL
currencystringRequiredNo description yet.
iduuidRequiredNo description yet.
is_activebooleanRequiredNo description yet.
modelenumRequiredNo description yet.
- Allowed values
- FLAT
- TIERED
- VOLUME
- SEAT_BASED
product_iduuidRequiredNo description yet.
unit_amountstringRequiredFlat and seat-based prices use this. Tiered/volume prices ignore it.
included_unitsstringOptionalUnits included before metering starts.
- Default
- 0
meter_iduuid or nullOptionalThe meter this price rates. Required for metered prices and the link that was missing: without it nothing can answer "which price applies to this meter's usage", and a period cannot be rated at all.
tier_modeenumOptionalNo description yet.
- Allowed values
- GRADUATED
- VOLUME
- Default
- GRADUATED
- GRADUATED
- Bracketed — each tier prices only its own slice (income-tax style).
- VOLUME
- Landed — the tier the total reaches prices every unit.
tiersarray of objectOptionalNo description yet.
3 child fields
unit_pricestringRequiredNo description yet.
flat_feestringOptionalCharged once when this tier is used at all.
- Default
- 0
limitstring or nullOptionalInclusive upper bound.
Nonemarks the final, unbounded tier.
usage_aggregationenum or nullOptionalSet for metered prices: how the period's events collapse to one number. Falls back to the meter's own aggregation when absent.
- Allowed values
- SUM
- MAX
- LAST
- UNIQUE_COUNT
- SUM
- Total consumption over the period.
- MAX
- Highest value seen — peak provisioning.
- LAST
- Value at period close — current state, e.g. storage.
- UNIQUE_COUNT
- Distinct subjects — monthly active users.
recordsarray of objectRequiredNo description yet.
4 child fields
idempotency_keystringRequiredNo description yet.
quantitystringRequiredNo description yet.
sequenceintegerOptionalOrders events within the period; decides
LASTaggregation.- Default
- 0
- at least 0
subjectstring or nullOptionalNo description yet.
period_iduuidRequiredNo description yet.
commitmentobject or nullOptionalPrepaid balance to draw against, when the account holds one.
11 child fields
account_iduuidRequiredNo description yet.
balancestringRequiredcommitted - drawn. Stored so entitlement checks can read it without re-summing the whole draw history on every request.committed_amountstringRequiredNo description yet.
currencystringRequiredNo description yet.
drawn_amountstringRequiredNo description yet.
iduuidRequiredNo description yet.
tenant_iduuidRequiredNo description yet.
term_enddate-timeRequiredNo description yet.
term_startdate-timeRequiredNo description yet.
treatmentenumRequiredWhat happens to whatever is left at
term_end.- Allowed values
- FORFEIT
- ROLLOVER
- TAKE_OR_PAY
- FORFEIT
- Unused balance is lost — the customer bought capacity, not units.
- ROLLOVER
- Unused balance carries into the next term.
- TAKE_OR_PAY
- The customer owes the difference between commitment and consumption.
trued_up_atdate-time or nullOptionalNo description yet.
Response
Status 202. The command was applied. The body reports the outcome and, where the command changes a record, that record's new state.
successbooleanRequiredtruewhen the command was applied.error_messagestringRequiredEmpty when the command was applied.
projected_stateobjectOptionalThe record as it stands after the command.
event_payloadobjectOptionalThe event the command recorded.
insightsarray of objectOptionalAdvisory notes about the result. Each has a
code, amessageand animpactnumber.
Errors
Every error carries an HTTP status. Where it also carries a code, branch on the code, not on the message.
- 400
X-CQRS-Actionis missing or names a command this route does not accept. SendRATE_USAGE_PERIOD. - 400
DOMAIN_ROUTINGThe body is not a valid command. Check the required fields and their types. - 401The access token is missing, expired or not valid.
- 401
L1_AUTHThe caller's role is belowfinanceor the caller has no access to this record. - 403
L1_POLICYA business rule refused the command. The message names the rule. - 409
L1_IDEMPOTENCYA command with this idempotency key was already applied. - 409
CONFLICTThe command would duplicate a record that must be unique. - 500
L3_COMMITThe command was valid but could not be saved.