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

# Workspace: Glob

> Find files in the agent's workspace matching a glob pattern

Find files in the per-agent workspace matching a glob pattern (e.g. `**/*.py`). Useful for discovering files before reading or editing them.

## Path Parameters

<ParamField path="agent_id" type="string" required>
  Agent ID (UUID)
</ParamField>

## Request Body

<ParamField body="pattern" type="string" required>
  Glob pattern to match (e.g. `**/*.py`).
</ParamField>

<ParamField body="root_dir" type="string">
  Directory to search from, relative to the workspace root. Defaults to the workspace root when omitted.
</ParamField>

<ParamField body="max_results" type="integer" default={1000}>
  Maximum number of matches to return.
</ParamField>

## Response

<ResponseField name="status" type="string">
  Result status (e.g., `ok`).
</ResponseField>

<ResponseField name="matches" type="array">
  Array of matching file paths.
</ResponseField>

## Example Request

```bash theme={"dark"}
curl -X POST "https://api.xpander.ai/v1/agents/<agent-id>/workspace/glob" \
  -H "Content-Type: application/json" \
  -H "x-api-key: <your-api-key>" \
  -d '{
    "pattern": "**/*.py",
    "root_dir": "src",
    "max_results": 1000
  }'
```

## Notes

* Use `**` to match across directory boundaries and `*` to match anything within a single path segment.
* Combine with [Workspace: Grep](/api-reference/v1/agents/workspace/grep) to search the contents of the matched files.

## See Also

* [Workspace: Grep](/api-reference/v1/agents/workspace/grep)
* [Workspace: File Read](/api-reference/v1/agents/workspace/file-read)


## OpenAPI

````yaml POST /v1/agents/{agent_id}/workspace/glob
openapi: 3.1.0
info:
  title: xpander.ai API Service
  description: |2-

        The xpander.ai API Service provides a unified REST API for managing AI agents,
        executing tasks, managing knowledge bases, and integrating with external systems.
        
        Features:
        - Agent Management: Create, update, deploy, and delete AI agents
        - Task Execution: Invoke agents with support for sync, async, and streaming modes
        - Knowledge Bases: Manage knowledge bases and documents for RAG workflows
        - Tools: Discover, connect, and attach tools (connectors, custom functions, MCP servers, sub-agents, workflows) to agents and workflows
        - MCP Integration: Model Context Protocol support for standardized AI interactions
        
        Authentication: All endpoints require authentication via either an API key (`x-api-key`) or an OAuth2 JWT (`Authorization: Bearer <jwt>`).
        
  version: '0.001'
servers:
  - url: https://api.xpander.ai
security: []
paths:
  /v1/agents/{agent_id}/workspace/glob:
    post:
      tags:
        - API v1
        - Agents
        - Agents Workspace
      summary: 'Workspace: Glob'
      description: Find files in the agent's workspace matching a glob pattern.
      operationId: Workspace__Glob_v1_agents__agent_id__workspace_glob_post
      parameters:
        - name: agent_id
          in: path
          required: true
          schema:
            type: string
            title: Agent Id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GlobRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GlobResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - APIKeyHeader: []
components:
  schemas:
    GlobRequest:
      properties:
        pattern:
          type: string
          title: Pattern
          description: >-
            Glob pattern for file matching. Supports ** for recursive matching,
            * for wildcards.
          examples:
            - '**/*.py'
        root_dir:
          type: string
          title: Root Dir
          description: Root directory to search from, relative to workspace root.
          default: ''
          examples:
            - src
        max_results:
          type: integer
          maximum: 50000
          minimum: 1
          title: Max Results
          description: >-
            Maximum number of results to return. Prevents excessive output for
            broad patterns.
          default: 1000
      type: object
      required:
        - pattern
      title: GlobRequest
    GlobResponse:
      properties:
        matches:
          items:
            type: string
          type: array
          title: Matches
          description: List of matched file paths
        total_found:
          type: integer
          title: Total Found
          description: Total number of files matching the pattern
          default: 0
        truncated:
          type: boolean
          title: Truncated
          description: True if results were truncated due to max_results limit
          default: false
      type: object
      title: GlobResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      description: API Key for authentication
      in: header
      name: x-api-key

````