const { result, error } = await unprice.plans.listPlanVersions({
onlyPublished: true,
onlyEnterprisePlan: false,
onlyLatest: true,
billingInterval: "month",
currency: "USD"
});
if (error) {
// handle potential network or bad request error
// a link to our docs will be in the `error.docs` field
console.error(error.message);
return;
}
console.log(result);
{
"planVersions": [
{
"id": "pv_1234567890",
"projectId": "project_1234567890",
"createdAtM": 1678900000,
"updatedAtM": 1678900000,
"planId": "plan_1234567890",
"description": "Description of the plan version",
"latest": true,
"title": "Plan Version Title",
"tags": ["tag1", "tag2"],
"active": true,
"status": "published",
"publishedAt": 1678900000,
"publishedBy": "user_1234567890",
"archived": false,
"archivedAt": null,
"archivedBy": null,
"paymentProvider": "stripe",
"dueBehaviour": "immediate",
"currency": "USD",
"billingConfig": {
"name": "Monthly",
"billingInterval": "month",
"billingIntervalCount": 1,
"billingAnchor": "dayOfCreation",
"planType": "recurring"
},
"whenToBill": "start",
"gracePeriod": 0,
"collectionMethod": "charge_automatically",
"trialDays": 0,
"autoRenew": true,
"metadata": {},
"paymentMethodRequired": true,
"version": 1,
"plan": {
"id": "plan_1234567890",
"projectId": "project_1234567890",
"createdAtM": 1678900000,
"updatedAtM": 1678900000,
"slug": "plan-slug",
"active": true,
"description": "Description of the plan",
"metadata": {
"externalId": "ext_123"
},
"defaultPlan": false,
"enterprisePlan": false
},
"planFeatures": [
{
"id": "pf_1234567890",
"projectId": "project_1234567890",
"createdAtM": 1678900000,
"updatedAtM": 1678900000,
"planVersionId": "pv_1234567890",
"featureId": "feat_1234567890",
"featureType": "usage",
"config": {},
"metadata": {},
"aggregationMethod": "sum",
"order": 1,
"hidden": false,
"feature": {
"id": "feat_1234567890",
"projectId": "project_1234567890",
"createdAtM": 1678900000,
"updatedAtM": 1678900000,
"slug": "feature-slug",
"code": "FEATURE_CODE",
"title": "Feature Title",
"description": "Feature Description"
}
}
],
"flatPrice": "10.00"
}
]
}
Request
Whether to include only published plan versions
Whether to include only enterprise plan versions
Whether to include only the latest plan version
The billing interval to filter the plan versions
The currency to filter the plan versions
Response
The ID of the plan version
planVersions[].createdAtM
The creation timestamp
planVersions[].updatedAtM
The last update timestamp
planVersions[].description
The description of the plan version
Whether this is the latest version
The title of the plan version
Array of tags for the plan version
Whether the plan version is active
The status of the plan version
planVersions[].publishedAt
The publication timestamp
planVersions[].publishedBy
The ID of the user who published the plan version
Whether the plan version is archived
planVersions[].archivedAt
The archive timestamp
planVersions[].archivedBy
The ID of the user who archived the plan version
planVersions[].paymentProvider
The payment provider for the plan version
planVersions[].dueBehaviour
The due behavior for the plan version
The currency for the plan version
planVersions[].billingConfig
The billing configuration for the plan version
planVersions[].billingConfig.name
The name of the billing configuration
planVersions[].billingConfig.billingInterval
The billing interval
planVersions[].billingConfig.billingIntervalCount
The number of intervals
planVersions[].billingConfig.billingAnchor
The billing anchor (number or “dayOfCreation”)
planVersions[].billingConfig.planType
The type of plan
planVersions[].whenToBill
When to bill the customer
planVersions[].gracePeriod
The grace period in days
planVersions[].collectionMethod
The collection method
Whether the plan auto-renews
Additional metadata for the plan version
planVersions[].paymentMethodRequired
Whether a payment method is required
planVersions[].plan.projectId
The ID of the project
planVersions[].plan.createdAtM
The creation timestamp
planVersions[].plan.updatedAtM
The last update timestamp
planVersions[].plan.active
Whether the plan is active
planVersions[].plan.description
The description of the plan
planVersions[].plan.metadata
Additional metadata for the plan
planVersions[].plan.metadata.externalId
The external ID of the plan
planVersions[].plan.defaultPlan
Whether this is the default plan
planVersions[].plan.enterprisePlan
Whether this is an enterprise plan
planVersions[].planFeatures
Array of plan features
planVersions[].planFeatures[].id
The ID of the plan feature
planVersions[].planFeatures[].projectId
The ID of the project
planVersions[].planFeatures[].createdAtM
The creation timestamp
planVersions[].planFeatures[].updatedAtM
The last update timestamp
planVersions[].planFeatures[].planVersionId
The ID of the plan version
planVersions[].planFeatures[].featureId
The ID of the feature
planVersions[].planFeatures[].featureType
The type of feature
planVersions[].planFeatures[].config
The configuration for the feature
planVersions[].planFeatures[].metadata
Additional metadata for the feature
planVersions[].planFeatures[].aggregationMethod
The aggregation method for the feature
planVersions[].planFeatures[].order
The order of the feature
planVersions[].planFeatures[].hidden
Whether the feature is hidden
planVersions[].planFeatures[].feature
The feature information
planVersions[].planFeatures[].feature.id
The ID of the feature
planVersions[].planFeatures[].feature.projectId
The ID of the project
planVersions[].planFeatures[].feature.createdAtM
The creation timestamp
planVersions[].planFeatures[].feature.updatedAtM
The last update timestamp
planVersions[].planFeatures[].feature.slug
The slug of the feature
planVersions[].planFeatures[].feature.code
The code of the feature
planVersions[].planFeatures[].feature.title
The title of the feature
planVersions[].planFeatures[].feature.description
The description of the feature
The flat price of the plan version