Skip to main content

Search Documents

GET /v1/documents/search
Search documents by title prefix and/or tag. At least one of q or tag is required. Results are scoped to the authenticated user.

Query Parameters

ParameterTypeRequiredDescription
qstringNo*Title prefix to search for (case-insensitive)
tagstringNo*Exact tag to match from metadata.tags
folder_idstringNoScope results to a specific folder
limitintegerNoMax results (default: 20, max: 50)
offsetintegerNoNumber of results to skip
At least one of q or tag is required.
Required role: documents:read

Example Request

curl "https://api.surfacedocs.dev/v1/documents/search?q=API&tag=guide&limit=10" \
  -H "X-API-Key: sd_live_..."

Response

{
  "results": [
    {
      "id": "doc_abc123",
      "url": "https://app.surfacedocs.dev/d/doc_abc123",
      "folder_id": "fld_xyz",
      "title": "API Documentation",
      "content_type": "markdown",
      "block_count": 15,
      "metadata": {
        "tags": ["api", "guide"],
        "source": "claude-3"
      },
      "visibility": "private",
      "current_version": 3,
      "created_at": "2024-01-01T00:00:00Z",
      "updated_at": "2024-01-02T00:00:00Z"
    }
  ],
  "count": 1,
  "query": "API",
  "tag": "guide",
  "folder_id": null
}

Response Fields

FieldTypeDescription
resultsarrayList of matching documents
countintegerNumber of results returned
querystring | nullThe title query used
tagstring | nullThe tag filter used
folder_idstring | nullThe folder scope used
Each result in results contains:
FieldTypeDescription
idstringDocument ID
urlstringURL to view the document
folder_idstringParent folder ID
titlestringDocument title
content_typestringContent type (markdown, html, text)
block_countintegerNumber of content blocks
metadataobject | nullDocument metadata including tags
visibilitystringDocument visibility
current_versioninteger | nullCurrent version number
created_atstringISO 8601 creation timestamp
updated_atstringISO 8601 last update timestamp

Search Behavior

  • Title search (q): Case-insensitive prefix match. Searching q=api matches “API Documentation”, “api-guide”, etc.
  • Tag search (tag): Exact match against the metadata.tags array.
  • Combined: When both q and tag are provided, results must match both (AND logic).
  • Folder scope: When folder_id is provided, only documents in that folder are searched.

Errors

CodeDescription
422Neither q nor tag provided
401Invalid or missing API key
403API key lacks documents:read role
404Specified folder_id not found