Skip to content

Commit d73b528

Browse files
authored
docs(migration): subject customer consolidation (#3211)
1 parent 7b0118a commit d73b528

File tree

1 file changed

+193
-0
lines changed

1 file changed

+193
-0
lines changed
Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
# Subject-Customer Consolidation
2+
3+
OpenMeter has always separated usage owners (subjects) from billing
4+
entities (customers). This design stays, but now you can assign multiple
5+
subjects to a customer.
6+
7+
To reduce complexity, usage sent with a Customer ID or Key is now
8+
automatically mapped to that customer.
9+
10+
We are also unifying subjects and customers for entitlements and
11+
notifications, making customer APIs the primary interface.
12+
13+
## 🔄 What's Changing
14+
15+
### 🔗 1. Consolidating Subject and Customer Entities
16+
17+
Customers now replace subjects as the primary entity. Mapping subjects
18+
to customers is optional and does not affect the ingest API or the
19+
`subject` field in usage events.
20+
21+
If the subject is a Customer ID or Key, OpenMeter automatically
22+
attributes usage to that customer. Custom subjects can still be created
23+
and linked to customers when needed.
24+
25+
→ Use customer entities instead of subjects.
26+
27+
> [!NOTE]
28+
> Ensure your custom subject values do not collide with any existing `customer.key`
29+
> or `customer.id`. If a collision occurs, usage may be attributed to the wrong customer.
30+
31+
#### Before
32+
33+
Mandatory subject-customer mapping via `usageAttribution` property before the change.
34+
35+
```ts
36+
const customer = await openmeter.customers.create({
37+
name: 'ACME, Inc.',
38+
key: 'my-identifier',
39+
usageAttribution: { subjects: ['my-identifier'] },
40+
});
41+
42+
await openmeter.events.ingest({
43+
type: 'prompt',
44+
// customer.usageAttribution.subjects
45+
subject: 'my-identifier',
46+
data: { tokens: 10 },
47+
});
48+
```
49+
50+
#### After
51+
52+
Optional definition of `usageAttribution` property on customer and
53+
automatic usage attribution when usage event uses Customer ID or Key.
54+
55+
```ts
56+
const customer = await openmeter.customers.create({
57+
name: 'ACME, Inc.',
58+
key: 'my-identifier',
59+
// optional: usageAttribution
60+
});
61+
62+
await openmeter.events.ingest({
63+
type: 'prompt',
64+
// customer.id, customer.key, or usageAttribution.subjects
65+
subject: 'my-identifier',
66+
data: { tokens: 10 },
67+
});
68+
```
69+
70+
### ➡️ 2. Deprecating Subject Entity APIs
71+
72+
All endpoints starting with `/api/v*/subjects...` will be deprecated
73+
after the migration period.
74+
75+
→ Use customer APIs instead: entitlements and notification
76+
77+
#### Before (subject-level)
78+
79+
```ts
80+
const entitlement = await openmeter.subjects.createEntitlement('my-identifier', { … });
81+
```
82+
83+
#### After (customer-level)
84+
85+
```ts
86+
const entitlement = await openmeter.customers.createEntitlement('my-identifier', { … });
87+
```
88+
89+
### ✏️ 3. Defining subjects on a customer becomes optional
90+
91+
The `usageAttribution` field on customers is now optional to set.
92+
93+
→ OpenMeter will automatically attribute usage by customer ID or Key.
94+
95+
### 👥 4. Assigning multiple subjects to a customer
96+
97+
You can now assign multiple subjects to a single customer. This is
98+
useful when multiple consumers need to be billed together.
99+
100+
```ts
101+
const customer = await openmeter.customers.create({
102+
name: 'ACME, Inc.',
103+
key: 'my-identifier',
104+
usageAttribution: {
105+
subjects: [
106+
'my-subject-1',
107+
'my-subject-2',
108+
'my-subject-3'
109+
]
110+
},
111+
});
112+
```
113+
114+
## 🗓 Deprecation Timeline
115+
116+
| Date | Change |
117+
|--------------------|----------------------------------------------------------------|
118+
| September 01, 2025 | Subject APIs marked as deprecated, functionality unchanged |
119+
| November 01, 2025 | Subject APIs removed entirely |
120+
121+
## Migration Guide
122+
123+
Who should act? Anyone calling /subjects APIs or relying on subject-level entitlements/notifications.
124+
125+
- **1. Switch to customer APIs**
126+
- Find all calls to `/api/v*/subjects*.`
127+
- Entitlements → Use customer APIs
128+
- Notifications → Use customer field in events
129+
- **2. Decide your attribution strategy**
130+
- Easiest: Start sending `subject = customer.key` (`or customer.id`) in new events.
131+
- Custom subjects: Keep your own subject strings and add them to `customer.usageAttribution.subjects`.
132+
133+
## Frequently Asked Questions
134+
135+
### What is a subject?
136+
137+
A subject is any entity that generates metered usage in OpenMeter — for
138+
example, a customer, user, server, service, or device. Subjects exist
139+
only in the context of usage events and metering, representing the
140+
consumers of your service.
141+
142+
### What is a customer?
143+
144+
A customer is the individual or organization that uses your service and
145+
is billed for the usage. One customer can have one or more subjects
146+
assigned to it to track usage for these consumers and bill them together.
147+
148+
### Will my existing integrations break after the migration?
149+
150+
No. Existing subject-based APIs will continue to work until the
151+
final deprecation date. However, we recommend updating to customer APIs
152+
as soon as possible.
153+
154+
### Will you create customers for my subjects automatically?
155+
156+
Yes. All subjects not assigned to customers will be turned into
157+
customers on OpenMeter Cloud. These customers remain in sync with
158+
the subjects they were created from.
159+
160+
### Can I assign multiple subjects to the same customer?
161+
162+
Yes, this is now supported natively. You can assign multiple subjects to a
163+
single customer via the `usageAttribution` API property.
164+
165+
### Can I assign the same subject to multiple customers?
166+
167+
No, like before one subject can only belong to a single customer.
168+
169+
### Can I still assign subjects to customers later?
170+
171+
Yes. You can still ingest usage with unassigned subjects, and later link
172+
them to customers. You can now assign multiple subjects to customers too.
173+
174+
### Can I mix customer IDs and subject IDs in ingestion?
175+
176+
Yes. You can use Customer ID, Customer Key or manually assigned
177+
subjects as the `subject` field in the usage event.
178+
179+
### Can I have customer-level entitlements?
180+
181+
Yes. This change introduces customer-level entitlements, which combine
182+
usage from all subjects assigned to a customer when calculating
183+
balances.
184+
185+
### Can I still create subject-level entitlements?
186+
187+
For now, yes. But subject level entitlements APIs will eventually be deprecated.
188+
In the future, use customer-level entitlements, with single or multiple subjects as needed.
189+
190+
### Can I revert back to using subjects APIs only?
191+
192+
No. After the final removal date, the subject APIs
193+
like subject-level entitlements will no longer be available.

0 commit comments

Comments
 (0)