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',
timing: 'immediate'
plan: { key: 'pro' },
});
customerId
: The ID of the customer to which the subscription will be assigned.timing
: The timing of the subscription. Can beimmediate
for immediate activation or aDate
object 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',
timing: 'immediate'
customPlan: customPlan,
});
customPlan
: A custom plan object that defines the pricing and entitlements for the subscription. Its syntactically similar to aPlanCreate
object with thekey
field removed.