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

# Create customer or guest session

> Create a unique session for a customer or guest

For customer sessions: Provide customer_id
For guest sessions: Set is_guest_session=True and omit customer_id



## OpenAPI

````yaml /openAPI/openapi-20240301.json post /customers/session
openapi: 3.1.0
info:
  title: zenskar
  version: 2.0.0
servers:
  - url: https://api.zenskar.com
security:
  - ApiTokenAuth: []
    OrganisationAuth: []
paths:
  /customers/session:
    post:
      tags:
        - Customers
      summary: Create customer or guest session
      description: |-
        Create a unique session for a customer or guest

        For customer sessions: Provide customer_id
        For guest sessions: Set is_guest_session=True and omit customer_id
      operationId: Create-customer-or-guest-session
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateSessionRequestSchema'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomerSessionResponseSchema'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    CreateSessionRequestSchema:
      properties:
        customer_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Customer Id
          description: >-
            Customer Id (required for customer sessions, must be None for guest
            sessions)
        is_guest_session:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Is Guest Session
          description: Set to True to create a guest session
        return_url:
          type: string
          title: Return Url
          description: Return URL
        idle_timeout:
          anyOf:
            - type: integer
            - type: 'null'
          title: Idle Timeout
          description: Idle Timeout in Seconds
          default: 3600
        session_key:
          anyOf:
            - type: string
            - type: 'null'
          title: Session Key
          description: Session Key
      type: object
      required:
        - return_url
      title: CreateSessionRequestSchema
      description: Create Session Request Schema
    CustomerSessionResponseSchema:
      properties:
        redirect_url:
          type: string
          title: Redirect Url
          description: >-
            URL to which the user should be redirected after the session is
            created or expires. This is usually the destination in the
            organisation's portal for follow-up steps.
        session_token:
          type: string
          title: Session Token
          description: >-
            Opaque token representing the current session. Use this token to
            authenticate session-specific requests.
        is_guest_session:
          type: boolean
          title: Is Guest Session
          description: >-
            Indicates if this session was created as a guest session (True for
            guests, False for registered customers).
      type: object
      required:
        - redirect_url
        - session_token
        - is_guest_session
      title: CustomerSessionResponseSchema
      description: Customer Session Response Schema
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    ApiTokenAuth:
      type: apiKey
      in: header
      name: x-api-key
      x-default: <your-api-key>
    OrganisationAuth:
      type: apiKey
      in: header
      name: organisation
      x-default: <your-organisation-id>

````