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

# Search collection documents

> Runs search over the documents in a collection, ranked by relevance to `query`. The collection's `retrieval_type` setting selects the strategy: `vector` (semantic similarity), `hybrid` (vector similarity fused with keyword matching), or `keyword` (lexical BM25 matching). When `query` is omitted, returns a plain catalog listing of the collection's documents.

**How it works:**
1. For `vector` and `hybrid`, the `query` text is embedded into a 1024-dimensional vector using the multilingual-e5-large model.
2. For `vector`, the embedding is compared against the collection's indexed document chunks using semantic similarity; for `hybrid`, those similarity scores are fused with keyword-match scores; for `keyword`, only lexical BM25 matching is applied.
3. Results are ranked by `score` (descending) and paginated via `page[number]` / `page[size]`.

**Authentication:** Requires a Telnyx API key via `Authorization: Bearer <key>`. Results are automatically scoped to your organization and cannot be overridden.

**Filtering:** Use `filter[field][operator]=value` query parameters to narrow results before search. Supported operators: `eq` (default), `in`, `gte`, `gt`, `lte`, `lt`, `contains`. Metadata fields resolve to `metadata.<field>`.

**Examples:**
- `GET /v2/ai/collections/my-collection/documents?query=billing+issue&top_k=10`
- `GET /v2/ai/collections/my-collection/documents?query=refund&sources=voice,message`
- `GET /v2/ai/collections/my-collection/documents?query=outage&filter[record_created_at][gte]=2026-01-01T00:00:00Z`



## OpenAPI

````yaml /openapi/source/external/collections/collections.json get /ai/collections/{slug}/documents
openapi: 3.1.0
info:
  version: 1.0.0
  title: Telnyx API
  x-latency-category: interactive
  x-endpoint-cost: light
  description: >-
    Create and manage AI Collections — logical, searchable groupings of your
    Telnyx product data (voice, meeting bot, and message sources).


    A collection defines *what* data is searchable and *how* it is retrieved.
    You create a collection, attach one or more sources to it, tune its
    retrieval settings, and then run vector or hybrid search scoped to that
    collection. Every collection is automatically scoped to your organization —
    identity is derived from your Telnyx API key and cannot be overridden.
  contact:
    email: support@telnyx.com
servers:
  - url: https://api.telnyx.com/v2
    description: Telnyx API v2
security:
  - bearerAuth: []
tags:
  - name: AI Collections
    description: >-
      Create and manage logical collections of your Telnyx data, tune retrieval
      settings, manage sources, and run collection-scoped semantic search.
