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

# List knowledge sources

> Returns the agent's knowledge sources, newest first.



## OpenAPI

````yaml /openapi.yaml get /agents/{agentId}/sources
openapi: 3.0.3
info:
  title: ReyGrid API
  version: 1.0.3
  description: |
    ReyGrid API

    ## Persistent user conversations

    If you want to build a separate conversation system for each user,
    build a wrapper layer around the ReyGrid API.

    The wrapper should manage the application's own user IDs and map them
    to ReyGrid conversations.

    The wrapper is responsible for:
    - Managing and identifying users.
    - Storing the relationship between the application's userId and
      ReyGrid conversationId.
    - Persisting conversation IDs in the application's own database.
    - Reusing the stored conversationId when the same user continues
      a conversation.
    - Verifying that conversation IDs belong to the expected user before
      using them.

    ReyGrid's userId can also be used as a stable identifier for persistent
    conversations. However, if the application requires its own user and
    conversation management, it should maintain this mapping in its own
    database.
servers:
  - url: https://reygrid.com/api/v1
security: []
paths:
  /agents/{agentId}/sources:
    get:
      summary: List knowledge sources
      description: Returns the agent's knowledge sources, newest first.
      operationId: listSources
      parameters:
        - $ref: '#/components/parameters/AgentId'
        - name: type
          in: query
          required: false
          description: Only return sources of this type.
          schema:
            $ref: '#/components/schemas/SourceType'
        - name: search
          in: query
          required: false
          description: Filter by title or file name (case-insensitive).
          schema:
            type: string
            maxLength: 100
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/Size'
      responses:
        '200':
          description: Knowledge sources
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SourcesResponse'
              example:
                success: true
                sources:
                  - id: b7a1e2c4-5d3f-4e8a-9b10-2c4d6e8f0a1b
                    type: text
                    title: Refund policy
                    content: Orders can be refunded within 30 days of delivery.
                    createdAt: '2026-10-04T09:12:00.000Z'
                  - id: 661a6da1-181f-43ac-9516-9847b9dd663b
                    type: file
                    title: handbook.pdf
                    size: 482113
                    createdAt: '2026-10-02T15:40:21.000Z'
                  - id: 0f3c9a7e-2b1d-4c6e-8a5f-7d9b1e3c5a7f
                    type: website
                    title: docs.example.com/pricing
                    createdAt: '2026-09-30T11:05:44.000Z'
                pagination:
                  totalSources: 92
                  totalPages: 31
                  currentPage: 1
                  pagingCounter: 1
                  hasNextPage: true
        '400':
          $ref: '#/components/responses/InvalidBody'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
      security:
        - apiKeyAuth: []
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl
            "https://reygrid.com/api/v1/agents/{AgentId}/sources?type=text&search=refund&size=20"
            \
              -H "Authorization: Bearer $REYGRID_API_KEY"
        - lang: python
          label: Python SDK
          source: |-
            from reygrid import ReyGrid

            client = ReyGrid(api_key="YOUR_API_KEY")

            res = client.list_sources("{AgentId}", type="text", search="refund")
            for source in res.sources:
                print(source.id, source.title)

            # Or every source, page by page
            for page in client.paginate_sources("{AgentId}"):
                for source in page.data:
                    print(source.type, source.title)
        - lang: javascript
          label: TypeScript SDK
          source: >-
            import { ReyGrid } from "reygrid";


            const client = new ReyGrid({ apiKey: "YOUR_API_KEY" });


            const { sources } = await client.listSources("{AgentId}", { type:
            "text", search: "refund" });


            // Or every source, page by page

            const all = await client.paginateSources("{AgentId}").all();
components:
  parameters:
    AgentId:
      name: agentId
      in: path
      required: true
      description: The ID of the agent.
      schema:
        type: string
    Page:
      name: page
      in: query
      required: false
      description: Page number.
      schema:
        type: integer
        minimum: 1
        default: 1
    Size:
      name: size
      in: query
      required: false
      description: Number of items per page.
      schema:
        type: integer
        minimum: 1
        maximum: 100
        default: 20
  schemas:
    SourceType:
      type: string
      enum:
        - text
        - qa
        - file
        - website
    SourcesResponse:
      type: object
      properties:
        success:
          type: boolean
        sources:
          type: array
          items:
            $ref: '#/components/schemas/Source'
        pagination:
          type: object
          properties:
            totalSources:
              type: integer
            totalPages:
              type: integer
            currentPage:
              type: integer
            pagingCounter:
              type: integer
            hasNextPage:
              type: boolean
    Source:
      type: object
      properties:
        id:
          type: string
        type:
          $ref: '#/components/schemas/SourceType'
        title:
          type: string
          description: The title, question, file name or page URL.
        content:
          type: string
          description: The text or answer. Only for text and qa sources.
        size:
          type: integer
          description: File size in bytes. Only for file sources.
        createdAt:
          type: string
          format: date-time
    ErrorResponse:
      type: object
      required:
        - success
        - error
      properties:
        success:
          type: boolean
        output:
          type: object
          additionalProperties: true
        error:
          $ref: '#/components/schemas/Error'
        usage:
          $ref: '#/components/schemas/ChatUsage'
    AuthErrorResponse:
      type: object
      required:
        - error
        - code
      properties:
        error:
          type: string
          example: Unauthorized
        code:
          type: string
          example: AUTH_REQUIRED
    Error:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: string
        message:
          type: string
        list:
          type: array
          description: |
            Validation error details.
            Present when error.code is INVALID_BODY.
          items:
            $ref: '#/components/schemas/ValidationErrorItem'
    ChatUsage:
      type: object
      required:
        - credits
      properties:
        credits:
          type: number
    ValidationErrorItem:
      type: object
      additionalProperties: true
  responses:
    InvalidBody:
      description: Invalid body or query (INVALID_BODY)
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            success: false
            error:
              code: INVALID_BODY
              message: Invalid body
              list:
                title:
                  - Title too short
    Unauthorized:
      description: API key is missing or invalid
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/AuthErrorResponse'
          example:
            error: Unauthorized
            code: AUTH_REQUIRED
    NotFound:
      description: The agent, source or message doesn't exist, or the key can't access it
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            success: false
            error:
              code: SOURCE_NOT_FOUND
              message: This source does not exist
  securitySchemes:
    apiKeyAuth:
      type: http
      scheme: bearer
      bearerFormat: API-Key
      description: ReyGrid API key sent as a Bearer token.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.