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"
    }
  ]
}
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

onlyPublished
boolean
Whether to include only published plan versions
onlyEnterprisePlan
boolean
Whether to include only enterprise plan versions
onlyLatest
boolean
Whether to include only the latest plan version
billingInterval
string
The billing interval to filter the plan versions
currency
string
The currency to filter the plan versions

Response

planVersions
array
required
Array of plan versions
planVersions[].id
string
required
The ID of the plan version
planVersions[].projectId
string
required
The ID of the project
planVersions[].createdAtM
number
required
The creation timestamp
planVersions[].updatedAtM
number
required
The last update timestamp
planVersions[].planId
string
required
The ID of the plan
planVersions[].description
string
required
The description of the plan version
planVersions[].latest
boolean
Whether this is the latest version
planVersions[].title
string
required
The title of the plan version
planVersions[].tags
array
Array of tags for the plan version
planVersions[].active
boolean
Whether the plan version is active
planVersions[].status
string
The status of the plan version
planVersions[].publishedAt
number
The publication timestamp
planVersions[].publishedBy
string
The ID of the user who published the plan version
planVersions[].archived
boolean
required
Whether the plan version is archived
planVersions[].archivedAt
number
The archive timestamp
planVersions[].archivedBy
string
The ID of the user who archived the plan version
planVersions[].paymentProvider
string
required
The payment provider for the plan version
planVersions[].dueBehaviour
string
required
The due behavior for the plan version
planVersions[].currency
string
required
The currency for the plan version
planVersions[].billingConfig
object
required
The billing configuration for the plan version
planVersions[].billingConfig.name
string
required
The name of the billing configuration
planVersions[].billingConfig.billingInterval
string
required
The billing interval
planVersions[].billingConfig.billingIntervalCount
number
required
The number of intervals
planVersions[].billingConfig.billingAnchor
number|string
required
The billing anchor (number or “dayOfCreation”)
planVersions[].billingConfig.planType
string
required
The type of plan
planVersions[].whenToBill
string
required
When to bill the customer
planVersions[].gracePeriod
number
required
The grace period in days
planVersions[].collectionMethod
string
required
The collection method
planVersions[].trialDays
number
required
The number of trial days
planVersions[].autoRenew
boolean
required
Whether the plan auto-renews
planVersions[].metadata
object
required
Additional metadata for the plan version
planVersions[].paymentMethodRequired
boolean
required
Whether a payment method is required
planVersions[].version
number
required
The version number
planVersions[].plan
object
required
The plan information
planVersions[].plan.id
string
required
The ID of the plan
planVersions[].plan.projectId
string
required
The ID of the project
planVersions[].plan.createdAtM
number
required
The creation timestamp
planVersions[].plan.updatedAtM
number
required
The last update timestamp
planVersions[].plan.slug
string
required
The slug of the plan
planVersions[].plan.active
boolean
Whether the plan is active
planVersions[].plan.description
string
required
The description of the plan
planVersions[].plan.metadata
object
Additional metadata for the plan
planVersions[].plan.metadata.externalId
string
The external ID of the plan
planVersions[].plan.defaultPlan
boolean
Whether this is the default plan
planVersions[].plan.enterprisePlan
boolean
Whether this is an enterprise plan
planVersions[].planFeatures
array
required
Array of plan features
planVersions[].planFeatures[].id
string
required
The ID of the plan feature
planVersions[].planFeatures[].projectId
string
required
The ID of the project
planVersions[].planFeatures[].createdAtM
number
required
The creation timestamp
planVersions[].planFeatures[].updatedAtM
number
required
The last update timestamp
planVersions[].planFeatures[].planVersionId
string
required
The ID of the plan version
planVersions[].planFeatures[].featureId
string
required
The ID of the feature
planVersions[].planFeatures[].featureType
string
required
The type of feature
planVersions[].planFeatures[].config
object
required
The configuration for the feature
planVersions[].planFeatures[].metadata
object
required
Additional metadata for the feature
planVersions[].planFeatures[].aggregationMethod
string
required
The aggregation method for the feature
planVersions[].planFeatures[].order
number
required
The order of the feature
planVersions[].planFeatures[].hidden
boolean
required
Whether the feature is hidden
planVersions[].planFeatures[].feature
object
required
The feature information
planVersions[].planFeatures[].feature.id
string
required
The ID of the feature
planVersions[].planFeatures[].feature.projectId
string
required
The ID of the project
planVersions[].planFeatures[].feature.createdAtM
number
required
The creation timestamp
planVersions[].planFeatures[].feature.updatedAtM
number
required
The last update timestamp
planVersions[].planFeatures[].feature.slug
string
required
The slug of the feature
planVersions[].planFeatures[].feature.code
string
required
The code of the feature
planVersions[].planFeatures[].feature.title
string
required
The title of the feature
planVersions[].planFeatures[].feature.description
string
required
The description of the feature
planVersions[].flatPrice
string
required
The flat price of the plan version