paths:
  /ai/collections/{slug}/documents:
    get:
      tags:
        - AI Collections
      summary: Search collection documents
      description: >-
        Runs search over the documents in a collection, ranked by relevance to
        `query`. The collection's `retrieval_type` setting selects the strategy:
        `vector` (semantic similarity), `hybrid` (vector similarity fused with
        keyword matching), or `keyword` (lexical BM25 matching). When `query` is
        omitted, returns a plain catalog listing of the collection's documents.


        **How it works:**

        1. For `vector` and `hybrid`, the `query` text is embedded into a
        1024-dimensional vector using the multilingual-e5-large model.

        2. For `vector`, the embedding is compared against the collection's
        indexed document chunks using semantic similarity; for `hybrid`, those
        similarity scores are fused with keyword-match scores; for `keyword`,
        only lexical BM25 matching is applied.

        3. Results are ranked by `score` (descending) and paginated via
        `page[number]` / `page[size]`.


        **Authentication:** Requires a Telnyx API key via `Authorization: Bearer
        <key>`. Results are automatically scoped to your organization and cannot
        be overridden.


        **Filtering:** Use `filter[field][operator]=value` query parameters to
        narrow results before search. Supported operators: `eq` (default), `in`,
        `gte`, `gt`, `lte`, `lt`, `contains`. Metadata fields resolve to
        `metadata.<field>`.


        **Examples:**

        - `GET
        /v2/ai/collections/my-collection/documents?query=billing+issue&top_k=10`

        - `GET
        /v2/ai/collections/my-collection/documents?query=refund&sources=voice,message`

        - `GET
        /v2/ai/collections/my-collection/documents?query=outage&filter[record_created_at][gte]=2026-01-01T00:00:00Z`
      operationId: SearchCollectionDocuments
      parameters:
        - $ref: '#/components/parameters/Slug'
        - name: query
          in: query
          required: false
          description: >-
            Natural-language search query. When provided, the text is matched
            against the collection's document chunks using the collection's
            `retrieval_type` (vector or hybrid). When omitted, documents are
            returned as a plain catalog listing.
          schema:
            type: string
            minLength: 1
            example: customer called about billing issue
        - name: top_k
          in: query
          required: false
          description: >-
            Maximum number of ranked results to consider. When omitted, the
            collection's configured `top_k` setting is used.
          schema:
            type: integer
            minimum: 1
            maximum: 50
            example: 10
        - name: sources
          in: query
          required: false
          description: >-
            Comma-separated list of source types to restrict the search to. When
            omitted, all of the collection's sources are searched.
          schema:
            type: string
            example: voice,message
        - name: retrieval_type
          in: query
          required: false
          description: >-
            Override the collection's configured retrieval strategy for this
            request. Echoed back in `meta.retrieval_type`.
          schema:
            type: string
            enum:
              - vector
              - hybrid
              - keyword
            example: hybrid
        - name: filter
          in: query
          required: false
          style: deepObject
          explode: true
          description: >-
            Field filters applied before ranking, using
            `filter[field][operator]=value`. Supported operators: `eq`
            (default), `in`, `gte`, `gt`, `lte`, `lt`, `contains`. Known fields:
            `record_type`, `record_id`, `user_id`, `record_created_at`,
            `ingested_at`; any other name resolves to a `metadata.<field>`
            filter. Example: `filter[record_id][eq]=rec_123`.
          schema:
            type: object
            additionalProperties: true
        - $ref: '#/components/parameters/PageNumber'
        - $ref: '#/components/parameters/PageSize'
      responses:
        '200':
          description: Ranked (or listed) collection documents.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CollectionSearchResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          description: The collection does not exist or is not searchable.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Errors'
              example:
                errors:
                  - code: '10005'
                    title: Resource not found
                    detail: The requested resource or URL could not be found.
                    meta:
                      url: https://developers.telnyx.com/docs/overview/errors/10005
        '422':
          description: The collection has no searchable sources.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Errors'
              example:
                errors:
                  - code: '10027'
                    title: Unprocessable Entity
                    detail: >-
                      The server understood the syntax of the request but was
                      unable to process the instructions.
                    meta:
                      url: https://developers.telnyx.com/docs/overview/errors/10027
      x-codeSamples:
        - lang: JavaScript
          source: >-
            import Telnyx from 'telnyx';


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


            const response = await
            client.ai.collections.retrieveDocuments('slug');


            console.log(response.data);
        - lang: Python
          source: |
            import os
            from telnyx import Telnyx

            client = Telnyx(
                api_key=os.environ.get("TELNYX_API_KEY"),  # This is the default and can be omitted
            )
            response = client.ai.collections.retrieve_documents(
                "slug",
            )
            print(response.data)
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/team-telnyx/telnyx-go\"\n\t\"github.com/team-telnyx/telnyx-go/option\"\n)\n\nfunc main() {\n\tclient := telnyx.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tresponse, err := client.AI.Collections.GetDocuments(\n\t\tcontext.TODO(),\n\t\t\"slug\",\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", response.Data)\n}\n"
        - lang: Java
          source: |-
            package com.telnyx.sdk.example;

            import com.telnyx.sdk.client.TelnyxClient;
            import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;

            public final class Main {
                private Main() {}

                public static void main(String[] args) {
                    TelnyxClient client = TelnyxOkHttpClient.fromEnv();

                    var response = client.ai().collections().retrieveDocuments("slug");
                }
            }
        - lang: Ruby
          source: |-
            require "telnyx"

            telnyx = Telnyx::Client.new(api_key: "My API Key")

            response = telnyx.ai.collections.retrieve_documents("slug")

            puts(response)
        - lang: PHP
          source: >-
            <?php


            require_once dirname(__DIR__) . '/vendor/autoload.php';


            use Telnyx\Client;

            use Telnyx\Core\Exceptions\APIException;


            $client = new Client(apiKey: getenv('TELNYX_API_KEY') ?: 'My API
            Key');


            try {
              $response = $client->ai->collections->retrieveDocuments(
                'slug',
              );

              var_dump($response);
            } catch (APIException $e) {
              echo $e->getMessage();
            }
        - lang: CLI
          source: |-
            telnyx ai:collections retrieve-documents \
              --api-key 'My API Key' \
              --slug support-transcripts
components:
  parameters:
    Slug:
      name: slug
      in: path
      required: true
      description: The collection's slug (unique within your organization).
      schema:
        type: string
        example: support-transcripts
    PageNumber:
      name: page[number]
      in: query
      required: false
      description: Page number to return (1-based). Defaults to 1.
      schema:
        type: integer
        minimum: 1
        default: 1
        example: 1
    PageSize:
      name: page[size]
      in: query
      required: false
      description: Number of results per page. Defaults to 20.
      schema:
        type: integer
        minimum: 1
        maximum: 100
        default: 20
        example: 20
  schemas:
    CollectionSearchResponse:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/CollectionDocumentRecord'
        meta:
          $ref: '#/components/schemas/CollectionSearchMeta'
    Errors:
      type: object
      properties:
        errors:
          type: array
          items:
            $ref: '#/components/schemas/Error'
    CollectionDocumentRecord:
      type: object
      properties:
        id:
          type: string
        record_id:
          type: string
        record_type:
          type: string
          description: >-
            The source record kind this chunk came from (e.g. `voice`,
            `meeting_bot`, `message`).
          example: voice
        chunk_index:
          type: integer
        chunk_total:
          type: integer
        text:
          type: string
        score:
          type: number
          format: float
          description: >-
            Relevance score (higher = more relevant) for ranked search. `0.0`
            for plain catalog listings (when `query` is omitted).
        region:
          type: string
        user_id:
          type: string
        organization_id:
          type: string
        record_created_at:
          type: string
          format: date-time
        ingested_at:
          type: string
          format: date-time
        metadata:
          type: object
          additionalProperties: true
    CollectionSearchMeta:
      type: object
      properties:
        collection_slug:
          type: string
          example: support-transcripts
        searched_sources:
          type: array
          items:
            type: string
          example:
            - voice
            - message
        retrieval_type:
          type: string
          example: vector
        top_k:
          type: integer
          example: 5
        total_results:
          type: integer
          example: 42
        total_pages:
          type: integer
          example: 3
        page_number:
          type: integer
          example: 1
        page_size:
          type: integer
          example: 20
    Error:
      type: object
      properties:
        code:
          type: string
        title:
          type: string
        detail:
          type: string
        meta:
          type: object
          additionalProperties: true
          properties:
            pointer:
              type: string
              description: >-
                JSON Pointer to the request field that caused the error. Present
                on field-level validation and conflict errors.
              example: /slug
  responses:
    BadRequest:
      description: The request was malformed or failed validation.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Errors'
          example:
            errors:
              - code: '10015'
                title: Bad Request
                detail: The request failed because it was not well-formed.
                meta:
                  url: https://developers.telnyx.com/docs/overview/errors/10015
    Unauthorized:
      description: Missing or invalid authentication.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Errors'
          example:
            errors:
              - code: '10009'
                title: Authentication failed
                detail: >-
                  The required authentication headers were either invalid or not
                  included in the request.
                meta:
                  url: https://developers.telnyx.com/docs/overview/errors/10009
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Telnyx API key. Collections and results are automatically scoped to the
        authenticated user's organization.

````