> ## Documentation Index
> Fetch the complete documentation index at: https://docs.unprice.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Get plan version

> Get a plan version by id

<RequestExample>
  ```ts theme={null}
  const { result, error } = await unprice.planVersions.get({
    planVersionId: "pv_1234567890"
  });

  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);
  ```
</RequestExample>

<ResponseExample>
  ```json theme={null}
  {
    "planVersion": {
      "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": {},
          "meterConfig": {
            "eventId": "event_1234567890",
            "eventSlug": "completions",
            "aggregationMethod": "sum",
            "aggregationField": "aiMessages"
          },
          "order": 1,
          "hidden": false,
          "displayFeatureText": "Feature description text",
          "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"
    }
  }
  ```
</ResponseExample>

## Request

<ParamField path="planVersionId" type="string" required>
  The ID of the plan version to retrieve
</ParamField>

## Response

<ResponseField name="planVersion" type="object" required>
  The plan version information
</ResponseField>

<ResponseField name="planVersion.id" type="string" required>
  The ID of the plan version
</ResponseField>

<ResponseField name="planVersion.projectId" type="string" required>
  The ID of the project
</ResponseField>

<ResponseField name="planVersion.createdAtM" type="number" required>
  The creation timestamp
</ResponseField>

<ResponseField name="planVersion.updatedAtM" type="number" required>
  The last update timestamp
</ResponseField>

<ResponseField name="planVersion.planId" type="string" required>
  The ID of the plan
</ResponseField>

<ResponseField name="planVersion.description" type="string" required>
  The description of the plan version
</ResponseField>

<ResponseField name="planVersion.latest" type="boolean">
  Whether this is the latest version
</ResponseField>

<ResponseField name="planVersion.title" type="string" required>
  The title of the plan version
</ResponseField>

<ResponseField name="planVersion.tags" type="array">
  Array of tags for the plan version
</ResponseField>

<ResponseField name="planVersion.active" type="boolean">
  Whether the plan version is active
</ResponseField>

<ResponseField name="planVersion.status" type="string" enum="draft,published">
  The status of the plan version
</ResponseField>

<ResponseField name="planVersion.publishedAt" type="number">
  The publication timestamp
</ResponseField>

<ResponseField name="planVersion.publishedBy" type="string">
  The ID of the user who published the plan version
</ResponseField>

<ResponseField name="planVersion.archived" type="boolean" required>
  Whether the plan version is archived
</ResponseField>

<ResponseField name="planVersion.archivedAt" type="number">
  The archive timestamp
</ResponseField>

<ResponseField name="planVersion.archivedBy" type="string">
  The ID of the user who archived the plan version
</ResponseField>

<ResponseField name="planVersion.paymentProvider" type="string" required>
  The payment provider for the plan version
</ResponseField>

<ResponseField name="planVersion.dueBehaviour" type="string" required>
  The due behavior for the plan version
</ResponseField>

<ResponseField name="planVersion.currency" type="string" required>
  The currency for the plan version
</ResponseField>

<ResponseField name="planVersion.billingConfig" type="object" required>
  The billing configuration for the plan version
</ResponseField>

<ResponseField name="planVersion.billingConfig.name" type="string" required>
  The name of the billing configuration
</ResponseField>

<ResponseField name="planVersion.billingConfig.billingInterval" type="string" enum="month,year,day,minute,onetime" required>
  The billing interval
</ResponseField>

<ResponseField name="planVersion.billingConfig.billingIntervalCount" type="number" required>
  The number of intervals
</ResponseField>

<ResponseField name="planVersion.billingConfig.billingAnchor" type="number|string" required>
  The billing anchor (number or "dayOfCreation")
</ResponseField>

<ResponseField name="planVersion.billingConfig.planType" type="string" enum="recurring,onetime" required>
  The type of plan
</ResponseField>

<ResponseField name="planVersion.whenToBill" type="string" required>
  When to bill the customer
</ResponseField>

<ResponseField name="planVersion.gracePeriod" type="number" required>
  The grace period in days
</ResponseField>

<ResponseField name="planVersion.collectionMethod" type="string" required>
  The collection method
</ResponseField>

<ResponseField name="planVersion.trialDays" type="number" required>
  The number of trial days
</ResponseField>

<ResponseField name="planVersion.autoRenew" type="boolean" required>
  Whether the plan auto-renews
</ResponseField>

<ResponseField name="planVersion.metadata" type="object" required>
  Additional metadata for the plan version
</ResponseField>

<ResponseField name="planVersion.paymentMethodRequired" type="boolean" required>
  Whether a payment method is required
</ResponseField>

<ResponseField name="planVersion.version" type="number" required>
  The version number
</ResponseField>

<ResponseField name="planVersion.plan" type="object" required>
  The plan information
</ResponseField>

<ResponseField name="planVersion.plan.id" type="string" required>
  The ID of the plan
