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

# Create Purchase URL

> Creates a secure checkout URL for purchasing a product.



## OpenAPI

````yaml /openapi/server.json post /payments/purchases/create-purchase-url
openapi: 3.1.0
info:
  title: Hexclave REST API
  version: 1.0.0
  description: >-
    The Hexclave REST API. All request headers are documented as canonical
    `X-Hexclave-*`; the equivalent `X-Stack-*` aliases are accepted on every
    endpoint for backwards compatibility. Response headers
    `X-Hexclave-actual-status`, `X-Hexclave-known-error`, and
    `X-Hexclave-request-id` are emitted alongside their legacy `X-Stack-*`
    equivalents.
servers:
  - url: https://api.hexclave.com/api/v1
    description: Hexclave REST API
security: []
paths:
  /payments/purchases/create-purchase-url:
    post:
      tags:
        - Payments
      summary: Create Purchase URL
      description: Creates a secure checkout URL for purchasing a product.
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                customer_type:
                  type: string
                  enum:
                    - user
                    - team
                    - custom
                  example: user
                  description: The type of customer making the purchase
                customer_id:
                  type: string
                  example: user_1234567890abcdef
                  description: >-
                    The ID of the customer (user ID, team ID, or custom customer
                    ID)
                product_id:
                  type: string
                  example: prod_premium_monthly
                  description: >-
                    The ID of the product to purchase. Either this or
                    product_inline should be given.
                product_inline:
                  type: object
                  properties:
                    display_name:
                      type: string
                    customer_type:
                      type: string
                      enum:
                        - user
                        - team
                        - custom
                    free_trial:
                      type: array
                      items:
                        type: integer
                    server_only:
                      type: boolean
                      default: true
                    stackable:
                      type: boolean
                      default: false
                    prices:
                      type: object
                      properties: {}
                      required: []
                    included_items:
                      type: object
                      properties: {}
                      required: []
                    client_metadata:
                      type: object
                      example:
                        featureFlag: true
                        source: marketing-campaign
                      description: >-
                        Client metadata. Used as a data store, accessible from
                        the client side. Do not store information that should
                        not be exposed to the client.
                    client_read_only_metadata:
                      type: object
                      example:
                        featureFlag: true
                        source: marketing-campaign
                      description: >-
                        Client read-only, server-writable metadata. Used as a
                        data store, accessible from the client side. Do not
                        store information that should not be exposed to the
                        client. The client can read this data, but cannot modify
                        it. This is useful for things like subscription status.
                    server_metadata:
                      type: object
                      example:
                        featureFlag: true
                        source: marketing-campaign
                      description: >-
                        Server metadata. Used as a data store, only accessible
                        from the server side. You can store secret information
                        related to the product here.
                  required:
                    - display_name
                    - customer_type
                  description: >-
                    Inline product definition. Either this or product_id should
                    be given.
                return_url:
                  type: string
                  example: https://myapp.com/purchase-success
                  description: >-
                    URL to redirect to after purchase completion. Must be
                    configured as a trusted domain in the project configuration.
              required:
                - customer_type
                - customer_id
              example:
                customer_type: user
                customer_id: user_1234567890abcdef
                product_id: prod_premium_monthly
                return_url: https://myapp.com/purchase-success
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  url:
                    type: string
                    description: The secure checkout URL for completing the purchase
                required:
                  - url

````