> ## 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 portal session

> Opens a Stripe billing portal session for the org and returns its URL: on the account overview, with the org's invoices and its subscription when it has one, or on the confirmation step of a plan change to target_tier.

Use this tool when you need to:
- Open the org's Stripe portal for its invoices and its Stripe subscription
- Change the org's Stripe subscription to another tier

Examples:
- POST /orgs/{orgID}/billing/portal-sessions {"request_id": "portal-6f1c2a9e"}
- POST /orgs/{orgID}/billing/portal-sessions {"request_id": "portal-6f1c2a9f", "target_tier": "max"}

Hints:
- orgID is the org's uuid; request_id is required, 1 to 128 letters, digits, - or _ (422 from the schema otherwise), and is the idempotency key of the Stripe request for this org, so send a new one for each portal visit. target_tier is optional: starter, pro, max or team (422 from the schema otherwise).
- Answers 201 with url, the portal to open. The request takes no surface: availability is judged as on the web.
- Without target_tier the org needs view_billing_history: one that never had a Stripe customer is refused with 409 no_billing_history. With target_tier it needs change_plan: 409 free_tier without a paid subscription, managed_elsewhere for a subscription the App Store or Play Store manages, team_seats_via_membership for a team org, and 409 when the subscription is already on that tier.
- A team org's target_tier is refused with 409 team_seats_via_membership before its plan is checked, so of the plan refusals only 422 personal_org_requires_personal_plan, target_tier team on a personal org, is answered. 404 for an org without billing; 502 when Stripe fails.
- Use createBillingCheckoutSession instead to start a subscription for an org without one, and getBillingSubscription to read change_plan and view_billing_history first.
- 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 validated, 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/portal-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/portal-sessions:
    post:
      tags:
        - billing
      summary: Create billing portal session
      description: >-
        Opens a Stripe billing portal session for the org and returns its URL:
        on the account overview, with the org's invoices and its subscription
        when it has one, or on the confirmation step of a plan change to
        target_tier.


        Use this tool when you need to:

        - Open the org's Stripe portal for its invoices and its Stripe
        subscription

        - Change the org's Stripe subscription to another tier


        Examples:

        - POST /orgs/{orgID}/billing/portal-sessions {"request_id":
        "portal-6f1c2a9e"}

        - POST /orgs/{orgID}/billing/portal-sessions {"request_id":
        "portal-6f1c2a9f", "target_tier": "max"}


        Hints:

        - orgID is the org's uuid; request_id is required, 1 to 128 letters,
        digits, - or _ (422 from the schema otherwise), and is the idempotency
        key of the Stripe request for this org, so send a new one for each
        portal visit. target_tier is optional: starter, pro, max or team (422
        from the schema otherwise).

        - Answers 201 with url, the portal to open. The request takes no
        surface: availability is judged as on the web.

        - Without target_tier the org needs view_billing_history: one that never
        had a Stripe customer is refused with 409 no_billing_history. With
        target_tier it needs change_plan: 409 free_tier without a paid
        subscription, managed_elsewhere for a subscription the App Store or Play
        Store manages, team_seats_via_membership for a team org, and 409 when
        the subscription is already on that tier.

        - A team org's target_tier is refused with 409 team_seats_via_membership
        before its plan is checked, so of the plan refusals only 422
        personal_org_requires_personal_plan, target_tier team on a personal org,
        is answered. 404 for an org without billing; 502 when Stripe fails.

        - Use createBillingCheckoutSession instead to start a subscription for
        an org without one, and getBillingSubscription to read change_plan and
        view_billing_history first.

        - 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 validated, 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: createBillingPortalSession
      parameters:
        - in: path
          name: orgID
          required: true
          schema:
            format: uuid
            type: string
      requestBody:
        content:
          application/json:
            schema:
              additionalProperties: false
              properties:
                request_id:
                  pattern: ^[A-Za-z0-9_-]{1,128}$
                  type: string
                target_tier:
                  description: >-
                    Open the portal on the confirmation step for switching the
                    active paid subscription to this tier.
                  enum:
                    - starter
                    - pro
                    - max
                    - team
                  type: string
              required:
                - request_id
              type: object
        required: true
      responses:
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BillingPortalSession'
          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
        '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:
    BillingPortalSession:
      additionalProperties: false
      properties:
        url:
          type: string
      required:
        - url
      type: object
    BillingErrorResponse:
      additionalProperties: false
      properties:
        code:
          enum:
            - bad_gateway
            - bad_request
            - checkout_pending
            - 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
    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.