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

# Create Checkout Session

> Create a customer-specific checkout session link to purchase a set of plans



## OpenAPI

````yaml https://api.getmeasure.com/api/v1/docs/api_spec.json POST /companies/{company_id}/checkout
openapi: 3.1.0
info:
  title: Measure API
  description: APIs to communicate with Measure
  version: 1.0.0
servers:
  - url: https://api.getmeasure.com/api/v1
security: []
paths:
  /companies/{company_id}/checkout:
    post:
      tags:
        - Checkout
      summary: Create Checkout Session
      description: >-
        Create a customer-specific checkout session link to purchase a set of
        plans
      operationId: Create_Checkout_Session
      parameters:
        - name: company_id
          in: path
          description: 'The company ID with the prefix ''cmp_''. '
          required: true
          schema:
            description: 'The company ID with the prefix ''cmp_''. '
            type: string
        - name: Idempotency-Key
          in: header
          description: >-
            The idempotency key that will be used to ensure the request is only
            performed once
          schema:
            description: >-
              The idempotency key that will be used to ensure the request is
              only performed once
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RequestCreateCheckoutSessionRequest'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseProposalLinkResponse'
      deprecated: false
      security:
        - apiKey:
            - ''
components:
  schemas:
    RequestCreateCheckoutSessionRequest:
      properties:
        auto_charges:
          description: >-
            Whether the subscription is automatically charged to the payment
            method after the checkout session
          type:
            - 'null'
            - boolean
        auto_renews:
          description: >-
            Whether this subscription auto renews at the end of the term. This
            is to be used without end date or renewal date
          type:
            - 'null'
            - boolean
        bundle_pricing_id:
          description: The bundle pricing that forms the checkout session
          type:
            - 'null'
            - string
        change_proration_type:
          description: >-
            The proration type of the existing subscription, if provided. This
            is one of NEXT, IMMEDIATE or NONE based on whether the proration is
            charged on the next invoice, immediately or no proration is applied
            respectively
          enum:
            - NEXT
            - IMMEDIATE
            - NONE
          type:
            - 'null'
            - string
        change_reset_billing_anchor:
          description: >-
            Whether to reset the billing anchor of the existing subscription, if
            provided
          type:
            - 'null'
            - boolean
        change_timing:
          description: >-
            The change timing of the existing subscription, if provided. This is
            one of IMMEDIATE, PERIOD_END or RENEWAL based on whether the change
            timing needs to be immediate, at the end of the current period, on
            renewal respectively
          enum:
            - IMMEDIATE
            - PERIOD_END
            - RENEWAL
          type:
            - 'null'
            - string
        config_items:
          items:
            $ref: '#/components/schemas/ModelSubscriptionConfigItem'
          type:
            - array
        customer_id:
          description: The customer attached to the checkout session
          type:
            - string
        discounts:
          description: The discounts attached to the checkout session
          items:
            $ref: '#/components/schemas/ModelDiscountParams'
          type:
            - array
            - 'null'
        metadata:
          additionalProperties: true
          description: >-
            Any additional as key-value pairs that needs to be attached to the
            subscription after the checkout session
          type: object
        onetime_items:
          description: Any one time charges to be attached to the checkout session
          items:
            $ref: '#/components/schemas/ModelOneTimeParams'
          type:
            - array
            - 'null'
        options:
          $ref: '#/components/schemas/RequestCreateProposalOptionsRequest'
          description: >-
            The detailed options for the checkout session such as confirmation
            messages, redirect urls etc.
        previous_subscription_id:
          description: >-
            The ID of an existing subscription whose plan will change with the
            checkout session
          type:
            - 'null'
            - string
        product_pricing_ids:
          description: The list of product pricings that form the checkout session
          items:
            type: string
          type:
            - array
            - 'null'
        term:
          $ref: '#/components/schemas/ModelTerm'
          description: The term for the subscription created by the checkout session
        trial:
          description: Whether the checkout session creates a subscription in a trial
          type:
            - 'null'
            - boolean
        trial_term:
          $ref: '#/components/schemas/ModelTerm'
          description: The trial term for the subscription after the checkout session
        type:
          description: The type of the checkout session
          enum:
            - CHECKOUT_SESSION
          type: string
      required:
        - type
        - customer_id
        - config_items
      type: object
    ResponseProposalLinkResponse:
      properties:
        id:
          description: The ID of the checkout session
          type: string
        url:
          description: The checkout link generated
          type:
            - 'null'
            - string
      type: object
    ModelSubscriptionConfigItem:
      description: >-
        The configuration for pricing components which can be license counts or
        minimum usage units
      properties:
        hide_at_checkout:
          description: >-
            Whether the pricing row will be hidden at checkout, defaults to
            false
          type:
            - 'null'
            - boolean
        minimum_units:
          description: The number of minimum units for this usage-based component
          format: double
          minimum: 0
          type: number
        num_licenses:
          description: The number of licenses for this license-based component
          format: double
          minimum: 0
          type: number
        product_metric_pricing_id:
          description: The product metric pricing ID to which this config applies.
          type:
            - 'null'
            - string
        product_pricing_id:
          description: >-
            The product pricing ID to which this config applies. If the product
            pricing contains multiple components, the same config will apply to
            all of them
          type:
            - 'null'
            - string
        quantity_config:
          $ref: '#/components/schemas/ModelQuantityConfig'
        sort_order:
          description: The sort index
          type:
            - 'null'
            - number
        upsell_product_metric_pricing_id:
          type:
            - 'null'
            - string
      type: object
    ModelDiscountParams:
      description: The details for the discount
      properties:
        amount:
          $ref: '#/components/schemas/ModelAmount'
        cap:
          $ref: '#/components/schemas/ModelAmount'
        coupon_id:
          type:
            - 'null'
            - string
        customer_id:
          type:
            - 'null'
            - string
        expiration_date:
          format: date-time
          type:
            - 'null'
            - string
        import_created_at_ref:
          format: date-time
          type:
            - 'null'
            - string
        import_ref:
          type:
            - 'null'
            - string
        imported_from:
          type:
            - 'null'
            - string
        item_pricing_id:
          type:
            - 'null'
            - string
        name:
          type: string
        onetime_billable_id:
          type:
            - 'null'
            - string
        percent:
          format: double
          maximum: 1
          minimum: 0
          type: number
        product_id:
          type:
            - 'null'
            - string
        product_pricing_id:
          type:
            - 'null'
            - string
        proposal_id:
          type:
            - 'null'
            - string
        state:
          enum:
            - ACTIVE
            - PENDING
            - REVOKED
            - EXPIRED
            - CONSUMED
          type:
            - 'null'
            - string
        subscription_id:
          type:
            - 'null'
            - string
        type:
          enum:
            - DISCOUNT_AMOUNT
            - DISCOUNT_PERCENT
            - DISCOUNT_AMOUNT_PER_UNIT
          type: string
      required:
        - name
        - type
      type: object
    ModelOneTimeParams:
      description: The pricing and aggregate for the one-time billable item
      properties:
        aggregate:
          description: The quantity of the one-time charge
          exclusiveMinimum: 0
          format: double
          type: number
        custom_price:
          $ref: '#/components/schemas/ModelOneTimeCustomPrice'
          description: >-
            The custom pricing for the product. Either 'product_pricing_id' or
            'custom_price' is required
        product_pricing_id:
          description: >-
            The product pricing for the one-time charge. Either
            'product_pricing_id' or 'custom_price' is required
          type:
            - 'null'
            - string
        quantity_config:
          $ref: '#/components/schemas/ModelQuantityConfig'
        sort_order:
          description: The sort index
          type:
            - 'null'
            - number
      required:
        - aggregate
      type: object
    RequestCreateProposalOptionsRequest:
      properties:
        allow_promo_code:
          description: Whether promo codes are allowed
          type:
            - 'null'
            - boolean
        completion_action:
          description: >-
            The action to perform upon completion which can be REDIRECT or
            CONFIRMATION_PAGE
          enum:
            - REDIRECT
            - CONFIRMATION_PAGE
          type:
            - 'null'
            - string
        confirmation_message:
          description: >-
            The message to show on completion, if the completion action is
            CONFIRMATION_PAGE
          type:
            - 'null'
            - string
        redirect_url:
          description: >-
            The url to redirect to on completion, if the completion action is
            REDIRECT
          type:
            - 'null'
            - string
        requires_customer_address:
          description: Whether the customer address is required, typically for tax purposes
          type:
            - 'null'
            - boolean
      type:
        - object
        - 'null'
    ModelTerm:
      description: >-
        The term which includes a frequency interval and a count for number of
        intervals
      properties:
        count:
          description: The number of times the frequency elapses
          exclusiveMinimum: 0
          format: int64
          type: integer
        frequency:
          description: The frequency at which the term repeats
          enum:
            - HOUR
            - DAY
            - WEEK
            - BI_MONTH
            - MONTH
            - QUARTER
            - BI_ANNUAL
            - YEAR
            - ONETIME
          type: string
      required:
        - frequency
        - count
      type: object
    ModelQuantityConfig:
      properties:
        allow_custom_quantity:
          type: boolean
        max_quantity:
          type: integer
        min_quantity:
          type: integer
      type: object
    ModelAmount:
      description: The amount which has value in cents and a currency
      properties:
        currency:
          type: string
        value_in_cents:
          format: int64
          type: integer
      type: object
    ModelOneTimeCustomPrice:
      properties:
        amount:
          $ref: '#/components/schemas/ModelAmount'
          description: The amount of quantity
        description:
          description: The description of the one-time charge
          type:
            - string
            - 'null'
        product_id:
          description: The product ID
          type: string
      required:
        - product_id
        - amount
      type: object
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer

````