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

# Downgrade to Free

> New seed and test generation stops at once, and every live environment gets the Free plan's deadline, counted from now. Requires the **admin** role.



## OpenAPI

````yaml https://api.twinbay.ai/openapi.json post /organizations/current/billing/downgrade
openapi: 3.1.0
info:
  title: Twinbay
  description: Backend API
  version: 0.1.0
servers:
  - url: https://api.twinbay.ai
    description: Production
security: []
tags:
  - name: healthchecks
    description: Healthcheck endpoints
  - name: users
    description: >-
      The current user. Sign-up and sign-in happen in WorkOS AuthKit, which
      issues the access tokens this API accepts.
  - name: organizations
    description: >-
      Organizations the caller belongs to. Every authenticated request acts
      inside exactly one organization — the one its access token names — so
      these routes address it as `current`.
  - name: billing
    description: >-
      The active organization's plan, its limits, and what the current period
      has cost so far.
  - name: api-keys
    description: >-
      Long-lived credentials for callers that cannot hold an AuthKit session —
      agents, SDKs, CI. A key is accepted wherever an access token is, and acts
      with the role its creator holds when the request arrives.
  - name: environments
    description: >-
      Create and edit isolated provider environments. Each environment contains
      behavioural twins from the `twins` package.
  - name: twins
    description: Manage provisioned twins by their IDs.
  - name: catalog
    description: Browse the digital twins available for new environments.
  - name: scenarios
    description: Reusable starting setups of provider twins and optional seeds.
  - name: seeds
    description: >-
      Starting states for a twin. Describe the data you want in your own words,
      and a worker expands it into rows once; pass the seed's id when you create
      an environment to start a twin holding it.
  - name: tests
    description: >-
      Outcomes described in natural language, compiled once into request
      matchers, and evaluated deterministically against the traffic an attempt
      was served.
paths:
  /organizations/current/billing/downgrade:
    post:
      tags:
        - billing
      summary: Downgrade to Free
      description: >-
        New seed and test generation stops at once, and every live environment
        gets the Free plan's deadline, counted from now. Requires the **admin**
        role.
      operationId: downgrade_billing_plan
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BillingResponse'
        '401':
          description: The credential is missing, malformed, expired, or not trusted
        '403':
          description: The caller is not an admin, or is an API key
      security:
        - Access token: []
        - Organization API key: []
components:
  schemas:
    BillingResponse:
      properties:
        plan:
          type: string
          enum:
            - free
            - paygo
          title: Plan
        max_environment_seconds:
          anyOf:
            - type: integer
            - type: 'null'
          title: Max Environment Seconds
          description: How long an environment may run, or null for no limit
        max_parallel_twins:
          anyOf:
            - type: integer
            - type: 'null'
          title: Max Parallel Twins
          description: How many twins may run at once, or null for no limit
        ai_generation_enabled:
          type: boolean
          title: Ai Generation Enabled
          description: Whether seeds, generated tests and evaluators can be built
        active_twins:
          type: integer
          title: Active Twins
          description: Twins currently asked to run
        ready:
          type: boolean
          title: Ready
          description: Whether the billing account is set up; plan changes wait for it
        upgrade_available:
          type: boolean
          title: Upgrade Available
          description: Whether this deployment can take a card for pay as you go
        remaining_credit_cents:
          anyOf:
            - type: number
            - type: 'null'
          title: Remaining Credit Cents
          description: >-
            Spendable USD credit after current draft invoice deductions. Null
            while billing is unreachable or not yet set up.
        invoice:
          anyOf:
            - $ref: '#/components/schemas/InvoicePreview'
            - type: 'null'
          description: >-
            The draft invoice for the current period, updated as usage arrives.
            Null while billing is unreachable or not yet set up.
      type: object
      required:
        - plan
        - max_environment_seconds
        - max_parallel_twins
        - ai_generation_enabled
        - active_twins
        - ready
        - upgrade_available
      title: BillingResponse
    InvoicePreview:
      properties:
        period_start:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Period Start
        period_end:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Period End
        total_cents:
          type: number
          title: Total Cents
          description: What is due, after credits
        credits_applied_cents:
          type: number
          title: Credits Applied Cents
          description: Credit drawn down against this period's usage
          default: 0
        line_items:
          items:
            $ref: '#/components/schemas/InvoiceLineItem'
          type: array
          title: Line Items
      type: object
      required:
        - period_start
        - period_end
        - total_cents
        - line_items
      title: InvoicePreview
    InvoiceLineItem:
      properties:
        name:
          type: string
          title: Name
          description: The product this line charges for
        twin:
          anyOf:
            - type: string
            - type: 'null'
          title: Twin
          description: The twin the line is itemized by, if any
        quantity:
          anyOf:
            - type: number
            - type: 'null'
          title: Quantity
          description: Twin-hours for runtime, builds otherwise
        unit_price_cents:
          anyOf:
            - type: number
            - type: 'null'
          title: Unit Price Cents
        total_cents:
          type: number
          title: Total Cents
      type: object
      required:
        - name
        - total_cents
      title: InvoiceLineItem
  securitySchemes:
    Access token:
      type: http
      description: Access token issued by WorkOS AuthKit.
      scheme: bearer
    Organization API key:
      type: apiKey
      description: >-
        An organization API key. Create one at
        https://console.twinbay.ai/api-keys
      in: header
      name: X-API-Key

````

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