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

# Generate Checkout URL

> Generate secure checkout URLs for customer subscription purchases



## OpenAPI

````yaml GET /api/v1/products/offerings/generate-checkout-url
openapi: 3.0.1
info:
  title: Metrifox API Documentation
  version: v1
  description: >-
    Welcome to Metrifox Platform's API documentation. This comprehensive API
    suite enables seamless integration with our platform, providing secure and
    efficient access to our services.
servers:
  - url: https://{defaultHost}
    variables:
      defaultHost:
        default: api.metrifox.com
security:
  - api_key: []
paths:
  /api/v1/products/offerings/generate-checkout-url:
    get:
      tags:
        - Checkout
      summary: Generate checkout URL
      description: >
        Generates a secure checkout URL for customers to complete their
        subscription purchase. 

        The URL can be customized with offering details, billing intervals, and
        pre-filled customer information.


        **Key Features:**

        - **Offering Integration**: Specify the offering key to generate URLs
        for specific products/plans

        - **Billing Flexibility**: Optional billing interval specification
        (monthly, yearly, etc.)

        - **Customer Pre-fill**: Include customer key to pre-populate checkout
        forms

        - **Secure URLs**: Generated URLs are time-limited and secure
      operationId: generateCheckoutUrl
      parameters:
        - name: offering_key
          in: query
          required: true
          description: The unique identifier for the offering/product
          schema:
            type: string
          example: premium_plan_monthly
        - name: billing_interval
          in: query
          required: false
          description: Optional billing interval for the subscription
          schema:
            type: string
            enum:
              - monthly
              - yearly
              - quarterly
          example: monthly
        - name: customer_key
          in: query
          required: false
          description: Optional customer key to pre-fill checkout information
          schema:
            type: string
          example: customer_123
      responses:
        '200':
          description: Checkout URL generated successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  statusCode:
                    type: integer
                    example: 200
                  message:
                    type: string
                    example: ''
                  data:
                    type: object
                    properties:
                      checkout_url:
                        type: string
                        format: uri
                        description: The generated checkout URL
                        example: >-
                          https://app.metrifox.com/your-organization/checkout/premium_plan_monthly
              examples:
                checkout_url_response:
                  summary: Successful Checkout URL Generation
                  value:
                    statusCode: 200
                    message: ''
                    data:
                      checkout_url: >-
                        https://app.metrifox.com/your-organization/checkout/premium_plan_monthly
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                type: object
                properties:
                  statusCode:
                    type: integer
                    example: 400
                  message:
                    type: string
                    example: Bad request
                  data:
                    type: object
                    example: {}
                  meta:
                    type: object
                    example: {}
                  errors:
                    type: object
                    example: {}
        '401':
          description: Unauthorized - Invalid or missing API key
          content:
            application/json:
              schema:
                type: object
                properties:
                  statusCode:
                    type: integer
                    example: 401
                  message:
                    type: string
                    example: Unauthorized
                  data:
                    type: object
                    example: {}
                  meta:
                    type: object
                    example: {}
                  errors:
                    type: object
                    example: {}
        '404':
          description: Not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  statusCode:
                    type: integer
                    example: 404
                  message:
                    type: string
                    example: Not found
                  data:
                    type: object
                    example: {}
                  meta:
                    type: object
                    example: {}
                  errors:
                    type: object
                    example: {}
      x-codeSamples:
        - lang: python
          label: Python SDK
          source: |
            from metrifox_sdk import MetrifoxClient

            client = MetrifoxClient(api_key="your_api_key")

            # Basic checkout URL generation
            checkout_url = client.checkout.url({
                "offering_key": "your_offering_key"
            })

            # With optional billing interval
            checkout_url = client.checkout.url({
                "offering_key": "your_offering_key",
                "billing_interval": "monthly"
            })

            # With customer key for pre-filled checkout
            checkout_url = client.checkout.url({
                "offering_key": "your_offering_key",
                "billing_interval": "monthly",
                "customer_key": "customer_123"
            })

            # Using type-safe CheckoutConfig
            from metrifox_sdk import CheckoutConfig

            checkout_config = CheckoutConfig(
                offering_key="your_offering_key",
                billing_interval="monthly",
                customer_key="customer_123"
            )

            checkout_url = client.checkout.url(checkout_config)
        - lang: js
          label: JavaScript SDK
          source: |
            import { init } from "metrifox-js";

            const metrifoxClient = init({
              apiKey: process.env.METRIFOX_API_KEY
            });

            // Basic checkout URL generation
            const checkoutUrl = await metrifoxClient.checkout.url({
              offeringKey: "your_offering_key"
            });

            // With optional billing interval
            const checkoutUrl = await metrifoxClient.checkout.url({
              offeringKey: "your_offering_key",
              billingInterval: "monthly"
            });

            // With customer key for pre-filled checkout
            const checkoutUrl = await metrifoxClient.checkout.url({
              offeringKey: "your_offering_key",
              billingInterval: "monthly",
              customerKey: "customer_123"
            });
        - lang: ruby
          label: Ruby SDK
          source: |
            require 'metrifox-sdk'

            # Initialize with configuration
            METRIFOX_SDK = MetrifoxSDK.init({ api_key: "your-api-key" })

            # Basic checkout URL generation
            checkout_url = METRIFOX_SDK.checkout.url({
              offering_key: "your_offering_key"
            })

            # With optional billing interval
            checkout_url = METRIFOX_SDK.checkout.url({
              offering_key: "your_offering_key",
              billing_interval: "monthly"
            })

            # With customer key for pre-filled checkout
            checkout_url = METRIFOX_SDK.checkout.url({
              offering_key: "your_offering_key",
              billing_interval: "monthly",
              customer_key: "customer_123"
            })

            # Using structured config object
            checkout_config = MetrifoxSDK::Types::CheckoutConfig.new(
              offering_key: "your_offering_key",
              billing_interval: "monthly",
              customer_key: "customer_123"
            )

            checkout_url = METRIFOX_SDK.checkout.url(checkout_config)
        - lang: curl
          label: cURL
          source: >
            curl -X GET
            "https://api.metrifox.com/api/v1/products/offerings/generate-checkout-url?offering_key=your_offering_key&billing_interval=monthly&customer_key=customer_123"
            \
              -H "x-api-key: your-api-key"
components:
  securitySchemes:
    api_key:
      type: apiKey
      name: x-api-key
      in: header

````