Get Started
Create Your First Subscription
You can start a subscription using by assining a plan to a customer or by creating a custom subscription. For the exmples below, we'll use the OpenMeter TypeScript SDK.
Note
For more details on using the TypesScript SDK check our docs.
Example: Create a subscription from a plan
const subscription = await openmeter.subscriptions.create({
customerId: 'customer-id',
plan: { key: 'pro' },
});customerId: The ID of the customer to which the subscription will be assigned.timing: The timing of the subscription. Can beimmediatefor immediate activation or aDateobject for a future activation.plan: The plan to be assigned to the subscription. The latest published version if the plan will be used.
Example: Create a custom subscription
const customPlan: CustomPlanInput = {
name: 'Custom Subscription',
currency: 'USD',
phases: [
// ...phases and rate cards
],
};
const subscription = await openmeter.subscriptions.create({
customerId: 'customer-id', // or customerKey
customPlan: customPlan,
});customPlan: A custom plan object that defines the pricing and entitlements for the subscription. Its syntactically similar to aPlanCreateobject with thekeyfield removed.
Last updated on