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

# Retrieve

> Execute a natural language query against your instance's data sources and return the retrieved data.



## OpenAPI

````yaml cloud_openapi.json POST /v1/instances/{instance_id}/retrieve
openapi: 3.1.0
info:
  title: SnowLeopard API
  description: Natural language querying capabilities over structured data
  version: 1.0.0
servers:
  - url: https://api.snowleopard.ai
    description: Production server
security:
  - bearerAuth: []
paths:
  /v1/instances/{instance_id}/retrieve:
    post:
      summary: Retrieve complete query results
      description: >-
        Execute a natural language query against your instance's data sources
        and return the retrieved data.
      operationId: retrieve
      parameters:
        - name: instance_id
          in: path
          required: true
          description: Unique identifier for the instance to query
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - userQuery
              properties:
                userQuery:
                  type: string
                  description: >-
                    Natural language query to execute against your instance's
                    data sources
                  example: How many users signed up last month?
      responses:
        '200':
          description: Successful query execution
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RetrieveResponse'
        '400':
          description: Bad request error (e.g. missing required request body field)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/APIError'
        '409':
          description: Query execution error (e.g. invalid SQL generated)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/APIError'
      x-codeSamples:
        - lang: Python
          label: Asynchronous
          source: |
            from snowleopard import AsyncSnowLeopardClient

            async def main():
                client = AsyncSnowLeopardClient(api_key="{api_key}")
                response = await client.retrieve(
                    instance_id="{instance_id}",
                    user_query="How many users signed up last month?"
                )
                print(response.data)
        - lang: Python
          label: Synchronous
          source: |
            from snowleopard import SnowLeopardClient

            client = SnowLeopardClient(api_key="{api_key}")
            response = client.retrieve(
                instance_id="{instance_id}",
                user_query="How many users signed up last month?"
            )
            print(response.data)
        - lang: TypeScript
          label: TypeScript
          source: |
            import { SnowLeopardClient } from '@snowleopard-ai/client';

            const client = new SnowLeopardClient({
                apiKey: 'your-api-key'
            });

            const response = await client.retrieve({
                instanceId: 'your-instance-id',
                userQuery: 'How many users signed up last month?'
            });

            console.log(response.data);
            await client.close();
components:
  schemas:
    RetrieveResponse:
      type: object
      required:
        - __type__
        - callId
        - data
        - responseStatus
      properties:
        __type__:
          type: string
          enum:
            - retrieveResponse
          description: Type discriminator
        callId:
          type: string
          format: uuid
          description: Unique identifier for this API call
        data:
          type: array
          description: Array of query results or errors
          items:
            oneOf:
              - $ref: '#/components/schemas/SchemaData'
                title: schemaData
              - $ref: '#/components/schemas/ErrorSchemaData'
                title: errorSchemaData
        responseStatus:
          $ref: '#/components/schemas/ResponseStatus'
    APIError:
      type: object
      required:
        - __type__
        - callId
        - responseStatus
        - description
      properties:
        __type__:
          type: string
          enum:
            - apiError
          description: Type discriminator
        callId:
          type: string
          format: uuid
          description: Unique identifier for this API call
        responseStatus:
          type: string
          description: Status of the response
        description:
          type: string
          description: Error description
    SchemaData:
      type: object
      required:
        - __type__
        - schemaId
        - schemaType
        - query
        - rows
        - querySummary
        - rowMax
        - isTrimmed
      properties:
        __type__:
          type: string
          enum:
            - schemaData
          description: Type discriminator
        schemaId:
          type: string
          description: Identifier for the schema/database queried
        schemaType:
          type: string
          description: Type of database (e.g. SQLite, PostgreSQL)
          example: SQLite
        query:
          type: string
          description: Generated SQL query that was executed
        rows:
          type: array
          description: Result rows from the query
          items:
            type: object
            additionalProperties: true
        querySummary:
          type: object
          description: Detailed explanation of the query
          properties:
            technical_details:
              type: string
              description: Technical explanation of the query logic
            non_technical_explanation:
              type: string
              description: Plain language explanation for non-technical users
        rowMax:
          type: integer
          description: Maximum number of rows that can be returned
        isTrimmed:
          type: boolean
          description: Whether the result set was trimmed due to size limits
        callId:
          type: string
          format: uuid
          description: Call identifier (optional)
    ErrorSchemaData:
      type: object
      required:
        - __type__
        - schemaType
        - schemaId
        - query
        - error
        - querySummary
      properties:
        __type__:
          type: string
          enum:
            - errorSchemaData
          description: Type discriminator
        schemaId:
          type: string
          description: Identifier for the schema/database queried
        schemaType:
          type: string
          description: Type of database
          example: SQLite
        query:
          type: string
          description: Generated SQL query that failed
        error:
          type: string
          description: Error message from query execution
        querySummary:
          type: object
          description: Explanation of what the query was attempting to do
          properties:
            technical_details:
              type: string
              description: Technical explanation of the query logic
            non_technical_explanation:
              type: string
              description: Plain language explanation for non-technical users
        datastoreExceptionInfo:
          type: string
          nullable: true
          description: Additional datastore-specific error information
        callId:
          type: string
          format: uuid
          description: Call identifier (optional)
    ResponseStatus:
      type: string
      enum:
        - SUCCESS
        - NOT_FOUND_IN_SCHEMA
        - UNKNOWN
        - INTERNAL_SERVER_ERROR
        - AUTHORIZATION_FAILED
        - LLM_ERROR
        - LLM_TOKEN_LIMIT_REACHED
      description: Status of the API response
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: api_key
      description: >-
        Bearer authentication header of the form `Bearer <api_key>`. API keys
        are created per instance in Snow Leopard Cloud.

````