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

# Search Files

> Search through user's uploaded files using vector similarity with AI reranking.

**Namespace filtering:** Pass `namespace_ids` to restrict the search to files in specific namespaces. If omitted, all namespaces are searched.

**Process:**
1. Vector similarity search using text embeddings
2. Initial ranking by semantic similarity
3. AI reranking for improved relevance
4. Rich metadata and signed URLs for file access
5. Optional per-file AI analysis for people, places, key subjects, and key moments

Each result includes the `namespace_ids` and resolved `namespaces` the file belongs to.

Set `include_usage=true` to receive the `usage` block, with the request's token counts.

Search your uploaded files using vector similarity and AI reranking.

## Overview

This endpoint searches through your uploaded file library using OpenAI embeddings for semantic similarity, followed by AI reranking for improved relevance. Results include rich metadata, signed URLs, and optional per-file analysis.

## Billing

File search is a semantic (vector) search over already indexed content and consumes **one `search_request`** per call. 1 credit covers 1,000 semantic searches. If the AI analysis pass runs (per-file + overall aggregation), it also bills `analysis_request` as `ceil(total_tokens / 15000)` units (minimum 1 when analysis ran).

Set `include_usage: true` to receive a [`usage`](https://docs.vidnavigator.com/api-reference/usage-costs.md#per-call-usage-disclosure) block with the per-charge breakdown — the consolidated `analysis_request` entry carries a nested `tokens` object.

### Search Process

1. Vector similarity search using OpenAI embeddings
2. Initial ranking by semantic similarity
3. AI reranking for improved relevance
4. Rich metadata and signed URLs for file access
5. Optional per-file AI analysis for people, places, key subjects, and key moments

## Request Body

| Parameter       | Type      | Required | Description                                                             |
| --------------- | --------- | -------- | ----------------------------------------------------------------------- |
| `query`         | string    | Yes      | Search query                                                            |
| `namespace_ids` | string\[] | No       | Restrict search to specific namespaces. If omitted, searches all files. |

## Example Request

```bash cURL
curl -X POST "https://api.vidnavigator.com/v1/search/file" \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "What did the customer say about pricing?"
  }'
```

```bash cURL (with namespace filter)
curl -X POST "https://api.vidnavigator.com/v1/search/file" \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "What did the customer say about pricing?",
    "namespace_ids": ["64a1b2c3d4e5f6789abc0002"]
  }'
```

```python Python
import requests

url = "https://api.vidnavigator.com/v1/search/file"
headers = {
    "X-API-Key": "YOUR_API_KEY",
    "Content-Type": "application/json"
}
data = {
    "query": "What did the customer say about pricing?",
    "namespace_ids": ["64a1b2c3d4e5f6789abc0002"]
}

response = requests.post(url, headers=headers, json=data)
results = response.json()
```

```javascript JavaScript
const response = await fetch('https://api.vidnavigator.com/v1/search/file', {
  method: 'POST',
  headers: {
    'X-API-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    query: 'What did the customer say about pricing?',
    namespace_ids: ['64a1b2c3d4e5f6789abc0002']
  })
});

const results = await response.json();
```

## Success Response

```json
{
  "status": "success",
  "data": {
    "results": [
      {
        "id": "file_abc123",
        "name": "client-call-march.mp4",
        "duration": 1800,
        "size": 52428800,
        "type": "video/mp4",
        "status": "completed",
        "created_at": "2026-03-10T14:00:00Z",
        "file_url": "https://storage.example.com/signed-url...",
        "namespace_ids": ["64a1b2c3d4e5f6789abc0002"],
        "namespaces": [
          { "id": "64a1b2c3d4e5f6789abc0002", "name": "Client Calls" }
        ],
        "relevance_score": 0.92,
        "timestamps": [245.5, 890.2],
        "relevant_text": "The customer mentioned the pricing was competitive but wished for a monthly option.",
        "query_answer": "The customer found pricing competitive but requested monthly billing.",
        "transcript_summary": "A 30-minute client call discussing product features, pricing, and onboarding timeline.",
        "people": [
          { "name": "John Smith", "context": "Client representative" }
        ],
        "key_subjects": [
          { "name": "Pricing", "description": "Discussion about pricing tiers and billing options" }
        ]
      }
    ],
    "query": "What did the customer say about pricing?",
    "total_found": 1,
    "explanation": "Found 1 file matching your query about customer pricing feedback."
  }
}
```

## OpenAPI

````yaml POST /search/file
openapi: 3.0.3
info:
  title: VidNavigator Developer API
  version: 1.0.0
servers:
  - url: https://api.vidnavigator.com/v1
    description: Production server
security:
  - ApiKeyAuth: []
paths:
  /search/file:
    post:
      summary: Search uploaded files
      description: |-
        Search through user's uploaded files using vector similarity with AI reranking.

        **Namespace filtering:** Pass `namespace_ids` to restrict the search to files in specific namespaces. If omitted, all namespaces are searched.

        **Process:**
        1. Vector similarity search using text embeddings
        2. Initial ranking by semantic similarity
        3. AI reranking for improved relevance
        4. Rich metadata and signed URLs for file access
        5. Optional per-file AI analysis for people, places, key subjects, and key moments

        Each result includes the `namespace_ids` and resolved `namespaces` the file belongs to.

        Set `include_usage=true` to receive the `usage` block, with the request's token counts.
      operationId: searchFiles
      tags:
        - Search
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - query
              properties:
                query:
                  type: string
                  description: Search query
                  example: What did the customer say about pricing?
                namespace_ids:
                  type: array
                  items:
                    type: string
                  description: Optional list of namespace IDs to restrict search scope. If not provided, all namespaces are searched.
                include_usage:
                  type: boolean
                  default: false
                  description: When true, the response includes the `usage` block of this request.
      responses:
        "200":
          description: Search completed successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    enum:
                      - success
                  data:
                    type: object
                    properties:
                      results:
                        type: array
                        items:
                          $ref: "#/components/schemas/FileSearchResult"
                      query:
                        type: string
                      total_found:
                        type: integer
                      explanation:
                        type: string
                  usage:
                    $ref: "#/components/schemas/UsageBlock"
        "400":
          $ref: "#/components/responses/BadRequest"
        "402":
          $ref: "#/components/responses/PaymentRequired"
        "500":
          $ref: "#/components/responses/InternalServerError"
components:
  schemas:
    FileSearchResult:
      type: object
      properties:
        id:
          type: string
          description: File ID
        name:
          type: string
          description: File name
        duration:
          type: number
          description: Duration in seconds
        size:
          type: integer
          description: File size in bytes
        type:
          type: string
          description: MIME type
        status:
          type: string
          enum:
            - completed
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
        original_file_date:
          type: string
          format: date-time
        file_url:
          type: string
          format: uri
          description: "Short-lived signed storage URL pointing directly at the file bytes. Same model as AWS S3 / CloudFront pre-signed URLs: time-limited and resource-scoped."
          example: https://storage.example.com/path/to/file?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Signature=...
        namespace_ids:
          type: array
          items:
            type: string
          description: IDs of the namespaces this file belongs to
        namespaces:
          type: array
          items:
            $ref: "#/components/schemas/NamespaceRef"
          description: Resolved namespaces this file belongs to (with names)
        relevance_score:
          type: number
          description: AI relevance score (0-1)
        timestamps:
          type: array
          items:
            type: number
          description: Key moment timestamps in seconds extracted from supporting evidence
        relevant_text:
          type: string
          description: Key quote from the file content
        query_answer:
          type: string
          description: Direct answer to the query
        transcript_summary:
          type: string
          description: Summary of the file's transcript
        people:
          type: array
          items:
            type: object
            properties:
              name:
                type: string
              context:
                type: string
        places:
          type: array
          items:
            type: object
            properties:
              name:
                type: string
              context:
                type: string
        key_subjects:
          type: array
          items:
            type: object
            properties:
              name:
                type: string
              description:
                type: string
    NamespaceRef:
      type: object
      description: Resolved namespace reference with ID and display name
      properties:
        id:
          type: string
          description: Namespace identifier
        name:
          type: string
          description: Namespace display name
    UsageBlock:
      type: object
      description: |-
        Per-call usage, returned only when the request sets `include_usage=true`: the charges of this request, one entry per `service_type`, and the total credits deducted. A waived charge carries `waived: true` and `credits_saved`, with a top-level `waived.credits_saved` summary.

        For endpoints that run an AI analysis (`/extract/video`, `/extract/file`, `/analyze/video`, `/analyze/file`, `/youtube/search`), the `analysis_request` entry carries a nested `tokens` object with the request's token counts.
      properties:
        charges:
          type: array
          description: The charges of this request, one entry per `service_type`. A charge reversed within the request is left out.
          items:
            type: object
            properties:
              service_type:
                type: string
                enum:
                  - standard_request
                  - residential_request
                  - transcription_hour
                  - analysis_request
                  - search_request
                  - scene_analysis_hour
                  - frame_analysis
                description: The kind of charge.
              quantity:
                type: number
                description: Net units consumed (hours for `transcription_hour`, frames for `frame_analysis`).
              credits:
                type: number
                description: Net credits deducted for this charge; 0 when it was waived.
              waived:
                type: boolean
                description: True when this charge was waived.
              credits_saved:
                type: number
                description: When waived=true, the credits that would have been charged otherwise.
              tokens:
                type: object
                description: "Only on the `analysis_request` entry of endpoints that run an AI analysis: the request's total token counts."
                properties:
                  prompt_tokens:
                    type: integer
                    description: Total input tokens.
                  completion_tokens:
                    type: integer
                    description: Total output tokens.
                  total_tokens:
                    type: integer
                    description: Sum of `prompt_tokens` + `completion_tokens`.
        total_credits:
          type: number
          description: Net credits deducted by this request (sum of all `charges[].credits`).
        waived:
          type: object
          description: Present only when one or more charges in this request were waived.
          properties:
            credits_saved:
              type: number
              description: Total credits waived on this request.
  responses:
    BadRequest:
      description: Bad request - invalid parameters. On /transcribe the `error` field may be `missing_parameter`, `unsupported_platform`, `unsupported_url`, `invalid_url`, `request_body_required`, `video_too_long`, or `no_videos_found` (the post carries no video).
      content:
        application/json:
          schema:
            type: object
            properties:
              status:
                type: string
                enum:
                  - error
              error:
                type: string
              message:
                type: string
    PaymentRequired:
      description: Usage limit exceeded - upgrade required
      content:
        application/json:
          schema:
            type: object
            properties:
              status:
                type: string
                enum:
                  - error
              error:
                type: string
                enum:
                  - limit_exceeded
              message:
                type: string
    InternalServerError:
      description: Internal server error
      content:
        application/json:
          schema:
            type: object
            properties:
              status:
                type: string
                enum:
                  - error
              error:
                type: string
                enum:
                  - metadata_fetch_failed
                  - audio_extraction_failed
                  - transcription_failed
                  - internal_server_error
              message:
                type: string
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: API key authentication. Include your VidNavigator API key in the X-API-Key header.
````
