Skip to content
Oclavex is in private preview, open to existing MonetizeIt users. New users who would like to evaluate Oclavex before the public launch can request access at info@revenusion.com.

Billing events

Your billing system knows when a customer subscribes, pays, falls behind, changes plan or leaves. Oclavex turns those facts into entitlements. The Stripe connector reads them from Stripe; billing events let any other billing system — Chargebee, Recurly, Paddle, or one you built — send them. Three endpoints take the same events the connector produces, and Oclavex applies each one exactly the way it applies Stripe’s.

Your billing system says You post Oclavex
A subscription started, changed, fell behind, paused or ended subscription-changed Creates, binds, updates, holds or ends the entitlement the subscription belongs to
A customer’s details changed account-changed Creates or updates the organization with the same reference
A credit purchase was paid credit-purchase-completed Adds the credits to the entitlement’s balance, once
  1. In Settings → API credentials, create a client and grant it provision.billing-event.create — the only scope these endpoints need.
  2. Exchange its id and secret for a token with the client_credentials grant (see Authentication), asking for that scope:
Terminal window
curl -X POST https://api.example.com/auth/connect/token \
-d grant_type=client_credentials \
-d client_id=$ID -d client_secret=$SECRET \
-d scope=provision.billing-event.create

api.example.com stands in for your endpoint — replace it with your own host.

Every event names what it is about as scheme:kind:id, in your billing system’s words: chargebee:subscription:AzZ9TK7pXm, chargebee:customer:16BQ4E1. The scheme is your billing system; the kind and id are what it calls the object. Oclavex finds the subscription’s entitlement by that reference from then on, so keep it stable.

The schemes sfdc, oclavex, manual, none and operator belong to the built-in connectors and billing modes. An event that uses one is refused with 403 license.reserved_scheme.

The stripe scheme is reserved only while the environment has the Stripe connector registered. A team that runs Stripe itself posts stripe:subscription:sub_… and stripe:customer:cus_… like any other billing system’s references; see The relay alternative. Registering the connector later does not change the entitlements already posted: the connector updates them by the same references, and from then on an event that uses stripe is refused.

Terminal window
curl -X POST https://api.example.com/api/v1/provision/admin/billing-events/subscription-changed \
-H "authorization: Bearer $TOKEN" -H "content-type: application/json" \
-d '{
"externalReference": "chargebee:subscription:AzZ9TK7pXm",
"accountExternalReference": "chargebee:customer:16BQ4E1",
"customerEmail": "billing@acme.example",
"customerName": "Acme Corp",
"changeType": "Created",
"status": "Active",
"entitlementOfferKey": "pro-annual",
"planName": "professional",
"quantity": 1,
"startsAt": "2026-09-23T10:00:00Z",
"currentPeriodEndsAt": "2026-10-23T10:00:00Z",
"latestInvoicePaid": true,
"sourceEventId": "ev_16BQ4E1a",
"observedAt": "2026-09-23T10:00:04Z"
}'

An entitlement a billing event creates is not on the buyer’s account in your end-user portal: customerEmail is its contact address, not a user it is assigned to. To list it under the buyer’s My licenses, assign them on the entitlement’s Access tab (Assign user), or let them add it themselves with its license key under Add a license.

The first event for a subscription finds its entitlement one of two ways:

  • targetEntitlementId binds the subscription to an entitlement you already have — the one a customer upgraded from, say. Only an Active or Trialing subscription binds.
  • Without it, Oclavex provisions a new entitlement from the offer named in entitlementOfferKey, for customerEmail. Subscribe a webhook to Entitlement.SubscriptionAnchored to learn which entitlement that is: its data carries the entitlement’s id and your reference as subscriptionExternalReference. The offer must be Published. While it is Draft, Disabled or Archived, the event is still accepted with 202 but nothing is created. The event is not retried: a warning naming the subscription is added to the offer’s Audit log. Publish the offer, then send the event again. entitlementOfferKey is the offer’s name alone, such as pro-annual. Send its version, if you need one, in entitlementOfferVersion; pro-annual@1.0 is not a key. An event that names an offer that doesn’t exist is also accepted with 202 and creates nothing. It is not retried either: a warning on the tenant’s Audit log names the subscription and repeats this rule. Correct the name, then send the event again.

After that, each event updates the same entitlement. Active and Trialing keep it live, PastDue puts it on a payment hold, Paused pauses it, and Canceled ends it.

Every change an event makes shows in the entitlement’s Audit log under the API client that posted it, so you can tell your billing system’s changes from those of your team. The license your app receives for the entitlement names its model subscription, because your billing system decides when it ends. The policy object chooses what a failed payment and an ended subscription do, and whether plan changes are followed. The choices, and what they do, are the ones the Stripe connector offers under What Stripe events do. Leave policy out, or any field of it, for the defaults:

Field Default Meaning
pastDue PauseAfter A failed payment keeps the license working for pastDueGrace, then pauses it. Pause pauses at once; Keep never pauses.
pastDueGrace P7D Whole days as an ISO 8601 duration, from P1D to P90D, counted from observedAt, or from when the event arrives.
applyPlanOnUpdate true The event’s planName is applied on every event, not only the first. Set it to false and an entitlement that already has a plan stays on it, such as a plan you set by hand.
canceled Disable A cancellation disables the entitlement. ApplyPlan moves it to canceledPlanName; Lapse holds it on a locked variant of its plan.
requirePaidInvoice false Provision, and apply a plan, only once the latest invoice is paid.

