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

# Search Tree

> Search across your teamspace's indexed knowledge and return results as a hierarchical context tree.
Results are grouped by source (datasets, files, pages) with navigation items for quick access.
Supports pagination via cursor-based `next` parameter.
This endpoint is the foundation for the AI Search endpoint — use this when you need structured results without AI summarization.




## OpenAPI

````yaml get /search/tree
openapi: 3.0.3
info:
  version: 0.1.1
  title: Datagrid API
  description: Datagrid API
servers:
  - url: https://api.datagrid.com/v1
security:
  - BearerAuth: []
paths:
  /search/tree:
    get:
      tags:
        - Search
      summary: Search Tree
      description: >
        Search across your teamspace's indexed knowledge and return results as a
        hierarchical context tree.

        Results are grouped by source (datasets, files, pages) with navigation
        items for quick access.

        Supports pagination via cursor-based `next` parameter.

        This endpoint is the foundation for the AI Search endpoint — use this
        when you need structured results without AI summarization.
      operationId: searchTree
      parameters:
        - name: query
          description: The natural language search query.
          in: query
          required: true
          schema:
            type: string
        - name: record_types
          description: >-
            Filter results by record type in the vector database. When omitted,
            all record types are searched.
          in: query
          required: false
          schema:
            type: array
            items:
              $ref: '#/components/schemas/SearchRecordType'
        - $ref: '#/components/parameters/next'
        - $ref: '#/components/parameters/limit'
      responses:
        '200':
          description: >-
            A tree of search results grouped by source, with navigation items
            and pagination.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SearchTreeResult'
        '402':
          description: >-
            Credit limit exceeded. The organization does not have enough credits
            to perform this search. Check your billing status and add credits to
            your account.
        '429':
          description: >-
            Rate limit exceeded. The request has been throttled because the rate
            limit for this endpoint has been reached. Check the `Retry-After`
            response header and retry after the specified number of seconds.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RateLimitError'
      x-codeSamples:
        - lang: JavaScript
          source: >-
            import Datagrid from 'datagrid-ai';


            const client = new Datagrid({
              apiKey: process.env['DATAGRID_API_KEY'], // This is the default and can be omitted
            });


            const searchTreeResult = await client.search.searchTree({ query:
            'query' });


            console.log(searchTreeResult.credits);
        - lang: Python
          source: |-
            import os
            from datagrid_ai import Datagrid

            client = Datagrid(
                api_key=os.environ.get("DATAGRID_API_KEY"),  # This is the default and can be omitted
            )
            search_tree_result = client.search.search_tree(
                query="query",
            )
            print(search_tree_result.credits)
components:
  schemas:
    SearchRecordType:
      type: string
      description: The record type in the vector database.
      enum:
        - rows
        - tables
        - files
        - pages
        - cells
    SearchTreeResult:
      type: object
      description: >-
        Hierarchical search results grouped by source (datasets, files, pages)
        with navigation items.
      required:
        - object
        - query
        - data
        - nav_items
        - has_more
        - credits
      properties:
        object:
          type: string
          enum:
            - search_tree
          description: The object type, always `search_tree`.
        query:
          type: string
          description: The original search query.
        data:
          type: array
          items:
            type: object
          description: >-
            Tree nodes representing search results grouped by source. Each node
            contains the matched content, metadata, score, and child nodes for
            hierarchical display.
        nav_items:
          type: array
          items:
            type: object
          description: >-
            Navigation items providing quick links to the datasets, tables, and
            files that matched the query. Each item includes a name, emoji, URL,
            and type.
        has_more:
          type: boolean
          description: >-
            Whether more results are available beyond this page. Use the `next`
            cursor to fetch additional results.
        next:
          type: string
          nullable: true
          description: >-
            Pagination cursor (numeric offset as string). Pass this value as the
            `next` query parameter to `/search/tree` to fetch the next page.
        credits:
          nullable: true
          description: >-
            Credit consumption for this search. When present, `consumed`
            reflects the actual variable cost of the retrieval work performed
            for this request. `null` when the billing write fails or the request
            is aborted before billing completes.
          allOf:
            - $ref: '#/components/schemas/OperationCredits'
    RateLimitError:
      type: object
      description: >-
        Returned when the rate limit is exceeded. Rate limits are enforced per
        teamspace, endpoint path, and HTTP method over a 60-second sliding
        window. Each endpoint may have its own limit — check the
        X-RateLimit-Limit response header for the effective value.
      required:
        - error
        - message
        - retryable
        - status_code
      properties:
        status_code:
          type: integer
          description: The HTTP status code (429).
        statusCode:
          type: integer
          deprecated: true
          description: Deprecated. Use status_code instead.
        error:
          type: string
          enum:
            - rate_limit_exceeded
          description: The error code identifying this as a rate limit error.
        message:
          type: string
          description: A human-readable error message.
        mitigation:
          type: string
          description: Suggested action to resolve the error.
        retryable:
          type: boolean
          description: Whether the request can be retried after a delay.
        details:
          type: object
          properties:
            reason:
              type: string
              description: A detailed explanation of why the rate limit was exceeded.
    OperationCredits:
      type: object
      required:
        - consumed
      properties:
        consumed:
          type: number
          description: The number of credits consumed by the operation.
  parameters:
    next:
      name: next
      in: query
      schema:
        type: string
      required: false
      description: >-
        A cursor to use in pagination to continue a query from the previous
        request. This is automatically added when the request has more results
        to fetch.
    limit:
      name: limit
      in: query
      schema:
        type: integer
        default: 50
        minimum: 1
        maximum: 100
      required: false
      description: The limit on the number of objects to return, ranging between 1 and 100.
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer

````