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

# Create a link session for a toolkit in a tool router session

> Initiates an authentication link session for a specific toolkit within a tool router session. Returns a link token and redirect URL that users can use to complete the OAuth flow.



## OpenAPI

````yaml /api-reference/openapi.json post /api/v3.1/tool_router/session/{session_id}/link
openapi: 3.1.0
info:
  version: 3.1.0
  title: Composio Platform API v3.1
  description: >-
    Composio v3.1 API — all endpoints available under /api/v3.1/. Tool endpoints
    default to the latest tool version.
  contact:
    name: Composio Support
    url: https://composio.dev/support
    email: support@composio.dev
  license:
    name: Proprietary
    url: https://composio.dev/terms
servers:
  - url: https://backend.composio.dev
    description: Composio production API
security:
  - ApiKeyAuth: []
tags:
  - name: Authentication
    description: Authentication related endpoints
    x-group: Authentication
  - name: Auth Configs
    description: Authentication configuration management
    x-group: Auth Configs
  - name: Connected Accounts
    description: Connected account management
    x-group: Connected Accounts
  - name: Logs
    description: Logging and monitoring
    x-group: Logs
  - name: OpenAPI
    description: OpenAPI specification management
    x-group: OpenAPI
  - name: Organization
    description: Organization management
    x-group: Organization
  - name: API Keys
    description: API key management
    x-group: API Keys
  - name: Webhooks
    description: Webhook configuration
    x-group: Webhooks
  - name: Webhook Endpoints
    description: >-
      Per-OAuth-app webhook ingress endpoints. Inbound URLs the provider posts
      to, plus signing secret storage and verification.
    x-group: Webhook Endpoints
  - name: Webhook Subscriptions
    description: >-
      Webhook delivery subscriptions. Outbound URLs Composio posts trigger
      events to, plus signing secret rotation and event-type filters.
    x-group: Webhook Subscriptions
  - name: Team
    description: Team member management
    x-group: Team
  - name: Consumer Skills
    description: Organization-authored Skill management
    x-group: Consumer Skills
  - name: Toolkits
    description: Toolkit and tool management
    x-group: Toolkits
  - name: Tools
    description: Tool execution endpoints
    x-group: Tools
  - name: Triggers
    description: Trigger management and execution
    x-group: Triggers
  - name: Payments
    description: Payment and subscription management
    x-group: Payments
  - name: Billing
    description: Dashboard billing state — usage, subscription, contract (cookie-auth only)
    x-group: Billing
  - name: Compliance
    description: Organization compliance agreements and acceptance state
    x-group: Compliance
  - name: Files
    description: File management
    x-group: Files
  - name: MCP
    description: MCP server management
    x-group: MCP
  - name: MCP Partner
    description: MCP partner management
    x-group: MCP Partner
  - name: Stripe Projects
    description: Stripe Projects provisioning
    x-group: Stripe Projects
  - name: Tool Router
    description: (Labs) Tool router endpoints
    x-group: Sessions (Prev Tool Router)
  - name: Playground
    description: Dashboard playground chat
    x-group: Playground
  - name: Arena
    description: Arena conversations, messages and terms
    x-group: Arena
  - name: Projects
    description: Projects API endpoints.
    x-group: Projects
  - name: Organization Management
    description: Organization Management API endpoints.
    x-group: Organization Management
  - name: Webhook Events
    description: Events delivered by Composio to your registered webhook endpoints
    x-group: Webhook Events
