Skip to main content

API Reference

The Sophic API provides programmatic access to your workspace's knowledge base. All endpoints return JSON and accept a Bearer credential — either a workspace API key or a Personal Access Token (PAT).

Base URL: https://app.sophic.so/api/v1


Authentication

All requests carry the credential in the Authorization header:

curl -H "Authorization: Bearer YOUR_API_KEY" \
https://app.sophic.so/api/v1/documents
  • A workspace API key is bound to one workspace — no extra header needed.
  • A PAT is user-scoped, so it must say which workspace to act in via the x-sophic-workspace: <slug> header.

The read endpoints below accept either credential. The write endpoint (POST /api/ingest/cli, used by the MCP capture tool) requires a PAT — see Authentication.

The v1 read endpoints only serve workspace-visible content. Documents that live in team- or role-scoped folders are not returned.


Endpoints

Documents

MethodPathDescription
GET/api/v1/documentsList documents (paginated)
GET/api/v1/documents/:idGet a single document with full content
MethodPathDescription
GET/api/v1/search?q=...Semantic (vector) search over document sections
GET/api/v1/grep?q=...Exact-string / regex search across documents

Captures

MethodPathDescription
GET/api/v1/capturesList raw buffer captures before consolidation
POST/api/ingest/cliSubmit a capture (PAT only — used by the MCP capture tool)

Common patterns

Pagination

The list endpoints (/documents, /captures) support limit and offset:

curl -H "Authorization: Bearer YOUR_API_KEY" \
"https://app.sophic.so/api/v1/documents?limit=20&offset=40"
ParameterDefaultMaxDescription
limit50100Results per page
offset0Number of results to skip

/documents and /captures also accept ?source=A,B to filter by one or more source values.

grep

When you have an exact identifier rather than a concept — an env-var name, a function name, an error string — use grep instead of search. It runs literal (or regex) line-level matching across the workspace's documents.

curl -H "Authorization: Bearer YOUR_API_KEY" \
"https://app.sophic.so/api/v1/grep?q=SOPHIC_API_KEY"
ParameterTypeDefaultMaxDescription
qstring500 charsThe string (or regex) to find. Required.
regexbooleanfalseTreat q as a POSIX regex
limitnumber50200Maximum matching lines
max_per_docnumber550Cap on matches per document

Returns { text, results }text is a ripgrep-shaped block (<title> (<id>):<line>: <text>) and results is the structured rows.

Error responses

All errors return a JSON object with an error field:

{
"error": "Search failed"
}
StatusMeaning
400Invalid or missing parameters
401Missing or invalid credential
403Credential type not allowed for this endpoint
404Document not found or not accessible
500Server error

Next steps