Casama AI Billing API

The billing API from Casama AI, for billing.

GitHub OpenAPI
Pull this API's OpenAPI, operations, scores and pricing into your own code or AI agent with a free APIs.io key — sign in with GitHub, Google or LinkedIn. No form to fill in; signing in shares your email address with us (Privacy).

Operations 11

GET /v1/billing/plans Plans and credit packs on this server #
GET /v1/orgs/{id}/billing The workspace's plan, entitlement, subscriptions and credits #
POST /v1/orgs/{id}/billing/preview Preview the immediate charge and renewal price for changing an active web… #
POST /v1/orgs/{id}/billing/checkout Start a web checkout (Dodo Payments) for a plan or credit pack #
POST /v1/orgs/{id}/billing/portal Open the customer portal for a web subscription #
PUT /v1/orgs/{id}/billing/seats Pay for more or fewer people than the plan includes (web subscriptions on Pro… #
POST /v1/orgs/{id}/billing/purchases Verify an App Store or Google Play purchase (also used by Restore Purchases) #
GET /v1/orgs/{id}/billing/usage This month's bill: billable usage by kind and instance, and recent credit… #
GET /v1/orgs/{id}/link/keys Casama Link keys for self-hosted instances #
POST /v1/orgs/{id}/link/keys Create a Casama Link key (shown once) #
DELETE /v1/orgs/{id}/link/keys/{key_id} Revoke link key #

Work with this as data

Every API here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for apis

7 MCP tools reach this
  • find_apisBrowse and filter every API in the catalog.
  • get_api_artifactsOne API's artifacts, grouped by type.
  • get_openapiThe primary OpenAPI for this API.
  • find_similar_apisAPIs that look like this one.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This API
curl "https://apis.io/api/v1/apis/casama-ai:casama-ai-billing-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. By signing up you are subscribing to the APIs.io and API Evangelist newsletters — you can unsubscribe from any issue. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.

OpenAPI Specification

casama-ai-billing-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  title: Casama Billing API
  version: 0.1.0
  license:
    name: Apache-2.0
    url: https://www.apache.org/licenses/LICENSE-2.0
servers:
- url: http://api.casama.ai
tags:
- name: Billing
paths:
  /v1/billing/plans:
    get:
      operationId: listPlans
      tags:
      - Billing
      security:
      - bearerAuth: []
      summary: Plans and credit packs on this server
      parameters:
      - schema:
          type: string
          maxLength: 64
        required: false
        name: periods
        in: query
      responses:
        '200':
          description: Catalog
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PlanCatalog'
        '401':
          description: Not authenticated
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
  /v1/orgs/{id}/billing:
    get:
      operationId: getBilling
      tags:
      - Billing
      security:
      - bearerAuth: []
      summary: The workspace's plan, entitlement, subscriptions and credits
      parameters:
      - schema:
          type: string
          format: uuid
        required: true
        name: id
        in: path
      responses:
        '200':
          description: Billing
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BillingSummary'
        '401':
          description: Not authenticated
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
        '404':
          description: Not found
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
  /v1/orgs/{id}/billing/preview:
    post:
      operationId: previewPlanChange
      tags:
      - Billing
      security:
      - bearerAuth: []
      summary: Preview the immediate charge and renewal price for changing an active web…
      parameters:
      - schema:
          type: string
          format: uuid
        required: true
        name: id
        in: path
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PlanChangePreviewRequest'
      responses:
        '200':
          description: Plan change preview
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PlanChangePreview'
        '400':
          description: Validation failed
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
        '401':
          description: Not authenticated
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
        '403':
          description: Forbidden
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
        '409':
          description: Conflict
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
  /v1/orgs/{id}/billing/checkout:
    post:
      operationId: createCheckout
      tags:
      - Billing
      security:
      - bearerAuth: []
      summary: Start a web checkout (Dodo Payments) for a plan or credit pack
      description: 'The server doesn''t know which device asks. Store rules are the client''s to follow: an Android app must not offer web checkout (Google Play billing only), and an iPhone, iPad or Mac App Store app only on the US storefront.'
      parameters:
      - schema:
          type: string
          format: uuid
        required: true
        name: id
        in: path
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CheckoutRequest'
      responses:
        '200':
          description: Checkout page, or the plan changed in place
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CheckoutResult'
        '400':
          description: Validation failed
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
        '401':
          description: Not authenticated
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
        '403':
          description: Forbidden
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
        '409':
          description: Conflict
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
  /v1/orgs/{id}/billing/portal:
    post:
      operationId: billingPortal
      tags:
      - Billing
      security:
      - bearerAuth: []
      summary: Open the customer portal for a web subscription
      parameters:
      - schema:
          type: string
          format: uuid
        required: true
        name: id
        in: path
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PortalRequest'
      responses:
        '200':
          description: Portal
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RedirectUrl'
        '401':
          description: Not authenticated
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
        '403':
          description: Forbidden
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
        '409':
          description: Conflict
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
  /v1/orgs/{id}/billing/seats:
    put:
      operationId: setBillingSeats
      tags:
      - Billing
      security:
      - bearerAuth: []
      summary: Pay for more or fewer people than the plan includes (web subscriptions on Pro…
      parameters:
      - schema:
          type: string
          format: uuid
        required: true
        name: id
        in: path
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SeatsRequest'
      responses:
        '200':
          description: Billing after the change
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BillingSummary'
        '400':
          description: Validation failed
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
        '401':
          description: Not authenticated
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
        '403':
          description: Forbidden
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
        '409':
          description: Conflict
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
  /v1/orgs/{id}/billing/purchases:
    post:
      operationId: verifyPurchase
      tags:
      - Billing
      security:
      - bearerAuth: []
      summary: Verify an App Store or Google Play purchase (also used by Restore Purchases)
      parameters:
      - schema:
          type: string
          format: uuid
        required: true
        name: id
        in: path
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PurchaseRequest'
      responses:
        '200':
          description: Billing after the purchase
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BillingSummary'
        '400':
          description: Validation failed
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
        '401':
          description: Not authenticated
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
        '403':
          description: Forbidden
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
        '409':
          description: Conflict
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
  /v1/orgs/{id}/billing/usage:
    get:
      operationId: billingUsage
      tags:
      - Billing
      security:
      - bearerAuth: []
      summary: 'This month''s bill: billable usage by kind and instance, and recent credit…'
      parameters:
      - schema:
          type: string
          format: uuid
        required: true
        name: id
        in: path
      responses:
        '200':
          description: Usage
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BillingUsage'
        '401':
          description: Not authenticated
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
        '404':
          description: Not found
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
  /v1/orgs/{id}/link/keys:
    get:
      operationId: listLinkKeys
      tags:
      - Billing
      security:
      - bearerAuth: []
      summary: Casama Link keys for self-hosted instances
      parameters:
      - schema:
          type: string
          format: uuid
        required: true
        name: id
        in: path
      responses:
        '200':
          description: Keys
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LinkKeyList'
        '401':
          description: Not authenticated
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
        '403':
          description: Forbidden
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
    post:
      operationId: createLinkKey
      tags:
      - Billing
      security:
      - bearerAuth: []
      summary: Create a Casama Link key (shown once)
      parameters:
      - schema:
          type: string
          format: uuid
        required: true
        name: id
        in: path
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateLinkKeyRequest'
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreatedLinkKey'
        '400':
          description: Validation failed
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
        '401':
          description: Not authenticated
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
        '403':
          description: Forbidden
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
        '409':
          description: Conflict
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
  /v1/orgs/{id}/link/keys/{key_id}:
    delete:
      operationId: revokeLinkKey
      tags:
      - Billing
      security:
      - bearerAuth: []
      parameters:
      - schema:
          type: string
          format: uuid
        required: true
        name: id
        in: path
      - schema:
          type: string
          format: uuid
        required: true
        name: key_id
        in: path
      responses:
        '200':
          description: Revoked
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RevokedLinkKey'
        '401':
          description: Not authenticated
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
        '403':
          description: Forbidden
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
        '404':
          description: Not found
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
      summary: Revoke link key
      x-summary-source: derived
components:
  schemas:
    PlanChangePreview:
      type: object
      properties:
        plan_code:
          type: string
        plan_name:
          type: string
        interval:
          type: string
          enum:
          - week
          - month
          - year
        currency:
          type: string
          description: ISO 4217 currency code (e.g. USD)
        immediate_total:
          type: integer
          description: Total charged now including tax, in minor units (e.g. cents)
        immediate_tax:
          type: integer
          description: Tax included in immediate_total, in minor units
        credit:
          type: integer
          description: Credit for the unused part of the current period, in minor units
        recurring_pre_tax:
          type: integer
          description: Renewal price before tax, in minor units
        next_billing_date:
          type:
          - string
          - 'null'
          format: date-time
        discount_applied:
          type: boolean
        discount_code:
          type:
          - string
          - 'null'
        discount_percent:
          type:
          - number
          - 'null'
          description: Percentage off (e.g. 25 for 25% off) when a percentage code applies
        discount_amount:
          type:
          - integer
          - 'null'
          description: What a flat code takes off the renewal price, in minor units of `currency` (the difference between the renewal price without and with it)
        discount_cycles:
          type:
          - integer
          - 'null'
          description: Number of renewals the code applies to; null means every renewal
        discount_preserved:
          type: boolean
          description: Whether the discount stays on later plan changes. When false, it ends if the plan changes again
        replaces_discount:
          type: boolean
          description: The code replaces a discount the subscription keeps today (Dodo's `discount_codes` replaces them)
        replaced_discount_percent:
          type:
          - number
          - 'null'
          description: The replaced discount's percentage, when it was a percentage discount
      required:
      - plan_code
      - plan_name
      - interval
      - currency
      - immediate_total
      - immediate_tax
      - credit
      - recurring_pre_tax
      - next_billing_date
      - discount_applied
    CheckoutRequest:
      type: object
      properties:
        plan_code:
          type: string
        pack_code:
          type: string
        return_url:
          type: string
          format: uri
        discount_code:
          type: string
          pattern: ^[A-Za-z0-9_-]{3,64}$
          description: Discount code (case-insensitive, 3–64 letters, digits, hyphens or underscores)
        expected_total:
          type: integer
          description: Immediate total from preview, in minor units (e.g. cents)
        expected_currency:
          type: string
          minLength: 3
          maxLength: 3
          description: ISO 4217 currency code matching expected_total (e.g. USD)
        new_subscription_only:
          type: boolean
          description: Only start a new subscription. When the workspace already has one, answer 409 subscription_exists instead of changing it (the app previews first)
    CheckoutResult:
      type: object
      properties:
        url:
          type: string
          format: uri
        changed:
          type: boolean
      required:
      - url
    RevokedLinkKey:
      type: object
      properties:
        revoked:
          type: string
          format: uuid
      required:
      - revoked
    CreditEntry:
      type: object
      properties:
        delta:
          type: number
        reason:
          type: string
        note:
          type:
          - string
          - 'null'
        balance_after:
          type: number
        created_at:
          type: string
          format: date-time
      required:
      - delta
      - reason
      - note
      - balance_after
      - created_at
    LinkKeyList:
      type: object
      properties:
        items:
          type: array
          items:
            $ref: '#/components/schemas/LinkKey'
      required:
      - items
    BillingSource:
      type: string
      enum:
      - dodo
      - app_store
      - google_play
    CreateLinkKeyRequest:
      type: object
      properties:
        instance_name:
          type: string
          minLength: 1
          maxLength: 80
        scopes:
          type: array
          items:
            type: string
            enum:
            - computers
            - models
            - remote_access
            - push
          minItems: 1
      required:
      - instance_name
    SavedLimitReset:
      type: object
      properties:
        id:
          type: string
          format: uuid
        campaign_id:
          type:
          - string
          - 'null'
          format: uuid
        message:
          type: string
        expires_at:
          type: string
          format: date-time
        refill_usd:
          type: number
          minimum: 0
          maximum: 1000000
        reset_daily:
          type: boolean
        reset_computer:
          type: boolean
        can_use:
          type: boolean
        unavailable_reason:
          type:
          - string
          - 'null'
          description: 'Why it can''t be used now: owner_required, paused, period_limit, budget, nothing_to_refill or no_billing_period; null when it can'
      required:
      - id
      - campaign_id
      - message
      - expires_at
      - refill_usd
      - reset_daily
      - reset_computer
      - can_use
      - unavailable_reason
    PurchaseRequest:
      type: object
      properties:
        source:
          type: string
          enum:
          - app_store
          - google_play
        product_id:
          type: string
          minLength: 1
        transaction_id:
          type: string
          description: App Store transaction id
        purchase_token:
          type: string
          description: Google Play purchase token
      required:
      - source
      - product_id
    LinkKey:
      type: object
      properties:
        id:
          type: string
          format: uuid
        instance_name:
          type: string
        key_hint:
          type: string
        scopes:
          type: array
          items:
            type: string
        last_used_at:
          type:
          - string
          - 'null'
          format: date-time
        created_at:
          type: string
          format: date-time
      required:
      - id
      - instance_name
      - key_hint
      - scopes
      - last_used_at
      - created_at
    BillingUsageItem:
      type: object
      properties:
        kind:
          type: string
        instance:
          type:
          - string
          - 'null'
          description: Casama Link instance, if any
        quantity:
          type: number
        cost_usd:
          type: number
      required:
      - kind
      - instance
      - quantity
      - cost_usd
    CreditPack:
      type: object
      properties:
        code:
          type: string
        name:
          type: string
        credits_usd:
          type: number
        web:
          type: boolean
        price_label:
          type:
          - string
          - 'null'
        store_product_ids:
          type: object
          additionalProperties:
            type: string
      required:
      - code
      - name
      - credits_usd
      - web
    PlanChangePreviewRequest:
      type: object
      properties:
        plan_code:
          type: string
          minLength: 1
        discount_code:
          type: string
          pattern: ^[A-Za-z0-9_-]{3,64}$
          description: Discount code (case-insensitive, 3–64 letters, digits, hyphens or underscores)
      required:
      - plan_code
    Plan:
      type: object
      properties:
        code:
          type: string
        name:
          type: string
        interval:
          type: string
          enum:
          - none
          - week
          - month
          - year
        limits:
          type: object
          additionalProperties:
            type: number
        price_label:
          type:
          - string
          - 'null'
        web:
          type: boolean
        store_product_ids:
          type: object
          additionalProperties:
            type: string
        paywall_default:
          type: boolean
        paywall_popular:
          type: boolean
      required:
      - code
      - name
      - interval
      - limits
      - price_label
      - web
      - store_product_ids
    RedirectUrl:
      type: object
      properties:
        url:
          type: string
          format: uri
      required:
      - url
    Problem:
      type: object
      properties:
        type:
          type: string
          example: https://casama.ai/problems/not_found
        title:
          type: string
        status:
          type: integer
        code:
          type: string
          description: Stable error code
          example: not_found
        detail:
          type: string
        instance:
          type: string
        errors:
          type: array
          items:
            type: object
            properties:
              path:
                type: string
              message:
                type: string
            required:
            - path
            - message
          description: Field errors for validation_failed
      required:
      - type
      - title
      - status
      - code
    CreatedLinkKey:
      allOf:
      - $ref: '#/components/schemas/LinkKey'
      - type: object
        properties:
          key:
            type: string
            description: Shown once; set it as CASAMA_CLOUD_KEY
        required:
        - key
    BillingSummary:
      type: object
      properties:
        enabled:
          type: boolean
          description: 'False on self-hosted servers: no paywall'
        plan_code:
          type: string
        plan_name:
          type: string
        interval:
          type: string
        limits:
          type: object
          additionalProperties:
            type: number
        unlimited:
          type: boolean
        valid_until:
          type:
          - string
          - 'null'
          format: date-time
        source:
          type: string
          enum:
          - default
          - dodo
          - app_store
          - google_play
        cancel_at_period_end:
          type: boolean
        extra_seats:
          type: integer
          description: People paid for beyond the plan's seats (D-249)
        trial_available:
          type: boolean
          description: The owner can still start a plan's free trial (D-249)
        resets:
          type: array
          items:
            $ref: '#/components/schemas/SavedLimitReset'
        credits_usd:
          type: number
        daily:
          type:
          - object
          - 'null'
          properties:
            used_usd:
              type: number
              description: Spent today (UTC) on the server's keys
            cap_usd:
              type: number
              description: The plan's daily cap on the server's keys
            resets_at:
              type: string
              format: date-time
              description: Next midnight UTC, when the day's spend resets
          required:
          - used_usd
          - cap_usd
          - resets_at
          description: Today's spend against the plan's daily cap; runs stop when it is reached (D-311). Null when no cap applies
        computer_hours:
          type:
          - object
          - 'null'
          properties:
            used_hours:
              type: number
              description: Hosted computer hours used this month (UTC)
            limit_hours:
              type: number
              description: The plan's computer hours a month
            resets_at:
              type: string
              format: date-time
              description: The first of next month (UTC), when the hours reset
          required:
          - used_hours
          - limit_hours
          - resets_at
          description: This month's hosted computer hours against the plan's. Past them only computers stop; chat keeps running on credits (D-442). Null when no limit applies
        sandbox:
          type: boolean
          description: 'The plan was bought with a store test account (TestFlight, App Review, Play license testers): it has tester limits (docs/SANDBOX-LIMITS-PLAN.md)'
        comp:
          type:
          - object
          - 'null'
          properties:
            plan_code:
              type: string
            ends_at:
              type: string
              format: date-time
            from:
              type: string
              enum:
              - grant
              - code
            keep_from:
              type: string
              format: date-time
              description: From this moment the comped plan can be bought to keep it
          required:
          - plan_code
          - ends_at
          - from
          - keep_from
          description: A plan given free by Casama, while it runs (docs/COMP-PLANS-PLAN.md). `source` then says default, for older apps
        casama_models:
          type: string
          enum:
          - 'on'
          - 'off'
          description: Whether Casama's own model keys are available on this workspace's plan (docs/OWN-KEYS-PLAN.md §6)
        casama_models_note:
          type:
          - string
          - 'null'
          description: Optional note from the instance owner when Casama's models are turned off (§3.3)
        subscriptions:
          type: array
          items:
            $ref: '#/components/schemas/Subscription'
        providers:
          type: array
          items:
            $ref: '#/components/schemas/BillingSource'
      required:
      - enabled
      - plan_code
      - plan_name
      - interval
      - limits
      - unlimited
      - valid_until
      - source
      - cancel_at_period_end
      - credits_usd
      - subscriptions
      - providers
    PortalRequest:
      type: object
      properties:
        return_url:
          type: string
          format: uri
    BillingUsage:
      type: object
      properties:
        period_start:
          type: string
          format: date-time
        items:
          type: array
          items:
            $ref: '#/components/schemas/BillingUsageItem'
        total_usd:
          type: number
        credits:
          type: array
          items:
            $ref: '#/components/schemas/CreditEntry'
      required:
      - period_start
      - items
      - total_usd
      - credits
    PlanCatalog:
      type: object
      properties:
        enabled:
          type: boolean
        plans:
          type: array
          items:
            $ref: '#/components/schemas/Plan'
        packs:
          type: array
          items:
            $ref: '#/components/schemas/CreditPack'
      required:
      - enabled
      - plans
      - packs
    Subscription:
      type: object
      properties:
        id:
          type: string
          format: uuid
        source:
          $ref: '#/components/schemas/BillingSource'
        plan_code:
          type: string
        status:
          type: string
        current_period_end:
          type:
          - string
          - 'null'
          format: date-time
        cancel_at_period_end:
          type: boolean
      required:
      - id
      - source
      - plan_code
      - status
      - current_period_end
      - cancel_at_period_end
    SeatsRequest:
      type: object
      properties:
        extra:
          type: integer
          minimum: 0
          maximum: 100
          description: People to pay for beyond the plan's seats
      required:
      - extra
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Supabase access token