paths:
  /api/v3.1/tool_router/session/{session_id}/link:
    post:
      tags:
        - Tool Router
      summary: Create a link session for a toolkit in a tool router session
      description: >-
        Initiates an authentication link session for a specific toolkit within a
        tool router session. Returns a link token and redirect URL that users
        can use to complete the OAuth flow.
      operationId: postToolRouterSessionBySessionIdLink
      parameters:
        - schema:
            type: string
            format: toolRouterSessionId
            description: The session ID returned when creating the session
            example: trs_LX9uJKBinWWr
          required: true
          description: The unique identifier of the tool router session
          name: session_id
          in: path
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                toolkit:
                  type: string
                  minLength: 1
                  description: The unique slug identifier of the toolkit to connect
                  example: github
                alias:
                  type: string
                  maxLength: 255
                  description: >-
                    A human-readable alias for this connected account. Must be
                    unique per entity and toolkit within the project.
                callback_url:
                  type: string
                  format: uri
                  description: URL where users will be redirected after completing auth
                  example: https://myapp.com/callback
                experimental:
                  type: object
                  properties:
                    account_type:
                      type: string
                      enum:
                        - PRIVATE
                        - SHARED
                      description: >-
                        Sharing model for this connected account. PRIVATE
                        (default) is usable only by the owning user_id. SHARED
                        is reachable from a tool-router session ONLY when
                        explicitly pinned in the session config — at most one
                        SHARED connection per toolkit per session. Sessions
                        never use a SHARED connection implicitly. Every use of a
                        SHARED connection must pass the acting user_id, which is
                        checked against its ACL.
                      x-experimental: true
                    acl_config_for_shared:
                      type: object
                      properties:
                        allow_all_users:
                          type: boolean
                          description: >-
                            Wildcard "any user_id in the project" allow toggle.
                            Only valid on SHARED connections.
                        allowed_user_ids:
                          type: array
                          items:
                            type: string
                            minLength: 1
                            maxLength: 256
                          maxItems: 1000
                          description: >-
                            Explicit allow list of user_ids who can use this
                            SHARED connection.
                        not_allowed_user_ids:
                          type: array
                          items:
                            type: string
                            minLength: 1
                            maxLength: 256
                          maxItems: 1000
                          description: >-
                            Explicit deny list. Wins on conflict with
                            allow_all_users and allowed_user_ids.
                      description: >-
                        Access control for SHARED connections. Resolution rule
                        (only fires when caller != creator): user in
                        not_allowed_user_ids → DENY; allow_all_users=true →
                        ALLOW; user in allowed_user_ids → ALLOW; else DENY.
                        Default state (omitted or {}) is deny-by-default — only
                        the creator can use.
                      x-experimental: true
                  description: >-
                    Experimental features - not stable, may be modified or
                    removed in future versions.
                  x-experimental: true
              required:
                - toolkit
      responses:
        '201':
          description: >-
            Successfully created link session. Returns link token, redirect URL,
            and connected account ID.
          content:
            application/json:
              schema:
                type: object
                properties:
                  link_token:
                    type: string
                    description: Token used to complete the authentication flow
                    example: lt_abc123xyz
                  redirect_url:
                    type: string
                    format: uri
                    description: The URL where users should be redirected to complete OAuth
                    example: https://app.composio.dev/link/lt_abc123xyz
                  connected_account_id:
                    type: string
                    format: connectedAccountId
                    description: The unique identifier for the connected account
                    example: ca_abc123xyz
                  experimental:
                    type: object
                    properties:
                      account_type:
                        type: string
                        enum:
                          - PRIVATE
                          - SHARED
                        description: >-
                          Sharing model for this connected account. PRIVATE is
                          usable only by the owning user_id. SHARED is reachable
                          from a tool-router session only when explicitly pinned
                          in the session config.
                        x-experimental: true
                      acl_config_for_shared:
                        type: object
                        properties:
                          allow_all_users:
                            type: boolean
                          allowed_user_ids:
                            type: array
                            items:
                              type: string
                          not_allowed_user_ids:
                            type: array
                            items:
                              type: string
                        required:
                          - allow_all_users
                          - allowed_user_ids
                          - not_allowed_user_ids
                        description: >-
                          Access control for SHARED connections. Visible only to
                          the connection creator and project/org API key
                          callers; non-creator cookie callers receive the
                          response without this block.
                        x-experimental: true
                    required:
                      - account_type
                    description: >-
                      Experimental features - not stable, may be modified or
                      removed in future versions.
                    x-experimental: true
                required:
                  - link_token
                  - redirect_url
                  - connected_account_id
        '400':
          description: >-
            Bad request. This may occur if the toolkit slug is invalid, request
            parameters are malformed, or a connected account is already defined
            for this toolkit in the session configuration.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: >-
            Unauthorized. Authentication is required or the provided credentials
            are invalid.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Forbidden. The session does not belong to the authenticated user.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: >-
            Not found. The session does not exist, toolkit not found, or no auth
            config exists for the toolkit.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '408':
          description: >-
            Request timeout. Auth config or link creation did not complete in
            time; retry the request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: >-
            Conflict. The link or the auto-created auth config collides with
            existing state, such as a duplicate alias.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: >-
            Unprocessable entity. The auth config or connection input was
            rejected by validation.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: >-
            Too many requests. The upstream service is rate limiting the
            request; retry after a short backoff.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          description: >-
            Internal server error. An unexpected error occurred while creating
            the link session.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '501':
          description: >-
            Not implemented. The auth scheme of the resolved auth config does
            not support link-based connection.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - ApiKeyAuth: []
components:
  schemas:
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
            code:
              type: number
            slug:
              type: string
            status:
              type: number
            request_id:
              type: string
            suggested_fix:
              type: string
            errors:
              type: array
              items:
                type: string
          required:
            - message
            - code
            - slug
            - status
      required:
        - error
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        Your Composio project API key. Create or copy it from the Composio
        dashboard.
      x-default: your-project-api-key

````