Skip to navigation

Per-employee platform fee with workflow credits

Opsflow sells an AI service management platform: a help desk, workflow automation and access provisioning that IT buys first and that spreads into HR, legal and finance. Each customer pays a platform fee of $12 per employee per month, billed a year in advance, and buys prepaid credits at $0.15 each. Every workflow run burns credits at a rate set by how many billable steps the run took. This page follows Opsflow’s largest customer, Northwind Traders, from catalog setup to a month of usage.

This example uses:

The calls below show only the request body. Every request also sends the request headers: Authorization, the Paid-Version, and a Paid-Beta opt-in for each beta the endpoint is in (each endpoint page names its beta; this example uses products=v1, prices=v1, meters=v1, credits=v1, customers=v1, customer_units=v1, customer_aliases=v1, orders=v1, events=v1 and usage_summaries=v1). Writes also send an Idempotency-Key, so a retry is safe (see Idempotency).

Pricing

Credits are granted when the order activates and last 12 months, plus 3 months of rollover. A run burns credits by its billable steps:

Billable steps in the runCredits per run
00
11
2 to 32
4 to 105
11 to 10010
101 or more20

Prices in usd are in cents: unit amounts as decimal strings ("1200" is $12.00), flat amounts as integers. A price denominated in a credit currency is priced in that unit, here credits.

Setup

These calls run once, when Opsflow sets up its catalog.

Create a credit currency for credits. The conversion is what one credit costs once a customer’s balance runs out: 15 cents, the list price.

POST /v1/credit-currencies
{
"key": "opsflow_credits",
"name": "Opsflow credits",
"conversion": { "currency": "usd", "unitAmount": "15" }
}

Create a product for the platform:

POST /v1/products
{
"externalId": "opsflow_platform",
"name": "Opsflow platform"
}

The workflow run meter

A run is every step event that shares a run_id. It closes when Opsflow sends the workflow_run.completed signal, or after 7 days without one. Each step carries billable_steps: 1 for a step that does real work, 0 for polls and glue. The closed run’s quantity is the sum, so the run is priced on its billable steps only. Ingestion steps carry no workflow_id, so the filter leaves them out.

Create a meter that measures workflows:

POST /v1/meters
{
"key": "workflow_runs",
"name": "Workflow runs",
"eventNames": ["workflow_step_completed", "workflow_run.completed"],
"filters": [{ "path": "payload.workflow_id", "op": "exists" }],
"measure": {
"type": "workflows",
"workflows": {
"identifier": "payload.run_id",
"close": {
"eventName": "workflow_run.completed",
"timeout": { "value": "7", "unit": "day" },
"onTimeout": "close"
},
"catchAll": { "action": "emit", "key": "workflow_run" },
"derivedEvent": {
"quantity": {
"type": "sum",
"sum": { "path": "payload.billable_steps" },
"unit": "step"
}
}
}
}
}

Prices

Create a price for each charge. The platform fee is a recurring monthly price per employee:

POST /v1/prices
{
"product": "opsflow_platform",
"name": "Platform",
"currency": "usd",
"type": "recurring",
"recurring": {
"interval": "month",
"unit": "employee",
"pricing": { "type": "perUnit", "perUnit": { "unitAmount": "1200" } }
}
}

The credit bundle is a yearly price per credit that grants one credit for each unit of the order line’s quantity when the order activates. Credits expire after 12 months, and unused credits roll over for 3 more:

POST /v1/prices
{
"product": "opsflow_platform",
"name": "Opsflow credits",
"currency": "usd",
"type": "recurring",
"recurring": {
"interval": "year",
"unit": "credit",
"pricing": { "type": "perUnit", "perUnit": { "unitAmount": "15" } },
"grants": [
{
"creditCurrency": "opsflow_credits",
"amountPerUnit": "1",
"grantedOn": "activation",
"expiresAfter": { "value": "12", "unit": "month" },
"rollover": {
"maxAmount": null,
"duration": { "value": "3", "unit": "month" }
}
}
]
}
}