While a payment hold runs, the entitlement’s status reads PastDue, in the grace period and after it, and under every setting of pastDue that holds, so your application can tell a failed payment from a pause you chose, which reads Paused. In the grace period the license keeps working. When the grace ends, the status stays PastDue, activations and renewals are refused, and an Entitlement.Paused webhook is sent. A later Active event ends the hold, and the license works again. An entitlement you have already paused by hand stays paused.

Two dates say when things happen. currentPeriodEndsAt is when the current billing period ends, so the next renewal: it is the renewal date the entitlement’s billing shows. endsAt is when the subscription itself ends. Leave it out while the subscription renews, and set it once a cancellation is scheduled. A currentPeriodEndsAt before startsAt is refused.

addOnCodes makes the event an add-on subscription. It grants those add-ons on targetEntitlementId and never changes the entitlement’s plan or status.

Send each change once, or say when it happened

Section titled “Send each change once, or say when it happened”

Your system may deliver a change twice, or late. Give every event sourceEventId, your id for the change, and observedAt, when your system saw that state. Oclavex then ignores:

  • a repeat of the last change it applied to the subscription;
  • a change your system saw before that one.

An event that arrives twice, a retry after a timeout, or an older change that arrives after a newer one changes nothing. Two changes stamped in the same second are both applied.

Let your billing system confirm a plan change

Section titled “Let your billing system confirm a plan change”

A customer can ask for another plan from your application. By default Oclavex holds that plan-change request until you approve it, and your billing system can do the approving, once it has charged for the new plan:

  1. The customer asks for the plan in your application. Oclavex records a pending request and sends an Entitlement.PlanChangeRequested webhook with requestedPlanCode and the entitlement’s routing keys, including the billing subscription’s reference.
  2. Your integration charges the customer in your billing system, and changes the subscription to the new plan.
  3. Your billing system posts subscription-changed for that subscription with the new plan in planName.
  4. Oclavex approves the pending request instead of applying the plan beside it. The request’s reviewer reads billing: followed by your scheme, such as billing:chargebee, and an Entitlement.PlanChangeReviewed webhook follows.

A posted plan that matches no pending request on that entitlement is applied directly, so a customer who upgrades in your billing system’s own portal has the new plan without a request. A request for another plan stays pending. An event that sets applyPlanOnUpdate to false approves nothing, and an entitlement that already has a plan stays on it. Posting the same event again changes nothing.

Terminal window
curl -X POST https://api.example.com/api/v1/provision/admin/billing-events/account-changed \
-H "authorization: Bearer $TOKEN" -H "content-type: application/json" \
-d '{
"externalReference": "chargebee:customer:16BQ4E1",
"changeType": "Updated",
"name": "Acme Corp",
"email": "billing@acme.example",
"legalName": "Acme Corporation B.V.",
"address": "Keizersgracht 1",
"postalCode": "1015 CC",
"city": "Amsterdam",
"country": "NL",
"vatNumber": "NL123456789B01",
"billingDetailsOnly": true
}'

The organization with the same reference is created, or updated. With billingDetailsOnly, your system owns only the invoice details: an existing organization keeps its name, contacts and licenses, the way it does for a Stripe customer, and no organization is created for a reference that none carries yet.

Terminal window
curl -X POST https://api.example.com/api/v1/provision/admin/billing-events/credit-purchase-completed \
-H "authorization: Bearer $TOKEN" -H "content-type: application/json" \
-d '{
"externalReference": "chargebee:invoice:2034",
"accountExternalReference": "chargebee:customer:16BQ4E1",
"entitlementId": "5f0c6c1e-9a41-4b7e-8d2a-2c1b7f0e9d11",
"metric": "api-calls",
"credits": 5000
}'

The credits land on the entitlement’s balance for metric, once per externalReference however often you post it. The entitlement needs a credit balance for that metric; without one the credits are not added.

Each endpoint answers 202 with the event’s id as soon as the event is accepted:

{ "eventId": "0f8e3c55-4f5a-4d8c-9e6d-3a4c2b1f7e90" }

The change is applied moments later. Read the entitlement to see it, or subscribe a webhook to the entitlement events. An event that can’t be applied is refused before anything happens, with a typed error:

Status Code When
400 license.validation_error A field can’t be used: a reference that isn’t scheme:kind:id, an unknown status, a negative quantity. The detail names each field.
403 license.billing_events_not_included Your plan doesn’t include billing events.
403 license.reserved_scheme A reference uses a scheme a built-in connector or billing mode owns: stripe while the environment has the Stripe connector registered, or sfdc, oclavex, manual, none or operator.
404 license.no_such_entitlement targetEntitlementId or entitlementId isn’t one of your entitlements, or names an offer or an archived entitlement.
409 license.billed_elsewhere Another provider bills the entitlement through a live subscription. It can take yours once that subscription is canceled.