</ResponseField>

<ResponseField name="planVersion.plan.projectId" type="string" required>
  The ID of the project
</ResponseField>

<ResponseField name="planVersion.plan.createdAtM" type="number" required>
  The creation timestamp
</ResponseField>

<ResponseField name="planVersion.plan.updatedAtM" type="number" required>
  The last update timestamp
</ResponseField>

<ResponseField name="planVersion.plan.slug" type="string" required>
  The slug of the plan
</ResponseField>

<ResponseField name="planVersion.plan.active" type="boolean">
  Whether the plan is active
</ResponseField>

<ResponseField name="planVersion.plan.description" type="string" required>
  The description of the plan
</ResponseField>

<ResponseField name="planVersion.plan.metadata" type="object">
  Additional metadata for the plan
</ResponseField>

<ResponseField name="planVersion.plan.metadata.externalId" type="string">
  The external ID of the plan
</ResponseField>

<ResponseField name="planVersion.plan.defaultPlan" type="boolean">
  Whether this is the default plan
</ResponseField>

<ResponseField name="planVersion.plan.enterprisePlan" type="boolean">
  Whether this is an enterprise plan
</ResponseField>

<ResponseField name="planVersion.planFeatures" type="array" required>
  Array of plan features
</ResponseField>

<ResponseField name="planVersion.planFeatures[].id" type="string" required>
  The ID of the plan feature
</ResponseField>

<ResponseField name="planVersion.planFeatures[].projectId" type="string" required>
  The ID of the project
</ResponseField>

<ResponseField name="planVersion.planFeatures[].createdAtM" type="number" required>
  The creation timestamp
</ResponseField>

<ResponseField name="planVersion.planFeatures[].updatedAtM" type="number" required>
  The last update timestamp
</ResponseField>

<ResponseField name="planVersion.planFeatures[].planVersionId" type="string" required>
  The ID of the plan version
</ResponseField>

<ResponseField name="planVersion.planFeatures[].featureId" type="string" required>
  The ID of the feature
</ResponseField>

<ResponseField name="planVersion.planFeatures[].featureType" type="string" enum="flat,tier,package,usage" required>
  The type of feature
</ResponseField>

<ResponseField name="planVersion.planFeatures[].config" type="object" required>
  The configuration for the feature
</ResponseField>

<ResponseField name="planVersion.planFeatures[].metadata" type="object" required>
  Additional metadata for the feature
</ResponseField>

<ResponseField name="planVersion.planFeatures[].meterConfig" type="object">
  Snapshotted meter configuration for usage features
</ResponseField>

<ResponseField name="planVersion.planFeatures[].meterConfig.eventId" type="string">
  The reusable project event linked to this meter snapshot
</ResponseField>

<ResponseField name="planVersion.planFeatures[].meterConfig.eventSlug" type="string">
  The immutable SDK event slug snapshotted into this plan version feature
</ResponseField>

<ResponseField name="planVersion.planFeatures[].meterConfig.aggregationMethod" type="string">
  The aggregation method used to measure usage for this feature
</ResponseField>

<ResponseField name="planVersion.planFeatures[].meterConfig.aggregationField" type="string">
  The numeric event payload property used when the aggregation method requires one
</ResponseField>

<ResponseField name="planVersion.planFeatures[].order" type="number" required>
  The order of the feature
</ResponseField>

<ResponseField name="planVersion.planFeatures[].hidden" type="boolean" required>
  Whether the feature is hidden
</ResponseField>

<ResponseField name="planVersion.planFeatures[].displayFeatureText" type="string" required>
  The text you can use to show the clients
</ResponseField>

<ResponseField name="planVersion.planFeatures[].feature" type="object" required>
  The feature information
</ResponseField>

<ResponseField name="planVersion.planFeatures[].feature.id" type="string" required>
  The ID of the feature
</ResponseField>

<ResponseField name="planVersion.planFeatures[].feature.projectId" type="string" required>
  The ID of the project
</ResponseField>

<ResponseField name="planVersion.planFeatures[].feature.createdAtM" type="number" required>
  The creation timestamp
</ResponseField>

<ResponseField name="planVersion.planFeatures[].feature.updatedAtM" type="number" required>
  The last update timestamp
</ResponseField>

<ResponseField name="planVersion.planFeatures[].feature.slug" type="string" required>
  The slug of the feature
</ResponseField>

<ResponseField name="planVersion.planFeatures[].feature.code" type="string" required>
  The code of the feature
</ResponseField>

<ResponseField name="planVersion.planFeatures[].feature.title" type="string" required>
  The title of the feature
</ResponseField>

<ResponseField name="planVersion.planFeatures[].feature.description" type="string" required>
  The description of the feature
</ResponseField>

<ResponseField name="planVersion.flatPrice" type="string" required>
  The flat price of the plan version
</ResponseField>