The burn rate is a usage price on the run meter, denominated in credits. With tierScope: "event", each closed run is banded on its own billable steps, and a volume tier with a flat amount charges the whole run once. The first tier makes a run with no billable steps free.

POST /v1/prices
{
"product": "opsflow_platform",
"name": "Workflow run burn",
"creditCurrency": "opsflow_credits",
"type": "usage",
"usage": {
"meter": "workflow_runs",
"pricing": {
"type": "volume",
"volume": {
"tierScope": "event",
"tiers": [
{ "upTo": "0", "unitAmount": "0", "flatAmount": 0 },
{ "upTo": "1", "unitAmount": "0", "flatAmount": 1 },
{ "upTo": "3", "unitAmount": "0", "flatAmount": 2 },
{ "upTo": "10", "unitAmount": "0", "flatAmount": 5 },
{ "upTo": "100", "unitAmount": "0", "flatAmount": 10 },
{ "upTo": null, "unitAmount": "0", "flatAmount": 20 }
]
}
}
}
}

The three prices come back as prc_platform, prc_credits and prc_burn; the rest of the page uses those IDs.

Signing Northwind Traders

Northwind Traders has a prod and a dev Opsflow org, each sending its own org ID, and departments that share one credit pool. Opsflow models it as one customer, a unit per org, a unit per department under prod, and an alias for each org ID.

Create the customer:

POST /v1/customers
{
"externalId": "northwind",
"name": "Northwind Traders",
"currency": "usd"
}

Create the customer units. A unit with no parent is the root:

POST /v1/customers/northwind/units
{
"externalId": "northwind",
"name": "Northwind Traders"
}

Then one unit per environment under the root:

POST /v1/customers/northwind/units
{
"externalId": "prod",
"parent": "northwind",
"name": "Production",
"kind": "environment"
}

The dev unit is the same with "externalId": "dev". Departments go under prod the same way ("parent": "prod", "kind": "department", with it, hr, legal, finance and so on as external IDs), so burn can be split by team.

Create an alias for each org ID Opsflow sends, routed to its environment:

POST /v1/customers/northwind/aliases
{
"value": "org_northwind_prod",
"customerUnit": "prod",
"source": "opsflow"
}

And org_northwind_dev routed to dev the same way.

The order

Create an order for the annual contract. The billing cycle is 12 months, so the monthly platform fee is invoiced once a year, in advance. Northwind Traders has 3,000 employees and buys 3,120,000 credits, about 70% of its forecast use:

POST /v1/orders
{
"customer": "northwind",
"externalId": "northwind-renewal-2026",
"startsAt": "2026-10-01T00:00:00Z",
"endsAt": "2027-10-01T00:00:00Z",
"billingCycle": { "interval": "month", "intervalCount": 12 },
"lines": [
{ "type": "price", "price": { "price": "prc_platform", "quantity": 3000 } },
{ "type": "price", "price": { "price": "prc_credits", "quantity": 3120000 } },
{ "type": "price", "price": { "price": "prc_burn" } }
]
}

Then activate it with POST /v1/orders/ord_123/activate, which takes no body. Activation grants 3,120,000 credits and issues the annual invoice:

LineAmount
Platform: 3,000 employees × $12.00 × 12 months$432,000.00
Opsflow credits: 3,120,000 × $0.15$468,000.00
Total$900,000.00

Sending usage

Opsflow sends an event for every step, under the org ID it already uses. The alias resolves org_northwind_prod to the prod unit, and customerUnit names the department when Opsflow knows it. That works because it sits under prod; naming dev there would be rejected.

POST /v1/events
{
"eventName": "workflow_step_completed",
"customer": "org_northwind_prod",
"customerUnit": "it",
"product": "opsflow_platform",
"dedupeKey": "step_8f2a91",
"payload": {
"run_id": "run_5521",
"workflow_id": "wf_access_request",
"ticket_id": "tkt_20931",
"billable_steps": 1
}
}

