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

# Mint a plan version

> Mint a new plan version from a price diff and make it the version the plan bills from, in one step. The diff references existing prices by id: create prices beforehand with POST /prices, then add, remove, or replace them here. To return to an earlier price set, make that version the default with a PATCH on the version.



## OpenAPI

````yaml /openapi.json post /v0/plans/{id}/versions
openapi: 3.1.0
info:
  title: Paygentic API
  version: 0.1.0
  description: >
    The Paygentic API provides a comprehensive platform for building and scaling
    monetization infrastructure.


    ## Authentication

    All API requests require authentication using an API key passed in the
    `Authorization` header:

    ```

    Authorization: Bearer YOUR_API_KEY

    ```


    ## Base URL

    All API requests should be made to:

    ```

    https://api.paygentic.io/v0

    ```
  contact:
    name: Paygentic Support
    email: support@paygentic.io
  license:
    name: Proprietary
servers:
  - url: https://api.paygentic.io
    description: Production API
  - url: https://api.sandbox.paygentic.io
    description: Sandbox API
security:
  - BearerAuth: []
tags:
  - name: Customers
    description: >-
      A `Customer` is an entity connected to a `Merchant` via a `Subscription`.
      This represents the merchant-facing perspective of `Consumers` who
      purchase their `Products`.
  - name: Billable Metrics
    description: >-
      A `Billable Metric` defines a measurable quantity tied to a `Product`'s
      consumption. Each metric stores details including its label, an
      explanatory description, and measurement units.
  - name: Grants
    description: >-
      Grants credit a customer's metered entitlement balance. Merchants can
      create grants directly or void existing ones.


      Use `GET /v1/entitlements?customerId={id}` or `GET
      /v1/entitlements?subscriptionId={id}` to find the metered entitlement `id`
      needed for these endpoints.
  - name: Features
    description: >-
      A `Feature` represents a specific capability or functionality provided by
      a `Product`. Features can be metered (usage-based), static (fixed
      allocation), or boolean (enabled/disabled).
  - name: Fees
    description: >-
      A `Fee` defines a recurring or one-time charge tied to a `Product`. Fees
      are linked to prices, and cadence is defined on the Price.
  - name: Plans
    description: >-
      A `Plan` links a collection of `Prices` to a `Product`. It functions as a
      pricing structure document for a particular feature set or service
      offering.
  - name: Prices
    description: >-
      A `Price` determines the monetary value for a single unit of a `Billable
      Metric`. Prices are exclusively grouped within a `Plan`.
  - name: Products
    description: >-
      A `Product` is an offering sold by a `Merchant`. It includes product
      metadata like title, summary, and pricing details. `Plans`, `Prices`, and
      `Subscriptions` are all associated with products.
  - name: Sources
    description: >-
      A `Source` is an external data provider capable of automatically creating
      usage events. Configuration occurs at the plan level, enabling data
      retrieval from third-party platforms such as Stripe to produce billable
      events.
  - name: Subscriptions
    description: >-
      A `Subscription` is a customer's commitment to purchase a `Product`
      following the terms of a `Plan` and its linked `Prices`.
  - name: Users
    description: >-
      A `User` is an entity granted access to an Organization's resources. All
      operations are performed by users.
  - name: Invoices V2
    description: >-
      Invoice V2 operations supporting billing cycles organized by time periods.
      Warning: v0 invoice endpoints are no longer supported.
  - name: Revenue
    description: Revenue data from invoices and payments
  - name: Profitability
    description: Per-customer profitability summaries
  - name: Test Clocks
    description: >-
      Test clocks provide programmable time control to simulate subscription and
      billing scenarios during testing.
  - name: Events
    description: Ingest raw metering events that are processed by the meters service.
  - name: Payments
    description: >-
      Create and manage one-off payments. A payment represents a single charge
      that a merchant wants to collect from a customer.
  - name: Payment Sessions
    description: >-
      Handle payment session lifecycle and processing across various entity
      types including invoices and subscriptions
  - name: Costs
    description: >-
      A Cost represents the operational or infrastructure expense of serving
      customers for a given product. Costs are metered (driven by event-based
      usage) and are tracked in parallel with billable metrics to give merchants
      visibility into both revenue and cost per customer.
  - name: ExternalReferences
    description: >-
      An `ExternalReference` links a Paygentic entity (e.g. an `Item`) to a
      record in an external system such as Salesforce or NetSuite. Multiple
      external records may map to the same Paygentic entity, but each external
      id is the *primary* reference of at most one entity per merchant.
  - name: Items
    description: >-
      An `Item` is the canonical "thing you sell" that external-system mappings
      point at. It is fully decoupled from the billing `Product` and holds no
      pricing/plan/metering, and it is CRM/ERP agnostic — which providers map to
      it lives entirely in its `ExternalReference` rows.
  - name: MerchantIntegrations
    description: >-
      A `MerchantIntegration` records a merchant's connection to an external
      provider. One connection per `(merchant, provider)` — re-connecting
      upserts in place.
  - name: Approvals
    description: Submit, decide, cancel, and read maker-checker approvals.
  - name: Orders
    description: Manage Orders, their line items, and billing schedules.
  - name: Billing Schedules
    description: >-
      Owner-polymorphic billing schedules with intervals and staged invoice
      projections. A BillingSchedule belongs to exactly one Order or one
      Subscription (XOR). Cadence lives on ScheduleIntervals
      (cadence-on-the-line).
