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

# Create Checkout Session

> Create a payment checkout session to purchase credits

Initiate a checkout session to purchase credits using your preferred payment method. Returns a checkout URL for the payment flow.

<CodeGroup>
  ```python Python theme={null}
  import requests

  payload = {
      "amount": 50,
      "success_url": "https://yourapp.com/billing/success",
      "cancel_url": "https://yourapp.com/billing/cancelled"
  }

  response = requests.post(
      "https://api.videodb.io/billing/checkout",
      json=payload,
      headers={"x-access-token": "your_api_key"}
  )

  checkout_data = response.json()
  print(f"Checkout URL: {checkout_data.get('checkout_url')}")
  print(f"Session ID: {checkout_data.get('id')}")
  ```

  ```javascript Node.js theme={null}
  const payload = {
      amount: 50,
      successUrl: "https://yourapp.com/billing/success",
      cancelUrl: "https://yourapp.com/billing/cancelled"
  };

  const response = await fetch("https://api.videodb.io/billing/checkout", {
      method: "POST",
      headers: {
          "x-access-token": "your_api_key",
          "Content-Type": "application/json"
      },
      body: JSON.stringify(payload)
  });

  const checkoutData = await response.json();
  console.log(`Checkout URL: ${checkoutData.checkoutUrl}`);
  console.log(`Session ID: ${checkoutData.id}`);
  ```
</CodeGroup>

<Note>
  * Amount is specified in USD (whole dollars)
  * Success and cancel URLs redirect users after payment completion or cancellation
  * Checkout sessions expire after 24 hours if not completed
  * Credits are added to your account immediately upon successful payment
</Note>

<CardGroup cols={2}>
  <Card title="List Checkouts" icon="list" href="/api-reference/billing/list_checkouts">
    View all checkout sessions and their status
  </Card>

  <Card title="Get Usage Statistics" icon="chart-line" href="/api-reference/billing/get_usage">
    Monitor credit usage and balance
  </Card>
</CardGroup>


## OpenAPI

````yaml POST /billing/checkout
openapi: 3.0.3
info:
  title: VideoDB Server API
  description: >
    VideoDB Server API for video, audio, and image processing with AI
    capabilities.

    This API provides comprehensive video management, search, indexing, and
    AI-powered features.
  version: 1.0.0
  contact:
    name: VideoDB Support
    url: https://videodb.io
  license:
    name: MIT
    url: https://opensource.org/licenses/MIT
servers:
  - url: https://api.videodb.io
    description: Production server
  - url: https://staging-api.videodb.io
    description: Staging server
security:
  - ApiKeyAuth: []
tags:
  - name: Authentication
    description: User authentication and API key management
  - name: Collections
    description: Collection management operations
  - name: Videos
    description: Video upload, processing, and management
  - name: Audio
    description: Audio management operations
  - name: Images
    description: Image management operations
  - name: Search
    description: Content search and indexing
  - name: AI Generation
    description: AI-powered content generation
  - name: Billing
    description: Billing and usage management
  - name: RTStream
    description: Real-time streaming operations
  - name: Utilities
    description: Utility endpoints
  - name: Meeting
    description: Meeting recording and management
  - name: Capture
    description: Capture session management for recording streams
  - name: Editor
    description: Timeline editor operations
  - name: Transcode
    description: Media transcoding operations
  - name: Assets
    description: Cross-collection asset listing
paths:
  /billing/checkout:
    post:
      summary: Create billing checkout session
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                mode:
                  type: string
                  enum:
                    - payment
                    - subscription
                  example: payment
                plan_id:
                  type: string
                  example: plan-basic
                amount:
                  type: number
                  example: 100
      responses:
        '200':
          description: Checkout URL
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: object
                    properties:
                      url:
                        type: string
                        example: https://checkout.stripe.com/pay/xxx
      security:
        - ApiKeyAuth: []
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-access-token
      description: API key for authentication (sk-xxx format)

````