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

# Connect



## OpenAPI

````yaml https://api.aiql.io/openapi.json post /connectors/{connector_type}/connect
openapi: 3.1.0
info:
  title: aiql-api
  version: 0.1.0
servers:
  - url: https://api.aiql.io
security: []
tags:
  - name: Health
    description: Service health checks.
  - name: Workspaces
    description: Workspace management.
  - name: Ingestions
    description: Document ingestion pipeline.
  - name: Queries
    description: Natural-language queries.
  - name: Sources
    description: Ingested sources and their contents.
  - name: Requests
    description: Source addition/removal requests awaiting review.
  - name: Request Changes
    description: Individual source add/remove changes on a request.
  - name: Request Reviews
    description: Reviews of a request, including draft and submit.
  - name: Request Comments
    description: Comments on a request review.
  - name: Canvases
    description: Brainstorm canvases.
  - name: Dashboards
    description: Dashboards.
  - name: Presentations
    description: Slide presentations.
  - name: Tools
    description: Standalone convert/split/shape/extract tools.
  - name: Connectors
    description: Connector catalog and connect flows.
  - name: Connections
    description: Workspace connector connections.
paths:
  /connectors/{connector_type}/connect:
    post:
      tags:
        - Connectors
      summary: Connect
      operationId: connect_connectors__connector_type__connect_post
      parameters:
        - name: connector_type
          in: path
          required: true
          schema:
            type: string
            title: Connector Type
        - name: AiQL-Workspace
          in: header
          required: true
          schema:
            type: string
            description: ID of the workspace the request operates on.
            title: Aiql-Workspace
          description: ID of the workspace the request operates on.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ConnectRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConnectResponse'
        '401':
          description: 'Authentication failed: missing or invalid API key.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X POST https://api.aiql.io/connectors/{connector_type}/connect
            \
              -H "Authorization: Bearer $AIQL_API_KEY"
components:
  schemas:
    ConnectRequest:
      properties:
        name:
          type: string
          title: Name
          description: Display name for the new connection.
        credential_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Credential Id
          description: >-
            ID of a credential already known to aiql-api (from a previous OAuth
            connect) to reuse for this new connection, skipping the OAuth
            handshake. Optional for google-drive, sharepoint, and
            microsoft-teams; when omitted, those types instead return an
            authorization_url to complete the handshake.
        credential:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Credential
          description: >-
            Raw credential fields for aiql-api to encrypt and persist itself.
            Required for odoo (unless credential_id is given): {url, db,
            username, api_key}.
        config:
          additionalProperties: true
          type: object
          title: Config
          description: >-
            Connector-specific configuration: root_folder_id (google-drive);
            site_id, drive_id, include_shared_with_me, tenant_id (sharepoint);
            drive_id, include_shared_with_me, tenant_id (onedrive); user_filter,
            tenant_id (microsoft-teams, tenant_id required when starting a new
            OAuth handshake).
        return_url:
          anyOf:
            - type: string
            - type: 'null'
          title: Return Url
          description: >-
            Where to send the user's browser after the OAuth handshake finishes
            (only used for google-drive, sharepoint, and microsoft-teams when no
            credential_id is given). The final callback redirects here with
            ?status=success|error&connection_id=... appended. When omitted, a
            static aiql-api-hosted confirmation page is shown instead.
      type: object
      required:
        - name
      title: ConnectRequest
    ConnectResponse:
      properties:
        status:
          type: string
          enum:
            - connected
            - pending_authorization
          title: Status
          description: >-
            'connected' when the connection was created immediately (odoo, or an
            OAuth type reusing an existing credential_id).
            'pending_authorization' when the caller must send the user's browser
            to authorization_url to finish connecting.
        connection:
          anyOf:
            - $ref: '#/components/schemas/Connection'
            - type: 'null'
          description: Populated when status == 'connected'.
        authorization_url:
          anyOf:
            - type: string
            - type: 'null'
          title: Authorization Url
          description: >-
            Populated when status == 'pending_authorization'. Open this URL in
            the user's browser (redirect or popup) to complete the OAuth
            handshake.
        expires_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Expires At
          description: When authorization_url stops being valid.
      type: object
      required:
        - status
      title: ConnectResponse
    ErrorResponse:
      type: object
      title: ErrorResponse
      properties:
        detail:
          type: string
          title: Detail
      required:
        - detail
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    Connection:
      properties:
        id:
          type: string
          title: Id
          description: Unique identifier of the connection.
        connector_type:
          type: string
          title: Connector Type
          description: Connector type this connection uses.
        name:
          type: string
          title: Name
          description: Display name of the connection.
        workspace_id:
          type: string
          title: Workspace Id
          description: Workspace the connection belongs to.
        credential_id:
          type: string
          title: Credential Id
          description: ID of the credential attached to this connection.
        config:
          additionalProperties: true
          type: object
          title: Config
          description: Connector-specific configuration for this connection.
        change_token:
          anyOf:
            - type: string
            - type: 'null'
          title: Change Token
          description: Opaque cursor used for incremental sync.
        last_synced_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Last Synced At
          description: When the connection last completed a sync.
        created_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Created At
          description: When the connection was created.
      type: object
      required:
        - id
        - connector_type
        - name
        - workspace_id
        - credential_id
      title: Connection
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    HTTPBearer:
      type: http
      description: API key passed as a Bearer token in the Authorization header.
      scheme: bearer

````