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

# Create Checkout Session

> Create a Stripe checkout session for purchasing credits.

The active org is captured in ``session.metadata.org_id`` so the
webhook credits the org the buyer was in when they clicked "Buy" —
not whichever org they happen to be in when Stripe fires the event.



## OpenAPI

````yaml /api-reference/openapi.json post /api/v2/external/billing/checkout
openapi: 3.1.0
info:
  title: Lyceum Cloud API
  version: 0.1.0
servers:
  - url: https://api.lyceum.technology
    description: Production
security:
  - bearerAuth: []
paths:
  /api/v2/external/billing/checkout:
    post:
      tags:
        - Billing
      summary: Create Checkout Session
      description: |-
        Create a Stripe checkout session for purchasing credits.

        The active org is captured in ``session.metadata.org_id`` so the
        webhook credits the org the buyer was in when they clicked "Buy" —
        not whichever org they happen to be in when Stripe fires the event.
      operationId: create_checkout_session_api_v2_external_billing_checkout_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CheckoutSessionRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CheckoutSessionResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    CheckoutSessionRequest:
      properties:
        credits_amount:
          type: integer
          title: Credits Amount
        success_url:
          anyOf:
            - type: string
            - type: 'null'
          title: Success Url
        cancel_url:
          anyOf:
            - type: string
            - type: 'null'
          title: Cancel Url
      type: object
      required:
        - credits_amount
      title: CheckoutSessionRequest
    CheckoutSessionResponse:
      properties:
        checkout_url:
          type: string
          title: Checkout Url
        session_id:
          type: string
          title: Session Id
      type: object
      required:
        - checkout_url
        - session_id
      title: CheckoutSessionResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Pass an API key (prefixed `lk_`) or a JWT access token as a bearer
        token. Generate API keys in the dashboard at
        https://dashboard.lyceum.technology/api-keys.

````