Skip to content
Seahorse Docs

API Reference

Base URL: https://seahorse.tools/api

Authentication

Seahorse uses JWT tokens for authentication. After registering or logging in, include the token in the Authorization header of every request:

Authorization: Bearer YOUR_JWT_TOKEN

Alternatively, you can use your API key (prefixed with sh_) in the same header:

Authorization: Bearer sh_YOUR_API_KEY

JWT tokens expire after 72 hours. API keys do not expire but can be regenerated (which invalidates the previous key).

Response Format

All responses are JSON. Errors return a detail field:

{
  "detail": "Invalid credentials"
}

Rate Limits

Authentication endpoints (/v1/auth/register, /v1/auth/login) are rate-limited to 10 requests per minute per IP address. Other endpoints are not rate-limited.

Auth Endpoints

No authentication required.

Method Endpoint Description
POST /v1/auth/register Register a new account. Returns JWT + API key.
POST /v1/auth/login Log in. Returns JWT + client_id.
POST /v1/auth/regenerate-key Generate a new API key (requires JWT). Invalidates the old key.

RAG Connection

Method Endpoint Description
POST /v1/connect Connect to a vector database (provider, url, collection_name, api_key)
GET /v1/status RAG status: document count, classification status

Documents

Method Endpoint Description
GET /v1/documents List all editable documents
PUT /v1/documents Update a document's content (body: {"id": "...", "content": "..."})
DELETE /v1/documents Delete a document (body: {"id": "..."})
POST /v1/documents/{id}/analyze Run cognitive cycle on a single document (8-phase loop scoped to one doc)
POST /v1/documents/{id}/export Export document as text or HTML (body: {"format": "text"|"html"})
PUT /v1/documents/{id}/annotations/{annotation_id} Update annotation status (body: {"status": "accepted"|"dismissed"})

PDF Upload

Method Endpoint Description
POST /v1/upload Upload a PDF file (multipart/form-data). Auto-chunked and embedded. Single-file uploads also create an editable document.
GET /v1/upload/quota Get chunk quota usage (used, limit, remaining)

Chunk quotas by tier: Free 100, Starter 5,000, Pro 50,000, Enterprise unlimited.

Cognitive Engine

Method Endpoint Description
POST /v1/cognitive/cycle Trigger a cognitive cycle (body: {"tier": "free"})
GET /v1/cognitive/cycle/{job_id} Get cycle status and progress
DELETE /v1/cognitive/cycle/{job_id} Cancel a running cycle
GET /v1/cognitive/observations List all observations (each includes audit_status: verified, suspect, or pending)
PUT /v1/cognitive/observations/{id}/resolve Approve or reject an observation
POST /v1/cognitive/observations/{id}/apply Apply an action (link, archive, rewrite, merge)
POST /v1/cognitive/observations/{id}/preview Preview a rewrite/merge without applying
GET /v1/cognitive/protocols List active perception protocols
GET /v1/cognitive/evaluations/latest Latest evaluation metrics
GET /v1/cognitive/evaluations/history Evaluation history (timeline data)
GET /v1/cognitive/health Health summary (includes lens_trust_scores per lens)
GET /v1/cognitive/document/{point_id} Fetch a document's content from the RAG
PUT /v1/cognitive/document/{point_id} Edit a document's content
GET /v1/cognitive/knowledge-protocol Current knowledge protocol + known gaps

Write-back

Method Endpoint Description
POST /v1/cognitive/snapshot/{id}/restore Undo a write-back action (restore from snapshot)
GET /v1/cognitive/snapshots List all write-back snapshots
GET /v1/settings/write-back Get current write-back mode
PUT /v1/settings/write-back Set write-back mode (manual, auto_safe, auto_full)

Smart Query

Method Endpoint Description
POST /v1/query Hierarchical retrieval + AI compression into a briefing
GET /v1/query/stats Usage stats (query count, super-chunk count)
POST /v1/smart-query/toggle Enable or disable Smart Query
GET /v1/smart-query/settings Smart Query status and quota

Chat

Method Endpoint Description
POST /v1/chat Chat with Seahorse about your documents (auto-upgrades with Smart Query context)

The chat endpoint accepts an optional sources parameter:

{
  "message": "What are my orphan documents?",
  "sources": "all"
}

Values: "pdf" (uploaded PDFs only), "rag" (connected vector DB only), "all" (both, default). Responses include a citations array with source file name, page number, and relevant excerpt.

Billing

Method Endpoint Description
GET /api/pay/{plan} Redirect to Stripe Checkout (plan: starter, pro, enterprise)
POST /webhook/stripe Stripe webhook (signature-verified)
GET /v1/tier Get current client tier
GET /v1/costs LLM cost summary for the current period

Examples

Register

curl -X POST https://seahorse.tools/api/v1/auth/register \
  -H "Content-Type: application/json" \
  -d '{"email": "you@example.com", "password": "your-password"}'

Returns: {"token": "eyJ...", "client_id": "abc123", "api_key": "sh_..."}

Login

curl -X POST https://seahorse.tools/api/v1/auth/login \
  -H "Content-Type: application/json" \
  -d '{"email": "you@example.com", "password": "your-password"}'

Returns: {"token": "eyJ...", "client_id": "abc123"}

Connect Your RAG

curl -X POST https://seahorse.tools/api/v1/connect \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "provider": "qdrant",
    "url": "https://your-qdrant.example.com:6333",
    "collection_name": "my-docs"
  }'

For Pinecone, use "provider": "pinecone" and include "api_key": "...".

Trigger a Cognitive Cycle

curl -X POST https://seahorse.tools/api/v1/cognitive/cycle \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"tier": "free"}'

Returns: {"job_id": "uuid-here", "status": "running"}. Poll with GET /v1/cognitive/cycle/{job_id}.

Upload a PDF

curl -X POST https://seahorse.tools/api/v1/upload \
  -H "Authorization: Bearer $TOKEN" \
  -F "file=@document.pdf"

Returns: {"chunks_created": 42, "document_id": "doc_..."}. Single-file uploads also create an editable document.

Chat (with source filter)

curl -X POST https://seahorse.tools/api/v1/chat \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"message": "What are my orphan documents?", "sources": "all"}'

Returns: {"response": "Based on the latest analysis...", "citations": [{"source": "guide.pdf", "page": 3, ...}]}

Analyze a Single Document

curl -X POST https://seahorse.tools/api/v1/documents/doc_abc123/analyze \
  -H "Authorization: Bearer $TOKEN"

Returns: {"job_id": "uuid-here", "status": "running"}. Runs the 8-phase cognitive cycle scoped to one document.

Smart Query

curl -X POST https://seahorse.tools/api/v1/query \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"query": "How does our onboarding process work?"}'

Returns a compressed briefing with source references from your RAG.