---
title: "Search documents across bases in your collection."
method: GET
path: "/api/collections/{collection_id}/search"
---

# Search documents across bases in your collection.

`GET /api/collections/{collection_id}/search`

## Request

- Base URL: `https://okfindex.com`
- URL: `https://okfindex.com/api/collections/{collection_id}/search`
- Auth: none declared

Collections store references, not copied content. They start private. Owner search reads current files in owned bases and published files in other bases. Publication includes only references to currently public bases; private bases and later additions stay out. Every public read checks base publication again. Private or withdrawn collections return 404. Responses use private, no-store.
Returns: { query, items[{document,base,snippet}], next }

## Path parameters

- `collection_id` string, required

## Query parameters

- `q` string, required
- `after` string

## Response `200`

{ query, items[{document,base,snippet}], next }

- object
  - `query` string, required: The requested word or phrase.
  - `items` CollectionSearchResult[], required: Matching documents, their base of origin and a bounded excerpt.
    - `document` Document, required
      - `id` string, required: The 64-character ID returned by the API.
      - `base_id` string, required: The 64-character ID returned by the API.
      - `filename` string, required: Original filename.
      - `title` string, required: Filename without extension.
      - `format` string, required: md, txt, pdf, docx or doc after conversion.
      - `managed` string, nullable, required: dataset for generated metadata; edit through save_base_dataset. Null for ordinary files.
      - `sha256` string, required: SHA-256 of stored UTF-8 text. Converted source hash is source_sha256.
      - `bytes` integer, required: Stored UTF-8 text size in bytes.
      - `status` string, required: ready or pending.
      - `created_at` string, required: Upload date, ISO 8601.
      - `api` string, required: JSON with Markdown.
      - `source_url` string, nullable: Present on document reads: source URL preserved with this version, or null for manual uploads. Also included in the exported OKF concept.
      - `source_sha256` string: SHA-256 of the original converted file.
      - `pages` integer: PDF physical page count. Zero for continuous DOC and DOCX text.
      - `review` object: PDF: completed automated review. DOC/DOCX: not_applicable, null model and zero pages reviewed.
      - `markdown_url` string, required: Markdown download.
      - `original_url` string, required: Original file download.
      - `okf_url` string, required: OKF concept URL.
    - `base` CollectionOrigin, required
      - `id` string, required: The 64-character ID returned by this API.
      - `name` string, required: Name of the base that contains the matching document.
      - `api` string, required: Base API URL for the current viewer.
      - `public_url` string, nullable, required: Public base page, or null for an owned private base.
    - `snippet` string, required: Source excerpt of up to 360 characters.
  - `next` string, nullable, required: Next page URL, or null when the bounded result is complete.

## Other responses

- `400`: Invalid name, cursor, query or idempotency key.
- `401`: A personal account or API key is required.
- `403`: Organization credentials cannot access personal collections.
- `404`: The collection or base is inaccessible.
- `409`: Collection or reference limit reached.
- `413`: Request body exceeds 2 KiB.
- `415`: Use application/json.
- `503`: Collection storage is unavailable.

---

[API](https://skmtc.dev/okfindex/apis/okf-index.md) · [All operations](https://skmtc.dev/okfindex/apis/okf-index/llms.txt) · [OpenAPI document](https://skmtc.dev/okfindex/apis/okf-index/revisions/4b13ca3c739f?raw)
