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

# Run a bounded generated-code probe against an external data connection.



## OpenAPI

````yaml https://api.truestate.io/openapi.json post /connections/{connection_id}/execute/
openapi: 3.1.0
info:
  title: TrueState Backend API
  summary: >-
    TrueState is an AI platform for business users to create high-impact AI
    solutions.
  description: >

    This **[TrueState](https://www.truestate.io/)** backend API allows our
    clients to automate and more powerfully retrieve and modify data from the
    TrueState platform.


    Example use cases include:


    - Accessing embeddings for a dataset.

    - Automating the process of dataset creation and model retraining as your
    data changes.

    - Much more.


    Our backend is built using the [FastAPI](https://fastapi.tiangolo.com/)
    framework in python

    using [Auth0](https://auth0.com/) and [Client API
    Keys](https://www.truestate.io/dawn/docs) for internal an external
    authentication, respectively.

    Our backend is designed to be secure, scalable, easy to use and well
    documented _(each router with its own linked docs page)_.

    Clients can only access data from their own organisation, as setup in Auth0
    our the Client API Keys. See how
    **[here](https://www.truestate.io/dawn/docs)**.


    **PS**: You can view this API documentation in either
    **[Swagger](swagger/docs)** or **[Redoc](redoc/)**, but only the swagger
    lets you test calls.
  contact:
    name: True State Support
    url: https://www.truestate.io/dawn/docs
    email: support@truestate.io
  license:
    name: Private
    url: https://www.apache.org/licenses/LICENSE-2.0.html
  version: 0.13.95
servers: []
security: []
paths:
  /connections/{connection_id}/execute/:
    post:
      tags:
        - connections
      summary: Run a bounded generated-code probe against an external data connection.
      operationId: execute_connection_connections__connection_id__execute__post
      parameters:
        - name: connection_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
            title: Connection Id
        - name: Api-key
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Api-Key
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ConnectionExecuteRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConnectionExecuteResult'
        '404':
          description: Not found
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    ConnectionExecuteRequest:
      properties:
        mode:
          $ref: '#/components/schemas/ConnectionExecutionMode'
          description: >-
            Use python for arbitrary source probes. Use query when generated
            Python should execute the provided read-only SQL/SOQL query via
            ctx.query.
          default: python
        code:
          anyOf:
            - type: string
            - type: 'null'
          title: Code
          description: >-
            Generated Python code for the executor. Define run(ctx) or run().
            The result should be a pandas DataFrame, list of records, or dict of
            named DataFrames/records/scalars. RUNTIME_* globals contain raw
            Secret Manager strings; generated code should parse them according
            to secret metadata, for example
            json.loads(RUNTIME_ATTIO_API_TOKEN)['token'] for token secrets.
        query:
          anyOf:
            - type: string
              minLength: 1
            - type: 'null'
          title: Query
        query_language:
          type: string
          enum:
            - sql
            - soql
          title: Query Language
          default: sql
        configuration:
          additionalProperties: true
          type: object
          title: Configuration
          description: >-
            Optional non-secret runtime configuration for standalone
            generated-code execution. Connection-bound execution uses the saved
            connection configuration.
        discovery_metadata:
          additionalProperties: true
          type: object
          title: Discovery Metadata
          description: >-
            Optional non-secret metadata available to standalone generated code
            as ctx.discovery_metadata.
        parameters:
          additionalProperties: true
          type: object
          title: Parameters
        secret_names:
          items:
            type: string
          type: array
          maxItems: 20
          title: Secret Names
          description: >-
            Optional secret names to resolve through the backend and expose to
            generated code as RUNTIME_<SECRET_NAME> globals. The globals contain
            raw Secret Manager payload strings that code must parse according to
            each secret_type.
        limit:
          type: integer
          maximum: 500
          minimum: 1
          title: Limit
          description: Maximum sample rows returned to the agent per output table.
          default: 25
        timeout_seconds:
          type: integer
          maximum: 120
          minimum: 1
          title: Timeout Seconds
          default: 60
      type: object
      title: ConnectionExecuteRequest
    ConnectionExecuteResult:
      properties:
        connection:
          anyOf:
            - $ref: '#/components/schemas/ConnectionRead'
            - type: 'null'
        execution_id:
          type: string
          title: Execution Id
        status:
          type: string
          enum:
            - succeeded
            - failed
          title: Status
        outputs:
          additionalProperties:
            $ref: '#/components/schemas/ConnectionExecutionTable'
          type: object
          title: Outputs
        metadata:
          additionalProperties: true
          type: object
          title: Metadata
        stdout_tail:
          type: string
          title: Stdout Tail
          default: ''
        stderr_tail:
          type: string
          title: Stderr Tail
          default: ''
        error:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Error
      type: object
      required:
        - execution_id
        - status
      title: ConnectionExecuteResult
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ConnectionExecutionMode:
      type: string
      enum:
        - python
        - query
      title: ConnectionExecutionMode
    ConnectionRead:
      properties:
        name:
          type: string
          maxLength: 255
          minLength: 1
          title: Name
        source:
          $ref: '#/components/schemas/IntegrationSource'
        configuration:
          additionalProperties: true
          type: object
          title: Configuration
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
        credential_secret_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Credential Secret Id
        credential_secret_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Credential Secret Name
        discovery_metadata:
          additionalProperties: true
          type: object
          title: Discovery Metadata
        status:
          $ref: '#/components/schemas/ConnectionStatus'
          default: active
        id:
          type: string
          format: uuid
          title: Id
        organisation_id:
          type: string
          title: Organisation Id
        credential_secret_type:
          anyOf:
            - type: string
            - type: 'null'
          title: Credential Secret Type
        created_at:
          type: string
          format: date-time
          title: Created At
        updated_at:
          type: string
          format: date-time
          title: Updated At
        last_discovered_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Last Discovered At
        last_sync_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Last Sync At
        last_error:
          anyOf:
            - type: string
            - type: 'null'
          title: Last Error
      type: object
      required:
        - name
        - source
        - configuration
        - id
        - organisation_id
        - created_at
        - updated_at
      title: ConnectionRead
    ConnectionExecutionTable:
      properties:
        columns:
          items:
            type: string
          type: array
          title: Columns
        rows:
          items:
            additionalProperties: true
            type: object
          type: array
          title: Rows
        row_count:
          type: integer
          title: Row Count
          default: 0
        truncated:
          type: boolean
          title: Truncated
          default: false
      type: object
      title: ConnectionExecutionTable
    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
    IntegrationSource:
      type: string
      enum:
        - salesforce
        - google-cloud-storage
        - aws-s3
        - azure-blob-storage
        - sql-server
        - postgres
        - sharepoint
        - bigquery
        - fabric-warehouse
        - snowflake
        - taboola
        - outbrain
        - dynamics-365-business-central
        - linkedin
        - google-sheets
        - heyreach
        - instantly
        - rest-api
        - custom
      title: IntegrationSource
    ConnectionStatus:
      type: string
      enum:
        - active
        - disabled
      title: ConnectionStatus
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````