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

# Generate a portal token for a customer

> Generates a JWT token that grants access to the customer portal.
The token can be used to access invoices, payment methods, and other portal features.



## OpenAPI

````yaml https://api.meteroid.com/api-docs/openapi.json post /api/v1/customers/{id_or_alias}/portal-token
openapi: 3.1.0
info:
  title: meteroid
  description: ''
  license:
    name: LicenseRef-Proprietary
    identifier: LicenseRef-Proprietary
  version: 0.1.0
servers: []
security: []
tags:
  - name: Meteroid
    description: Meteroid API
  - name: Add-ons
  - name: Batch Jobs
  - name: Checkout Sessions
  - name: Connect
    description: Manage connected accounts (Express & Standard)
  - name: Coupons
  - name: Credit Notes
  - name: Customers
  - name: Entitlements
  - name: Events
  - name: Features
  - name: Invoices
  - name: Metrics
  - name: OAuth
    description: OAuth 2.0 token endpoints (public, client-credentials auth)
  - name: OAuth Apps
    description: Manage OAuth applications for Connect integrations
  - name: Plans
  - name: Product Families
  - name: Products
  - name: Subscriptions
  - name: Usage
paths:
  /api/v1/customers/{id_or_alias}/portal-token:
    post:
      tags:
        - Customers
      summary: Generate a portal token for a customer
      description: >-
        Generates a JWT token that grants access to the customer portal.

        The token can be used to access invoices, payment methods, and other
        portal features.
      operationId: create_portal_token
      parameters:
        - name: id_or_alias
          in: path
          description: customer ID or alias
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              oneOf:
                - type: 'null'
                - $ref: '#/components/schemas/CustomerPortalTokenRequest'
      responses:
        '200':
          description: Portal token generated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomerPortalTokenResponse'
        '400':
          description: Invalid input
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestErrorResponse'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestErrorResponse'
        '404':
          description: Customer not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestErrorResponse'
        '429':
          description: Too many requests
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestErrorResponse'
        '500':
          description: Internal error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestErrorResponse'
      security:
        - bearer_auth: []
components:
  schemas:
    CustomerPortalTokenRequest:
      type: object
      properties:
        expires_in_seconds:
          type:
            - integer
            - 'null'
          format: int32
          description: |-
            Token lifetime in seconds. Defaults to 86400 (24 hours).
            Must be between 60 and 2592000 (30 days).
          minimum: 0
    CustomerPortalTokenResponse:
      type: object
      required:
        - token
        - portal_url
      properties:
        portal_url:
          type: string
          description: Base URL of the customer portal
        token:
          type: string
          description: JWT token for portal access
    RestErrorResponse:
      type: object
      required:
        - code
        - message
      properties:
        code:
          $ref: '#/components/schemas/ErrorCode'
        message:
          type: string
    ErrorCode:
      type: string
      enum:
        - BAD_REQUEST
        - NOT_FOUND
        - CONFLICT
        - FORBIDDEN
        - UNAUTHORIZED
        - TOO_MANY_REQUESTS
        - INTERNAL_SERVER_ERROR
  securitySchemes:
    bearer_auth:
      type: http
      scheme: bearer

````