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

# Get Document by Filename

> Retrieve a document by filename within a space. Includes document content. Useful when you know the filename but not the document ID.



## OpenAPI

````yaml api/openapi.json get /api/documents/by-filename
openapi: 3.1.0
info:
  version: '0.1'
  title: Orchata API
servers:
  - url: https://api.orchata.ai
    description: Orchata API Server
security:
  - ApiKey: []
paths:
  /api/documents/by-filename:
    get:
      tags:
        - Documents
      summary: Get Document by Filename
      description: >-
        Retrieve a document by filename within a space. Includes document
        content. Useful when you know the filename but not the document ID.
      parameters:
        - schema:
            type: string
            description: The ID of the space containing the document
            example: space_123
          required: true
          description: The ID of the space containing the document
          name: spaceId
          in: query
        - schema:
            type: string
            description: The filename to search for
            example: my-notes.md
          required: true
          description: The filename to search for
          name: filename
          in: query
      responses:
        '200':
          description: Successfully retrieved document
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                  filename:
                    type: string
                  status:
                    type: string
                  metadata:
                    type: object
                    additionalProperties: {}
                  content:
                    type: string
                  mimeType:
                    type: string
                  fileSize:
                    type: string
                  createdAt:
                    type: string
                  updatedAt:
                    type: string
                required:
                  - id
                  - filename
                  - status
                  - metadata
                  - content
                  - mimeType
                  - fileSize
                  - createdAt
                  - updatedAt
        '401':
          description: Authentication required
        '404':
          description: Document not found
      x-codeSamples:
        - lang: typescript
          label: TypeScript SDK
          source: |-
            import { Orchata } from '@orchata-ai/sdk';

            const client = new Orchata({ apiKey: 'oai_your_api_key' });

            const doc = await client.documents.getByFilename({
              spaceId: 'space_123',
              filename: 'to-do.md'
            });

            console.log(doc.content);
components:
  securitySchemes:
    ApiKey:
      type: apiKey
      in: header
      name: Oai-Api-Key

````