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

# Create an auth session

> To launch the authentication flow, create an auth session and pass the returned session's `authFlowUrl` to the client for your end-user to visit in their browser. Demo: https://connect.conductor.is/qbd/demo



## OpenAPI

````yaml POST /auth-sessions
openapi: 3.1.0
info:
  title: Conductor API
  version: 0.0.1
servers:
  - url: https://api.conductor.is/v1
security:
  - BearerAuth: []
paths:
  /auth-sessions:
    post:
      summary: Create an auth session
      description: >-
        To launch the authentication flow, create an auth session and pass the
        returned session's `authFlowUrl` to the client for your end-user to
        visit in their browser. Demo: https://connect.conductor.is/qbd/demo
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                publishableKey:
                  type: string
                  description: >-
                    Your Conductor publishable key, which we use to create the
                    auth session's `authFlowUrl`.
                  example: '{{YOUR_PUBLISHABLE_KEY}}'
                endUserId:
                  type: string
                  description: >-
                    The ID of the end-user for whom to create the integration
                    connection.
                  example: end_usr_1234567abcdefg
                linkExpiryMins:
                  type: number
                  default: 30
                  description: >-
                    The number of minutes after which the auth session will
                    expire. Must be at least 15 minutes and no more than 7 days.
                    If not provided, defaults to 30 minutes.
                redirectUrl:
                  type: string
                  format: uri
                  description: >-
                    The URL to which Conductor will redirect the end-user to
                    return to your app after they complete the authentication
                    flow. If not provided, their browser tab will close instead.
                  example: https://example.com/auth/conductor-callback
              required:
                - publishableKey
                - endUserId
      responses:
        '200':
          description: Returns the auth session object.
          headers:
            Conductor-Request-Id:
              schema:
                type: string
                description: The unique identifier for this API request.
                example: req_1234567abcdefg
              required: true
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/auth_session'
      security:
        - BearerAuth: []
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import Conductor from 'conductor-node';

            const conductor = new Conductor({
              apiKey: process.env['CONDUCTOR_SECRET_KEY'], // This is the default and can be omitted
            });

            const authSession = await conductor.authSessions.create({
              endUserId: 'end_usr_1234567abcdefg',
              publishableKey: '{{YOUR_PUBLISHABLE_KEY}}',
            });

            console.log(authSession.id);
        - lang: Python
          source: |-
            import os
            from conductor import Conductor

            conductor = Conductor(
                api_key=os.environ.get("CONDUCTOR_SECRET_KEY"),  # This is the default and can be omitted
            )
            auth_session = conductor.auth_sessions.create(
                end_user_id="end_usr_1234567abcdefg",
                publishable_key="{{YOUR_PUBLISHABLE_KEY}}",
            )
            print(auth_session.id)
components:
  schemas:
    auth_session:
      type: object
      properties:
        id:
          type: string
          description: The unique identifier for this auth session.
          example: auth_sess_1234567abcdefg
        objectType:
          type: string
          const: auth_session
          description: The type of object. This value is always `"auth_session"`.
          example: auth_session
        createdAt:
          type: string
          description: The date and time when this auth session record was created.
          example: '2024-01-01T12:34:56.789Z'
        endUserId:
          type: string
          description: The ID of the end-user for whom to create an integration connection.
          example: end_usr_1234567abcdefg
        clientSecret:
          type: string
          description: >-
            The secret used in `authFlowUrl` to securely access the
            authentication flow.
          example: auth_sess_client_secret_1234567abcdefg
        authFlowUrl:
          type: string
          description: >-
            The URL of the authentication flow that you will pass to your client
            for your user to set up their integration connection.
          example: >-
            https://connect.conductor.is/qbd/auth_sess_client_secret_1234567abcdefg?key={{YOUR_PUBLISHABLE_KEY}}
        expiresAt:
          type: string
          description: >-
            The date and time when this auth session expires. By default, this
            value is 30 minutes from creation. You can extend this time by
            setting `linkExpiryMins` when creating the auth session.
          example: '2024-01-01T12:34:56.789Z'
        redirectUrl:
          type:
            - string
            - 'null'
          description: >-
            The URL to which Conductor will redirect your user to return to your
            app after they complete the authentication flow. If `null`, their
            browser tab will close instead.
          example: https://myapp.com/auth/callback
      required:
        - id
        - objectType
        - createdAt
        - endUserId
        - clientSecret
        - authFlowUrl
        - expiresAt
        - redirectUrl
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: >-
        Your Conductor secret key using Bearer auth (e.g., `"Authorization:
        Bearer {{YOUR_SECRET_KEY}}"`).

````

Built with [Mintlify](https://mintlify.com).