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

# Create billing checkout session

> Opens a checkout for a subscription, a credit pack or an Aether inference top-up: a Stripe hosted checkout on the web, a store purchase intent on ios and android.

Use this tool when you need to:
- Subscribe the org to a paid tier
- Buy a credit pack or top up the org's Aether inference balance
- Get the store product and store identity a device buys with on ios or android

Examples:
- POST /orgs/{orgID}/billing/checkout-sessions {"checkout_type": "subscription", "surface": "web", "tier": "pro", "return_path": "/settings/billing"}
- POST /orgs/{orgID}/billing/checkout-sessions {"checkout_type": "inference_topup", "surface": "ios", "amount_usd": 25}

Hints:
- orgID is the org's uuid. checkout_type picks the body: subscription takes tier (starter, pro, max or team), credit_pack takes credit_pack_id (credits_100, credits_250, credits_500 or credits_1000), inference_topup takes amount_usd (5 to 5000). surface is required in each; return_path, a local path of at most 500 characters such as /settings/billing, is required on the web and refused on ios and android.
- In a JSON object body, a missing surface or one other than web, ios or android is refused with 400 invalid_surface before the schema runs; the schema then answers 422 for any other field out of shape or unknown. The handler answers 400 for a return_path sent from ios or android or missing on the web, the team tier on ios or android (sold on the web only), an amount_usd that is not whole cents, and a store top-up amount other than 5, 10, 25 or 50 (getBillingCatalog's top_up_skus).
- Answers 201 with the BillingCheckoutSession, status created: on the web its url is the Stripe hosted checkout to open; on ios and android it carries store_product_id and store_app_user_id for the device to buy with, and the device then binds its transaction with bindBillingCheckoutSessionTransaction. A team org's subscription is priced per seat, one per entry of plan.seats; a store top-up adds no fee.
- A new checkout expires the org's open one for the same purchase (any open subscription checkout, or the same credit pack or top-up on the same channel); one already settling (paid, bound to a store transaction, or still being created at Stripe) is refused with 409.
- Refused with 422 team_org_requires_team_plan or personal_org_requires_personal_plan for a tier the org's kind cannot buy; 409 with the reason as code when getBillingSubscription's matching action is unavailable on that surface (subscription_active, subscription_pending, checkout_pending, managed_elsewhere or provider_unavailable for a subscription; payment_delinquent, enterprise_invoice or provider_unavailable for a credit pack or top-up); 409 when the caller's profile has no email for the org's first Stripe customer; 404 for an org without billing; and 502 when Stripe fails.
- Use getBillingCheckoutSession instead to follow the checkout, createBillingPortalSession to change or manage an existing Stripe subscription, getBillingCatalog for tiers and top-up amounts, and listBillingCreditPacks for packs.
- Owners, admins and billing members only, with a session or a platform API key: a member or viewer is refused with 403 org_role_insufficient before the body is read, a non-member with 403 org_membership_required, an orgID that is not a uuid with 400, and an agent host's grant with 403 agent_host_route_not_allowed.



## OpenAPI

````yaml api-reference/openapi.json POST /orgs/{orgID}/billing/checkout-sessions
openapi: 3.1.0
info:
  title: Aether API
  version: 0.1.0
servers:
  - url: https://api.runaether.dev
security:
  - bearerAuth: []
paths:
  /orgs/{orgID}/billing/checkout-sessions:
    post:
      tags:
        - billing
      summary: Create billing checkout session
      description: >-
        Opens a checkout for a subscription, a credit pack or an Aether
        inference top-up: a Stripe hosted checkout on the web, a store purchase
        intent on ios and android.


        Use this tool when you need to:

        - Subscribe the org to a paid tier

        - Buy a credit pack or top up the org's Aether inference balance

        - Get the store product and store identity a device buys with on ios or
        android


        Examples:

        - POST /orgs/{orgID}/billing/checkout-sessions {"checkout_type":
        "subscription", "surface": "web", "tier": "pro", "return_path":
        "/settings/billing"}

        - POST /orgs/{orgID}/billing/checkout-sessions {"checkout_type":
        "inference_topup", "surface": "ios", "amount_usd": 25}


        Hints:

        - orgID is the org's uuid. checkout_type picks the body: subscription
        takes tier (starter, pro, max or team), credit_pack takes credit_pack_id
        (credits_100, credits_250, credits_500 or credits_1000), inference_topup
        takes amount_usd (5 to 5000). surface is required in each; return_path,
        a local path of at most 500 characters such as /settings/billing, is
        required on the web and refused on ios and android.

        - In a JSON object body, a missing surface or one other than web, ios or
        android is refused with 400 invalid_surface before the schema runs; the
        schema then answers 422 for any other field out of shape or unknown. The
        handler answers 400 for a return_path sent from ios or android or
        missing on the web, the team tier on ios or android (sold on the web
        only), an amount_usd that is not whole cents, and a store top-up amount
        other than 5, 10, 25 or 50 (getBillingCatalog's top_up_skus).

        - Answers 201 with the BillingCheckoutSession, status created: on the
        web its url is the Stripe hosted checkout to open; on ios and android it
        carries store_product_id and store_app_user_id for the device to buy
        with, and the device then binds its transaction with
        bindBillingCheckoutSessionTransaction. A team org's subscription is
        priced per seat, one per entry of plan.seats; a store top-up adds no
        fee.

        - A new checkout expires the org's open one for the same purchase (any
        open subscription checkout, or the same credit pack or top-up on the
        same channel); one already settling (paid, bound to a store transaction,
        or still being created at Stripe) is refused with 409.

        - Refused with 422 team_org_requires_team_plan or
        personal_org_requires_personal_plan for a tier the org's kind cannot
        buy; 409 with the reason as code when getBillingSubscription's matching
        action is unavailable on that surface (subscription_active,
        subscription_pending, checkout_pending, managed_elsewhere or
        provider_unavailable for a subscription; payment_delinquent,
        enterprise_invoice or provider_unavailable for a credit pack or top-up);
        409 when the caller's profile has no email for the org's first Stripe
        customer; 404 for an org without billing; and 502 when Stripe fails.

        - Use getBillingCheckoutSession instead to follow the checkout,
        createBillingPortalSession to change or manage an existing Stripe
        subscription, getBillingCatalog for tiers and top-up amounts, and
        listBillingCreditPacks for packs.

        - Owners, admins and billing members only, with a session or a platform
        API key: a member or viewer is refused with 403 org_role_insufficient
        before the body is read, a non-member with 403 org_membership_required,
        an orgID that is not a uuid with 400, and an agent host's grant with 403
        agent_host_route_not_allowed.
      operationId: createBillingCheckoutSession
      parameters:
        - in: path
          name: orgID
          required: true
          schema:
            format: uuid
            type: string
      requestBody:
        content:
          application/json:
            schema:
              discriminator:
                mapping:
                  credit_pack: >-
                    #/components/schemas/CreateBillingCreditPackCheckoutSessionRequest
                  inference_topup: >-
                    #/components/schemas/CreateBillingInferenceTopUpCheckoutSessionRequest
                  subscription: >-
                    #/components/schemas/CreateBillingSubscriptionCheckoutSessionRequest
                propertyName: checkout_type
              oneOf:
                - $ref: >-
                    #/components/schemas/CreateBillingSubscriptionCheckoutSessionRequest
                - $ref: >-
                    #/components/schemas/CreateBillingCreditPackCheckoutSessionRequest
                - $ref: >-
                    #/components/schemas/CreateBillingInferenceTopUpCheckoutSessionRequest
        required: true
      responses:
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BillingCheckoutSession'
          description: Created
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BillingErrorResponse'
          description: Bad Request
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BillingErrorResponse'
          description: Unauthorized
        '403':
          content:
            application/json:
              schema:
                anyOf:
                  - $ref: '#/components/schemas/BillingErrorResponse'
                  - $ref: '#/components/schemas/OrgAuthorizationErrorResponse'
          description: Forbidden
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BillingErrorResponse'
          description: Not Found
        '409':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BillingErrorResponse'
          description: Conflict
        '410':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BillingErrorResponse'
          description: Gone
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BillingErrorResponse'
          description: Unprocessable Entity
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BillingErrorResponse'
          description: Internal Server Error
        '502':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BillingErrorResponse'
          description: Bad Gateway
components:
  schemas:
    CreateBillingCreditPackCheckoutSessionRequest:
      additionalProperties: false
      properties:
        checkout_type:
          enum:
            - credit_pack
          type: string
        credit_pack_id:
          enum:
            - credits_100
            - credits_250
            - credits_500
            - credits_1000
          type: string
        return_path:
          description: >-
            Where the hosted checkout returns. Required on the web; refused on
            ios and android.
          maxLength: 500
          pattern: >-
            ^/(?:(?:\.{3,}[!-"$&-.0->A-\[\]-~]*|\.{0,2}[!-"$&--0->A-\[\]-~][!-"$&-.0->A-\[\]-~]*)/)*(?:\.{3,}[!-"$&-.0->A-\[\]-~]*|\.{0,2}[!-"$&--0->A-\[\]-~][!-"$&-.0->A-\[\]-~]*)?$
          type: string
        surface:
          description: >-
            The client purchasing: web opens a Stripe hosted checkout; ios and
            android create a store purchase intent.
          enum:
            - web
            - ios
            - android
          type: string
      required:
        - checkout_type
        - surface
        - credit_pack_id
      type: object
    CreateBillingInferenceTopUpCheckoutSessionRequest:
      additionalProperties: false
      properties:
        amount_usd:
          description: >-
            Any whole-cent amount within the bounds on the web; one of
            top_up_skus' amounts on ios and android.
          format: double
          maximum: 5000
          minimum: 5
          type: number
        checkout_type:
          enum:
            - inference_topup
          type: string
        return_path:
          description: >-
            Where the hosted checkout returns. Required on the web; refused on
            ios and android.
          maxLength: 500
          pattern: >-
            ^/(?:(?:\.{3,}[!-"$&-.0->A-\[\]-~]*|\.{0,2}[!-"$&--0->A-\[\]-~][!-"$&-.0->A-\[\]-~]*)/)*(?:\.{3,}[!-"$&-.0->A-\[\]-~]*|\.{0,2}[!-"$&--0->A-\[\]-~][!-"$&-.0->A-\[\]-~]*)?$
          type: string
        surface:
          description: >-
            The client purchasing: web opens a Stripe hosted checkout; ios and
            android create a store purchase intent.
          enum:
            - web
            - ios
            - android
          type: string
      required:
        - checkout_type
        - surface
        - amount_usd
      type: object
    CreateBillingSubscriptionCheckoutSessionRequest:
      additionalProperties: false
      properties:
        checkout_type:
          enum:
            - subscription
          type: string
        return_path:
          description: >-
            Where the hosted checkout returns. Required on the web; refused on
            ios and android.
          maxLength: 500
          pattern: >-
            ^/(?:(?:\.{3,}[!-"$&-.0->A-\[\]-~]*|\.{0,2}[!-"$&--0->A-\[\]-~][!-"$&-.0->A-\[\]-~]*)/)*(?:\.{3,}[!-"$&-.0->A-\[\]-~]*|\.{0,2}[!-"$&--0->A-\[\]-~][!-"$&-.0->A-\[\]-~]*)?$
          type: string
        surface:
          description: >-
            The client purchasing: web opens a Stripe hosted checkout; ios and
            android create a store purchase intent.
          enum:
            - web
            - ios
            - android
          type: string
        tier:
          enum:
            - starter
            - pro
            - max
            - team
          type: string
      required:
        - checkout_type
        - surface
        - tier
      type: object
    BillingCheckoutSession:
      discriminator:
        mapping:
          credit_pack: '#/components/schemas/BillingCreditPackCheckoutSession'
          inference_topup: '#/components/schemas/BillingInferenceTopUpCheckoutSession'
          subscription: '#/components/schemas/BillingSubscriptionCheckoutSession'
        propertyName: checkout_type
      oneOf:
        - $ref: '#/components/schemas/BillingSubscriptionCheckoutSession'
        - $ref: '#/components/schemas/BillingCreditPackCheckoutSession'
        - $ref: '#/components/schemas/BillingInferenceTopUpCheckoutSession'
    BillingErrorResponse:
      additionalProperties: false
      properties:
        code:
          enum:
            - bad_gateway
            - bad_request
            - checkout_pending
            - cli_upgrade_required
            - client_outdated
            - conflict
            - enterprise_invoice
            - forbidden
            - free_tier
            - gateway_timeout
            - gone
            - internal_error
            - invalid_surface
            - managed_elsewhere
            - method_not_allowed
            - no_billing_history
            - not_acceptable
            - not_found
            - not_implemented
            - payment_delinquent
            - payment_required
            - personal_org_requires_personal_plan
            - precondition_failed
            - provider_unavailable
            - rate_limited
            - request_canceled
            - request_timeout
            - request_too_large
            - requires_org_admin
            - service_unavailable
            - subscription_active
            - subscription_pending
            - team_org_requires_team_plan
            - team_plan_web_only
            - team_seats_via_membership
            - unauthenticated
            - unsupported_media_type
            - validation_failed
            - warm_slot_occupied
            - web_only
          minLength: 1
          type: string
        error:
          minLength: 1
          type: string
        errors:
          items:
            $ref: '#/components/schemas/ErrorDetail'
          type: array
      required:
        - error
        - code
      type: object
    OrgAuthorizationErrorResponse:
      additionalProperties: false
      properties:
        code:
          enum:
            - org_membership_required
            - org_role_insufficient
            - org_suspended
            - account_deleting
            - agent_host_route_not_allowed
            - credential_kind_not_admitted
            - grant_scope_insufficient
          type: string
        error:
          minLength: 1
          type: string
      required:
        - error
        - code
      type: object
    BillingCreditPackCheckoutSession:
      additionalProperties: false
      properties:
        amount_usd:
          format: double
          type: number
        checkout_session_id:
          format: uuid
          type: string
        checkout_session_token:
          pattern: ^pcs_[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$
          type: string
        checkout_type:
          enum:
            - credit_pack
          type: string
        claimed_store_purchase:
          description: >-
            Present and true when binding the store transaction claimed the
            purchase the store had already reported: the intent completed and
            granted from it.
          type: boolean
        credit_pack_id:
          enum:
            - credits_100
            - credits_250
            - credits_500
            - credits_1000
          type: string
        credits:
          format: int64
          type: integer
        purchase_status:
          enum:
            - failed
            - granted
            - pending
            - pending_grant
          type: string
        status:
          enum:
            - created
            - completed
            - expired
            - failed
          type: string
        store_app_user_id:
          description: >-
            The store identity the device buys as. Present only when a store
            purchase intent is created.
          format: uuid
          type: string
        store_product_id:
          description: >-
            The store product the device buys. Present only when a store
            purchase intent is created.
          type: string
        url:
          description: >-
            The Stripe hosted checkout to open. Absent for a store purchase
            intent.
          type: string
      required:
        - checkout_session_id
        - checkout_session_token
        - checkout_type
        - status
        - purchase_status
        - credit_pack_id
        - credits
        - amount_usd
      type: object
    BillingInferenceTopUpCheckoutSession:
      additionalProperties: false
      properties:
        amount_usd:
          format: double
          type: number
        checkout_session_id:
          format: uuid
          type: string
        checkout_session_token:
          pattern: ^pcs_[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$
          type: string
        checkout_type:
          enum:
            - inference_topup
          type: string
        claimed_store_purchase:
          description: >-
            Present and true when binding the store transaction claimed the
            purchase the store had already reported: the intent completed and
            granted from it.
          type: boolean
        fee_usd:
          format: double
          type: number
        purchase_status:
          enum:
            - failed
            - granted
            - pending
            - pending_grant
          type: string
        status:
          enum:
            - created
            - completed
            - expired
            - failed
          type: string
        store_app_user_id:
          description: >-
            The store identity the device buys as. Present only when a store
            purchase intent is created.
          format: uuid
          type: string
        store_product_id:
          description: >-
            The store product the device buys. Present only when a store
            purchase intent is created.
          type: string
        url:
          description: >-
            The Stripe hosted checkout to open. Absent for a store purchase
            intent.
          type: string
      required:
        - checkout_session_id
        - checkout_session_token
        - checkout_type
        - status
        - purchase_status
        - amount_usd
        - fee_usd
      type: object
    BillingSubscriptionCheckoutSession:
      additionalProperties: false
      properties:
        checkout_session_id:
          format: uuid
          type: string
        checkout_session_token:
          pattern: ^pcs_[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$
          type: string
        checkout_type:
          enum:
            - subscription
          type: string
        claimed_store_purchase:
          description: >-
            Present and true when binding the store transaction claimed the
            purchase the store had already reported: the intent completed and
            granted from it.
          type: boolean
        status:
          enum:
            - created
            - completed
            - expired
            - failed
          type: string
        store_app_user_id:
          description: >-
            The store identity the device buys as. Present only when a store
            purchase intent is created.
          format: uuid
          type: string
        store_product_id:
          description: >-
            The store product the device buys. Present only when a store
            purchase intent is created.
          type: string
        subscription_status:
          enum:
            - active
            - failed
            - pending
            - pending_webhook
          type: string
        target_tier:
          enum:
            - starter
            - pro
            - max
            - team
          type: string
        url:
          description: >-
            The Stripe hosted checkout to open. Absent for a store purchase
            intent.
          type: string
      required:
        - checkout_session_id
        - checkout_session_token
        - checkout_type
        - status
        - target_tier
        - subscription_status
      type: object
    ErrorDetail:
      additionalProperties: false
      properties:
        location:
          description: >-
            Where the error occurred, e.g. 'body.items[3].tags' or
            'path.thing-id'
          type: string
        message:
          description: Error message text
          type: string
        value:
          description: The value at the given location
      type: object
  securitySchemes:
    bearerAuth:
      bearerFormat: JWT
      scheme: bearer
      type: http

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.