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

# Create Stripe Customer Portal Session

> Create a Stripe Billing Portal Session for an authenticated user's mapped billing subject.



## OpenAPI

````yaml https://raw.githubusercontent.com/InsForge/InsForge/main/openapi/payments.yaml post /api/payments/stripe/{environment}/customer-portal-sessions
openapi: 3.0.3
info:
  title: Insforge Payments API
  version: 1.0.0
  description: >-
    Provider-specific Stripe and Razorpay payment setup, runtime flows, catalog
    management, sync, and webhook projections
servers: []
security: []
tags:
  - name: Stripe Payments
    description: >-
      Stripe Checkout, Billing Portal, catalog, sync, customer, subscription,
      and transaction routes
  - name: Razorpay Payments
    description: >-
      Razorpay Orders, Subscriptions, catalog, manual webhook setup, sync,
      customer, and transaction routes
  - name: Payment Webhooks
    description: Provider webhook ingestion routes
paths:
  /api/payments/stripe/{environment}/customer-portal-sessions:
    post:
      tags:
        - Stripe Payments
      summary: Create Stripe Customer Portal Session
      description: >-
        Create a Stripe Billing Portal Session for an authenticated user's
        mapped billing subject.
      parameters:
        - $ref: '#/components/parameters/EnvironmentPath'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateCustomerPortalSessionBody'
            example:
              subject:
                type: team
                id: team_123
              returnUrl: https://app.example.com/billing
      responses:
        '201':
          description: Customer Portal Session created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateCustomerPortalSessionResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '500':
          $ref: '#/components/responses/InternalError'
      security:
        - bearerAuth: []
components:
  parameters:
    EnvironmentPath:
      name: environment
      in: path
      required: true
      schema:
        $ref: '#/components/schemas/PaymentEnvironment'
      description: Payment provider environment.
  schemas:
    CreateCustomerPortalSessionBody:
      type: object
      required:
        - subject
      additionalProperties: false
      properties:
        subject:
          $ref: '#/components/schemas/BillingSubject'
        returnUrl:
          type: string
          format: uri
        configuration:
          type: string
          minLength: 1
          maxLength: 255
    CreateCustomerPortalSessionResponse:
      type: object
      required:
        - customerPortalSession
      properties:
        customerPortalSession:
          $ref: '#/components/schemas/CustomerPortalSession'
    PaymentEnvironment:
      type: string
      enum:
        - test
        - live
    BillingSubject:
      type: object
      required:
        - type
        - id
      additionalProperties: false
      properties:
        type:
          type: string
          minLength: 1
          maxLength: 100
          example: team
        id:
          type: string
          minLength: 1
          maxLength: 255
          example: team_123
    CustomerPortalSession:
      type: object
      required:
        - id
        - environment
        - status
        - subjectType
        - subjectId
        - customerId
        - returnUrl
        - configuration
        - url
        - lastError
        - createdAt
        - updatedAt
      properties:
        id:
          type: string
          format: uuid
        environment:
          $ref: '#/components/schemas/StripeEnvironment'
        status:
          $ref: '#/components/schemas/CustomerPortalSessionStatus'
        subjectType:
          type: string
        subjectId:
          type: string
        customerId:
          type: string
          nullable: true
          example: cus_123
        returnUrl:
          type: string
          nullable: true
          example: https://app.example.com/billing
        configuration:
          type: string
          nullable: true
        url:
          type: string
          nullable: true
          example: https://billing.stripe.com/p/session/test_123
        lastError:
          type: string
          nullable: true
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
    ErrorResponse:
      type: object
      required:
        - error
        - message
        - statusCode
      properties:
        error:
          type: string
          example: INVALID_INPUT
        message:
          type: string
          example: 'environment: Invalid enum value'
        statusCode:
          type: integer
          example: 400
        nextActions:
          type: string
          nullable: true
    StripeEnvironment:
      $ref: '#/components/schemas/PaymentEnvironment'
    CustomerPortalSessionStatus:
      type: string
      enum:
        - initialized
        - created
        - failed
  responses:
    BadRequest:
      description: Invalid request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Unauthorized:
      description: Unauthorized
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Forbidden:
      description: Forbidden
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    NotFound:
      description: Resource not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    InternalError:
      description: Internal server error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````