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

# Create Portal Session

> Creates a billing portal session for a customer. Returns a session URL that can be used to redirect the customer to the portal. > **Sibling endpoint**: tenants who have Chargebee Retention enabled (`retention_app_id` set on their config) should call [`POST /billing-portals/retention-sessions`](./create-retention-portal-session.md) for the cancel flow instead of passing `intent=cancel` here. The frontend reads the config to make this routing decision.



## OpenAPI

````yaml /openapi.json post /billing-portals/{provider_billing_portal_id}/sessions
openapi: 3.1.0
info:
  title: OpenLoop API
  version: 0.1.0
  description: >-
    Unified reference for the OpenLoop Patient (clinical) and Payments & Revenue
    APIs.
servers:
  - url: https://api.openloophealth.com/v0.1
    description: Production partner edge
  - url: https://api-staging.openloophealth.com/v0.1
    description: Staging partner edge (sandbox credentials)
security: []
paths:
  /billing-portals/{provider_billing_portal_id}/sessions:
    post:
      tags:
        - Billing Portals
      summary: Create Portal Session
      description: >-
        Creates a billing portal session for a customer. Returns a session URL
        that can be used to redirect the customer to the portal. > **Sibling
        endpoint**: tenants who have Chargebee Retention enabled
        (`retention_app_id` set on their config) should call [`POST
        /billing-portals/retention-sessions`](./create-retention-portal-session.md)
        for the cancel flow instead of passing `intent=cancel` here. The
        frontend reads the config to make this routing decision.
      parameters:
        - in: path
          name: provider_billing_portal_id
          required: true
          schema:
            type: string
          description: Portal configuration ID (e.g. `test_billing_portal_id`).
        - in: header
          name: Idempotency-Key
          required: false
          schema:
            type: string
          description: >-
            Deduplicates retried requests with the same key and parameters
            instead of creating a second resource. Recommended: an opaque,
            randomly-generated value such as a UUID.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                provider_customer_id:
                  type: string
                  description: Customer ID in the payment provider.
                intent:
                  type: string
                  description: >-
                    Portal intent (`cancel` or `other` per `PortalSessionIntent`
                    enum).
                provider_subscription_id:
                  type: string
                  description: Required when `intent` is `cancel`.
              required:
                - provider_customer_id
                - intent
            example:
              provider_customer_id: test_customer_id
              intent: cancel
              provider_subscription_id: test_subscription_id_2
      responses:
        '200':
          description: Success.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      url:
                        type: string
                        description: Portal session URL for client redirect.
                required:
                  - data
              example:
                data:
                  url: https://billing.stripe.com/session/xyz123abc456
        '400':
          description: >-
            ValidationError: Missing/invalid `provider_customer_id` or `intent`;
            missing `provider_subscription_id` when intent requires it.
        '401':
          description: Missing or invalid bearer token.
        '403':
          description: >-
            No configuration exists for your account, or provider access has
            been disabled for it.
        '404':
          description: 'NotFoundError: Billing portal or config not found.'
        '500':
          description: An upstream provider error.
      security:
        - serviceToken: []
        - userToken: []
components:
  securitySchemes:
    serviceToken:
      type: oauth2
      description: >-
        Service (M2M) access token issued by POST /auth/token using the
        client_credentials grant. Required scopes, where known, are listed on
        each operation below.
      flows:
        clientCredentials:
          tokenUrl: https://api.openloophealth.com/v0.1/auth/token
          scopes: {}
    userToken:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        User access token issued by POST /auth/token via the verification-code
        grant (after Verify a one-time code) or the refresh_token grant.

````

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