When the run finishes, Opsflow sends the signal that closes it:

POST /v1/events
{
"eventName": "workflow_run.completed",
"customer": "org_northwind_prod",
"customerUnit": "it",
"product": "opsflow_platform",
"dedupeKey": "run_5521:completed",
"payload": {
"run_id": "run_5521",
"workflow_id": "wf_access_request",
"status": "succeeded"
}
}

At volume, Opsflow sends steps through the batch endpoint, up to 1,000 events a request.

Take an access request that logged 1,507 steps, 19 of them billable. The run closes with a quantity of 19 steps, lands in the 11 to 100 band, and spends 10 credits. The spend’s ledger entry points at the run’s derived event, so every run has its own credit receipt.

A month of usage

Assume Northwind Traders runs 140,000 workflows in a month:

Billable stepsRunsCredits per runCredits
036,40000
128,000128,000
2 to 335,000270,000
4 to 1028,0005140,000
11 to 10011,90010119,000
101 or more7002014,000
Total140,000371,000
  • Balance after the month: 3,120,000 − 371,000 = 2,749,000 credits, 88.1% available. Nothing is invoiced: the runs draw on the prepaid grant.
  • Running low: at this rate the balance is 894,000 after month 6 and 523,000 after month 7, so a 20% alert (624,000 credits) fires during month 7, and the grant runs out during month 9.

What Opsflow shows its customers

Credit balances give the live balance, and credit transactions give the burn ledger, one spend per run with the derived event it came from:

GET /v1/credit-balances?customer=northwind&creditCurrency=opsflow_credits
GET /v1/credit-transactions?customer=northwind&creditCurrency=opsflow_credits&meter=workflow_runs&type=spend&limit=100

Usage summaries split burn by team and month:

GET /v1/usage-summaries?customer=northwind&meters=workflow_runs&startsAt=2026-10-01T00:00:00Z&endsAt=2027-10-01T00:00:00Z&granularity=month&groupBy=customerUnit

Changes during the term

Topping up credits

Opsflow sells 70% of forecast upfront and tops up when a customer runs low. A top-up is a one-time price that grants credits, created once:

POST /v1/prices
{
"product": "opsflow_platform",
"name": "Credit top-up",
"currency": "usd",
"type": "oneTime",
"oneTime": {
"unit": "credit",
"pricing": { "type": "perUnit", "perUnit": { "unitAmount": "15" } },
"grants": [{ "creditCurrency": "opsflow_credits", "amountPerUnit": "1" }]
}
}

After month 7, Northwind Traders has 523,000 credits left and needs 5 × 371,000 = 1,855,000 to finish the term. A top-up of 1,400,000 credits leaves 523,000 + 1,400,000 − 1,855,000 = 68,000 to spare. Preview the amendment that adds it as a line, invoiced straight away:

POST /v1/orders/ord_123/amendments/preview
{
"expectedVersion": 1,
"changes": [
{
"type": "addLine",
"addLine": {
"type": "price",
"price": { "price": "prc_topup", "quantity": 1400000 },
"invoice": "now"
}
}
]
}

Then create the amendment with the same changes and the previewToken the preview returned. It invoices 1,400,000 × $0.15 = $210,000.00 once and grants the credits. To do this automatically at a threshold, use a credit auto top-up.

A custom burn rate for one customer

To give Northwind Traders its own burn bands mid-term, create a second burn price the same way as prc_burn with the new tiers, then swap it onto the order’s burn line:

POST /v1/orders/ord_123/amendments/preview
{
"expectedVersion": 2,
"changes": [
{
"type": "replacePrice",
"replacePrice": { "line": "ordl_3", "price": "prc_burn_northwind" }
}
]
}

Create it with the returned previewToken, as above. Runs that close before the amendment spend at the old rate, and runs that close after it at the new one.