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

# Load Connector Data

> Load data from a connector into a sandbox dataframe

<Warning>
  **`tql_path` runs saved Context Library `.tql` files** that the caller's roles can already see — it does not compile caller-authored TQL. Provide exactly one of `query` or `tql_path`; sending both or neither returns `400 invalid_request`.
</Warning>


## OpenAPI

````yaml POST /v2/sandcastles/{id}/query
openapi: 3.1.0
info:
  title: TextQL v2 API
  version: '2.0'
  description: >
    REST API for TextQL platform operations. All endpoints require Bearer token
    authentication.
servers:
  - url: https://app.textql.com
security:
  - bearerAuth: []
tags:
  - name: Chat
    description: Create and manage AI chat sessions
  - name: Connectors
    description: List available data connectors
  - name: Playbooks
    description: Create, configure, and run automated playbooks
  - name: Sandcastles
    description: Manage Python sandbox environments for code execution
  - name: Changes
    description: Review, approve, and deny Context Library changes
paths:
  /v2/sandcastles/{id}/query:
    post:
      tags:
        - Sandcastles
      summary: Load Connector Data
      description: >
        Load data from a connector into a sandbox dataframe. Provide **exactly

        one** of `query` (an inline SQL query) or `tql_path` (the Context

        Library path of a saved `.tql` file) — sending both or neither returns

        `400 invalid_request`.


        `tql_path` runs **saved Context Library `.tql` files** that the

        caller's roles can already see — it does not compile caller-authored

        TQL. A path that is not visible to the member's roles returns

        `404 not_found`, indistinguishable from a path that does not exist. A

        path that does not end in `.tql`, or a file that fails to render,

        returns `400` with the renderer's message included.


        The response shape is the same for both branches.


        Executions are recorded — see

        [GET
        /v2/sandcastles/{id}/executions](/api-reference/v2/sandbox/list-executions).
      operationId: v2.loadConnectorData
      parameters:
        - $ref: '#/components/parameters/SandboxId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LoadConnectorDataRequest'
      responses:
        '200':
          description: Query result loaded into dataframe
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LoadConnectorDataResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/InternalError'
components:
  parameters:
    SandboxId:
      name: id
      in: path
      required: true
      schema:
        type: string
      description: Sandbox ID
  schemas:
    LoadConnectorDataRequest:
      type: object
      required:
        - connector_id
      properties:
        connector_id:
          type: integer
          format: int32
          description: Connector to query
        query:
          type: string
          description: |
            Inline SQL query to execute. Mutually exclusive with `tql_path` —
            provide exactly one of the two (`400 invalid_request` otherwise).
        tql_path:
          type: string
          description: |
            Context Library path of a saved `.tql` file to run (must end in
            `.tql`). Only files already visible to the member's roles can be
            run — a path that is not visible returns `404 not_found`,
            indistinguishable from a path that does not exist. Mutually
            exclusive with `query` — provide exactly one of the two
            (`400 invalid_request` otherwise).
        params:
          type: object
          description: |
            Parameter values passed to the saved `.tql` file when it is
            rendered. Only used with `tql_path`. If rendering fails, the
            request returns `400` with the renderer's message included.
        max_rows:
          type: integer
          format: int64
          description: |
            Maximum number of rows to load. Only applies to the `tql_path`
            branch; clamped to the range 1–2,000,000 (default 2,000,000).
        dataframe_name:
          type: string
          description: |
            Name for the resulting dataframe. Defaults to `connector_{id}` for
            `query`, or to the `.tql` filename stem (e.g. `revenue` for
            `reports/revenue.tql`) for `tql_path`.
    LoadConnectorDataResponse:
      type: object
      properties:
        preview:
          type: string
          description: >
            Text summary of the loaded data. Format varies by size: for smaller
            results,

            a dataframe preview string from the sandbox; for larger results
            (2048+ rows),

            a markdown table of the first 100 rows.
        dataframe_name:
          type: string
        num_rows:
          type: integer
          format: int64
        num_cols:
          type: integer
          format: int64
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              description: Machine-readable error code
              enum:
                - invalid_request
                - unauthenticated
                - permission_denied
                - not_found
                - conflict
                - rate_limit_exceeded
                - internal
                - timeout
                - cancelled
                - execution_failed
                - no_report
            message:
              type: string
              description: Human-readable error message
  responses:
    BadRequest:
      description: Invalid request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: invalid_request
              message: Invalid request body
    Unauthorized:
      description: Missing or invalid authentication
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: unauthenticated
              message: Authentication required
    Forbidden:
      description: Insufficient permissions
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: permission_denied
              message: Insufficient permissions
    NotFound:
      description: Resource not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: not_found
              message: Resource not found
    RateLimited:
      description: Rate limit exceeded
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: rate_limit_exceeded
              message: Rate limit exceeded
    InternalError:
      description: Internal server error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: internal
              message: Internal server error
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: API key or JWT token

````