> This page is for version Preview (default).
> For other versions, use one of these documentation indexes:
> - Preview (default): https://docs.preview.paid.ai/preview/llms.txt
> - Current: https://docs.preview.paid.ai/current/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.preview.paid.ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.preview.paid.ai/_mcp/server.

# Per-employee platform fee with workflow credits

> Bill an annual per-employee platform fee in advance, grant prepaid credits, and burn them per workflow run at a rate set by the run's billable steps.

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:

* [Credit currencies](../../api-reference/catalog/credit-currencies/create), for Opsflow credits
* [Products](../../api-reference/catalog/products/create) and [prices](../../api-reference/catalog/prices/create), for the platform fee, the credit bundle and the burn rate
* [Meters](../../api-reference/metering/meters/create), to turn step events into one measured run
* [Customers](../../api-reference/customers/customers/create), [customer units](../../api-reference/customers/customer-units/create) and [customer aliases](../../api-reference/customers/customer-aliases/create), for one customer with a prod and a dev org
* [Orders](../../api-reference/billing/orders/create) and [amendments](../../api-reference/billing/amendments/create), for the annual contract and changes during it
* [Events](../../api-reference/metering/events/create), for each workflow step
* [Credit balances](../../api-reference/credits/credit-balances/list), [credit transactions](../../api-reference/credits/credit-transactions/list) and [usage summaries](../../api-reference/metering/usage-summaries/list), for what Opsflow shows its customers

> **Note**
>
> The calls below show only the request body. Every request also sends the [request headers](../../api-reference/introduction#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](../../api-reference/idempotency)).

## Pricing \[#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 run | Credits per run |
| ------------------------- | --------------- |
| 0                         | 0               |
| 1                         | 1               |
| 2 to 3                    | 2               |
| 4 to 10                   | 5               |
| 11 to 100                 | 10              |
| 101 or more               | 20              |

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 \[#setup]

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

[Create a credit currency](../../api-reference/catalog/credit-currencies/create) 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`**

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

[Create a product](../../api-reference/catalog/products/create) for the platform:

**`POST /v1/products`**

```json title="POST /v1/products"
{
  "externalId": "opsflow_platform",
  "name": "Opsflow platform"
}
```

### The workflow run meter \[#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](../../api-reference/metering/meters/create) that measures workflows:

**`POST /v1/meters`**

```json title="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 \[#prices]

[Create a price](../../api-reference/catalog/prices/create) for each charge. The platform fee is a recurring monthly price per employee:

**`POST /v1/prices`**

```json title="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`**

```json title="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`**

```json title="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 \[#signing-a-customer]

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](../../api-reference/customers/customers/create):

**`POST /v1/customers`**

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

[Create the customer units](../../api-reference/customers/customer-units/create). A unit with no parent is the root:

**`POST /v1/customers/northwind/units`**

```json title="POST /v1/customers/northwind/units"
{
  "externalId": "northwind",
  "name": "Northwind Traders"
}
```

Then one unit per environment under the root:

**`POST /v1/customers/northwind/units`**

```json title="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](../../api-reference/customers/customer-aliases/create) for each org ID Opsflow sends, routed to its environment:

**`POST /v1/customers/northwind/aliases`**

```json title="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 \[#order]

[Create an order](../../api-reference/billing/orders/create) 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`**

```json title="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](../../api-reference/billing/orders/activate) with `POST /v1/orders/ord_123/activate`, which takes no body. Activation grants 3,120,000 credits and issues the annual invoice:

| Line                                            | Amount           |
| ----------------------------------------------- | ---------------- |
| 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 \[#sending-usage]

Opsflow [sends an event](../../api-reference/metering/events/create) 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`**

```json title="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`**

```json title="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](../../api-reference/metering/events/create-batch), 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 \[#month-of-usage]

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

| Billable steps | Runs        | Credits per run | Credits     |
| -------------- | ----------- | --------------- | ----------- |
| 0              | 36,400      | 0               | 0           |
| 1              | 28,000      | 1               | 28,000      |
| 2 to 3         | 35,000      | 2               | 70,000      |
| 4 to 10        | 28,000      | 5               | 140,000     |
| 11 to 100      | 11,900      | 10              | 119,000     |
| 101 or more    | 700         | 20              | 14,000      |
| **Total**      | **140,000** |                 | **371,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 \[#what-customers-see]

[Credit balances](../../api-reference/credits/credit-balances/list) give the live balance, and [credit transactions](../../api-reference/credits/credit-transactions/list) give the burn ledger, one spend per run with the derived event it came from:

```bash
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](../../api-reference/metering/usage-summaries/list) split burn by team and month:

```bash
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 \[#changes-during-the-term]

### Topping up credits \[#topping-up]

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`**

```json title="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](../../api-reference/billing/amendments/preview) that adds it as a line, invoiced straight away:

**`POST /v1/orders/ord_123/amendments/preview`**

```json title="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](../../api-reference/billing/amendments/create) 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](../../api-reference/credits/credit-auto-top-ups/create).

### A custom burn rate for one customer \[#custom-burn-rate]

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`**

```json title="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.