paths:
  /v0/plans/{id}/versions:
    parameters:
      - name: id
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/PlanId'
    post:
      tags:
        - Plans
      summary: Mint a plan version
      description: >-
        Mint a new plan version from a price diff and make it the version the
        plan bills from, in one step. The diff references existing prices by id:
        create prices beforehand with POST /prices, then add, remove, or replace
        them here. To return to an earlier price set, make that version the
        default with a PATCH on the version.
      operationId: mintPlanVersion
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MintPlanVersionRequest'
      responses:
        '201':
          description: The newly minted version, published and now the plan's default
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PlanVersion'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '500':
          $ref: '#/components/responses/InternalServerError'
components:
  schemas:
    PlanId:
      type: string
      pattern: ^plan_[a-zA-Z0-9]+$
      description: Unique identifier for a plan
    MintPlanVersionRequest:
      type: object
      additionalProperties: false
      description: >-
        A reference-by-id price diff applied to the prices of the plan's current
        version. Every id references an existing price created via POST /prices;
        inline price definitions are not accepted. An empty body copies the
        current prices into the new version unchanged. A version must carry at
        least one price, so a diff that would leave none is rejected.
      properties:
        addPrices:
          type: array
          items:
            $ref: '#/components/schemas/schemas-PriceId'
          description: >-
            Prices to add to the version. Each must not already be on the plan's
            current version.
        removePrices:
          type: array
          items:
            $ref: '#/components/schemas/schemas-PriceId'
          description: Prices to remove. Each must be on the plan's current version.
        replacePrices:
          type: array
          items:
            type: object
            additionalProperties: false
            required:
              - replacesPriceId
              - withPriceId
            properties:
              replacesPriceId:
                $ref: '#/components/schemas/schemas-PriceId'
              withPriceId:
                $ref: '#/components/schemas/schemas-PriceId'
          description: >-
            Prices to swap in place, preserving the slot's lineage so the price
            keeps its identity where the plan is configured for stable price
            ids. replacesPriceId must be on the plan's current version;
            withPriceId is the new price.
    PlanVersion:
      type: object
      description: >-
        A single plan version, including its price slots. Extends the list
        summary with the version's prices for draft review.
      required:
        - id
        - object
        - versionNumber
        - status
        - isDefault
        - subscriptionCount
        - updatedAt
        - prices
      properties:
        id:
          $ref: '#/components/schemas/PlanVersionId'
        object:
          type: string
          enum:
            - plan_version
        versionNumber:
          type: integer
          minimum: 1
          description: Monotonic version number within the plan, starting at 1.
        status:
          type: string
          enum:
            - draft
            - published
            - archived
          description: Lifecycle status of the version.
        publishedAt:
          type: string
          format: date-time
          description: When this version was published. Absent for draft versions.
        isDefault:
          type: boolean
          description: Whether this version is the plan's current default (live) version.
        subscriptionCount:
          type: integer
          minimum: 0
          description: >-
            Number of committed-status subscriptions pinned to this version at
            creation time. Not a live-billing cohort.
        basedOnVersionId:
          $ref: '#/components/schemas/PlanVersionId'
          description: >-
            The version this one follows on from — the version that was live
            when this one was created, and whose prices it was built from.
            Absent for versions created before this field existed.
        updatedAt:
          type: string
          format: date-time
          description: >-
            When this version was last modified. Optimistic-concurrency token:
            read this value and echo it back as an `If-Match` header on a
            draft-price-mutation request to reject the write (412) if the draft
            changed since this read.
        prices:
          type: array
          items:
            $ref: '#/components/schemas/PlanVersionPriceSlot'
          description: The price slots that make up this version.
    schemas-PriceId:
      type: string
      pattern: ^price_[a-zA-Z0-9]+$
      description: Unique identifier for a price
    PlanVersionId:
      type: string
      pattern: ^pver_[a-zA-Z0-9]+$
      description: Unique identifier for a plan version
    PlanVersionPriceSlot:
      description: >-
        One price slot on a plan version. Every `Price` field is present, plus
        `priceDeleted` layered on top.
      allOf:
        - $ref: '#/components/schemas/Price'
        - type: object
          required:
            - priceDeleted
          properties:
            priceDeleted:
              type: boolean
              description: >-
                True when the underlying price this slot references has been
                soft-deleted. The slot can still be removed or replaced to
                repair the draft; it cannot be published while any slot remains
                dead.
    Error:
      type: object
      required:
        - message
      properties:
        error:
          type: string
          description: >-
            Coarse HTTP error category (e.g. 'bad_request', 'forbidden'). Maps
            to the HTTP status code.
        message:
          type: string
          description: >-
            Human-readable error message. Clients must not parse this field
            programmatically.
        code:
          type: string
          examples:
            - TAX_NOT_ENABLED
            - PAYMENT_SESSION_EXPIRED
          description: >-
            Optional semantic business error code for machine-readable
            discrimination (e.g. 'TAX_NOT_ENABLED'). UPPER_SNAKE_CASE. Clients
            should check this field, not message.
        details:
          type: object
          description: Additional error details
          additionalProperties: true
      example:
        message: The requested resource was not found
        error: not_found
    ValidationError:
      type: object
      required:
        - message
        - errors
      properties:
        error:
          type: string
          enum:
            - validation_error
          default: validation_error
          description: Error type indicating validation failure
        message:
          type: string
          description: Human-readable error message
        errors:
          type: array
          items:
            type: object
            properties:
              field:
                type: string
                description: The field that failed validation
              message:
                type: string
                description: Validation error message for this field
              code:
                type: string
                description: Validation error code
            required:
              - field
              - message
          description: Array of field-specific validation errors
      example:
        message: Validation failed
        error: validation_error
        errors:
          - field: email
            message: Invalid email format
            code: invalid_format
    Price:
      type: object
      required:
        - id
        - object
        - merchantId
        - model
        - paymentTerm
        - invoiceDisplayName
        - properties
        - createdAt
        - updatedAt
        - quantity
      properties:
        id:
          $ref: '#/components/schemas/schemas-PriceId'
        object:
          type: string
          enum:
            - price
          default: price
        merchantId:
          $ref: '#/components/schemas/OrganizationId'
          description: >-
            The merchant organization that owns this price, derived from the
            associated fee or billable metric.
        billableMetricId:
          type: string
        feeId:
          type: string
          pattern: ^fee_[a-zA-Z0-9]+$
          description: The unique identifier for the fee referred to by this price
        billingCadence:
          type: string
          nullable: true
          description: ISO 8601 duration for billing frequency (e.g., P1M for monthly)
        createdAt:
          type: string
          format: date-time
        currency:
          type: string
        description:
          type: string
        invoiceDisplayName:
          type: string
        model:
          type: string
          enum:
            - standard
            - dynamic
            - volume
            - percentage
        paymentTerm:
          type: string
          enum:
            - in_arrears
            - in_advance
        properties:
          type: object
          additionalProperties: true
        unitAmount:
          type: string
        updatedAt:
          type: string
          format: date-time
        features:
          type: array
          items:
            $ref: '#/components/schemas/PriceFeature'
          description: Features associated with this price
        grantDiscountEnabled:
          type: boolean
          default: false
          description: >-
            When true, grants applied to a subscription will discount usage
            charged by this price. Only supported for standard metered prices.
        quantity:
          type: integer
          minimum: 1
          maximum: 1000000
          default: 1
          description: >-
            Quantity used when generating invoice line items for this price.
            Total per period = quantity × unitPrice. Only supported for fee
            prices; metered prices derive quantity from usage. Defaults to 1.
    OrganizationId:
      type: string
      pattern: ^org_[a-zA-Z0-9]+$
      description: Unique identifier for an organization
    PriceFeature:
      type: object
      required:
        - id
        - featureId
        - entitlementTemplate
      properties:
        id:
          type: string
        featureId:
          type: string
        entitlementTemplate:
          type: object
          additionalProperties: true
        feature:
          type: object
          properties:
            key:
              type: string
            name:
              type: string
            type:
              type: string
              enum:
                - metered
                - static
                - boolean
  responses:
    BadRequest:
      description: >-
        Bad Request - The request could not be understood or was missing
        required parameters
      content:
        application/json:
          schema:
            oneOf:
              - $ref: '#/components/schemas/Error'
              - $ref: '#/components/schemas/ValidationError'
    Unauthorized:
      description: Unauthorized - Authentication failed or user does not have permissions
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Forbidden:
      description: Forbidden - Request is understood but refused
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    NotFound:
      description: Not Found - The requested resource could not be found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Conflict:
      description: Conflict - The request conflicts with the current state of the resource
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    InternalServerError:
      description: Internal Server Error - Something went wrong on the server side
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: API key authentication

````