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

# Create a billing portal session

> Creates a Stripe-hosted billing portal session for an organization and returns its URL. The caller must be an admin of the organization named in the path: an admin of a different organization is refused, as are API keys and service credentials. The portal exposes invoices and payment methods and can change the subscription, so it is a person's surface and there is no machine credential that opens one.



## OpenAPI

````yaml /api-reference/billing.openapi.json post /v1/billing/organizations/{org_id}/portal-session
openapi: 3.1.0
info:
  title: billing
  description: ''
  license:
    name: ''
  version: 0.1.0
servers:
  - url: https://api.anthid.com
    description: Production
security: []
tags:
  - name: Billing
    description: Read organization billing access and open the customer portal
  - name: Billing
    description: Grant, change, or withdraw entitlements beyond an organization's plan
  - name: Billing
    description: Receive signed Stripe events for asynchronous processing
paths:
  /v1/billing/organizations/{org_id}/portal-session:
    post:
      tags:
        - Billing
      summary: Create a billing portal session
      description: >-
        Creates a Stripe-hosted billing portal session for an organization and
        returns its URL. The caller must be an admin of the organization named
        in the path: an admin of a different organization is refused, as are API
        keys and service credentials. The portal exposes invoices and payment
        methods and can change the subscription, so it is a person's surface and
        there is no machine credential that opens one.
      operationId: createBillingPortalSession
      parameters:
        - name: org_id
          in: path
          description: Organization ID
          required: true
          schema:
            type: string
            format: uuid
          example: 11111111-2222-3333-4444-555555555555
      requestBody:
        description: >-
          Return URL where Stripe should send the user after they leave the
          billing portal
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GetPortalSessionRequest'
            example:
              return_url: https://app.anthid.com/settings/billing
        required: true
      responses:
        '200':
          description: Billing portal session created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetPortalSessionResponse'
              example:
                url: https://billing.stripe.com/p/session/test_123
        '400':
          description: '`return_url` is missing or blank'
          content:
            text/plain:
              schema:
                type: string
        '401':
          description: Missing or invalid authentication credentials
          content:
            text/plain:
              schema:
                type: string
        '403':
          description: >-
            Caller is not an organization admin, is an admin of a different
            organization than the one in the path, has no active organization,
            or is an API key or service credential
          content:
            text/plain:
              schema:
                type: string
        '404':
          description: No billing identity exists for the organization
          content:
            text/plain:
              schema:
                type: string
        '429':
          description: Caller exceeded the request rate limit
          content:
            text/plain:
              schema:
                type: string
        '500':
          description: Unexpected server error while creating the billing portal session
          content:
            text/plain:
              schema:
                type: string
      security:
        - bearerAuth: []
components:
  schemas:
    GetPortalSessionRequest:
      type: object
      required:
        - return_url
      properties:
        return_url:
          type: string
          description: >-
            Where Stripe should send the user after they exit the customer
            portal.
          example: https://app.anthid.com/settings/billing
    GetPortalSessionResponse:
      type: object
      required:
        - url
      properties:
        url:
          type: string
          description: Stripe-hosted customer portal session URL.
          example: https://billing.stripe.com/p/session/test_123
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````