REST API

curl-able knowledge: the REST API for your base

Base URL https://the-snip.com/api/v1. Authenticate with a workspace API key — Authorization: Bearer snip_..., generated in Settings → API keys. Same service layer, same review gate as MCP: CI scripts, bots and cron jobs use the identical nine operations.

Reads are free — any agent can search the base on the Free plan, and every Free workspace gets 5 free agent writes (review-gated). Unlimited agent writes (create and update) are part of Pro & Team, $8/user/mo.

The nine operations

MethodPathRequest fieldsResponse
POST/api/v1/searchall optional: query, type (snippet | api | doc | webpage), language, collectionId, tags, sort (relevance | updated | created | title), limit200 — matching items
POST/api/v1/snippetstitle, language, code · optional: description, collectionId, sampleOutput, tags (≤10 names; absent → up to 3 suggested)201 — created item, status in review
POST/api/v1/apistitle, method, url · optional: description, collectionId, headers (JSON), requestBody, sampleResponse201 — created item, status in review
POST/api/v1/docstitle, body · optional: description, collectionId[[wikilinks]] supported in body201 — created item, status in review
POST/api/v1/webpagestitle, sourceUrl, body · optional: description, collectionIdsourceUrl must be an absolute http(s) URL; body is the page content as Markdown201 — created item, status in review
GET/api/v1/items/{id}none — the id is the path; take ids from search results, never guess them200 — full item · 404 not found
PATCH/api/v1/items/{id}any create field, all optional (a patch)200 — updated item · 404 not found
GET/api/v1/collectionsnone200 — the workspace's collections (id and name)
POST/api/v1/collectionsname · optional: description201 — created collection (no review; doesn't count against the item cap)

Search is a POST with a JSON body, not a query-string read — a bare read probe on the search path answers 405 with the method contract. There are no delete endpoints on the v1 surface today: these nine operations are the whole API, and this page documents all of it.

First call in one paste

// search the base
curl -X POST https://the-snip.com/api/v1/search \
  -H "Authorization: Bearer snip_YOUR_KEY" -H "Content-Type: application/json" \
  -d '{"query":"retry with backoff","type":"snippet"}'

Returns an array of matching items (truncated):

// 200 — matching items
[
  {
    "id": "0198f2c1-4e2a-7d31-b3a4-9c6d2f8e1a07",
    "workspaceId": "…",
    "type": "snippet",
    "status": "approved",
    "title": "Retry with exponential backoff",
    "language": "typescript",
    "code": "export async function retry(fn, tries = 3) { /* ... */ }",
    "updatedAt": "2026-07-12T09:30:00.000Z",
    ...
  }
]
// file a snippet
curl -X POST https://the-snip.com/api/v1/snippets \
  -H "Authorization: Bearer snip_YOUR_KEY" -H "Content-Type: application/json" \
  -d '{"title":"Retry with exponential backoff","language":"typescript","code":"export async function retry(fn, tries = 3) { /* ... */ }"}'

Returns 201 with the created item — agent writes land in review ("status": "in_review") until a human approves:

// 201 — created, in review
{
  "id": "0198f2c1-9b57-7aa2-8c11-2e5f7d4b6c93",
  "workspaceId": "…",
  "type": "snippet",
  "status": "in_review",
  "createdVia": "agent",
  "title": "Retry with exponential backoff",
  "language": "typescript",
  "createdAt": "2026-07-12T09:31:00.000Z",
  ...
}
// update an item
curl -X PATCH https://the-snip.com/api/v1/items/ITEM_ID \
  -H "Authorization: Bearer snip_YOUR_KEY" -H "Content-Type: application/json" \
  -d '{"description":"Adds jitter between attempts."}'

Returns 200 with the updated item — updates are re-gated to review — or 404 when the id is not visible in your workspace.

Error shapes — exactly what failure looks like

Every error is {"error":{"code","message"}} plus machine-actionable fields. These are the real bodies, verbatim:

// 400 — body is not valid JSON
{"error":{"code":"invalid_json","message":"Body must be valid JSON"}}

Send a JSON body with Content-Type: application/json — watch for shell quoting eating your quotes.

// 400 — schema validation failed
{"error":{"code":"invalid_request","message":"Invalid request","details":[{"path":"title","message":"..."}]}}

The details array names the exact field and message — agents can self-correct from the body alone. Schemas are strict: unknown fields (including status) are rejected, not ignored.

// 401 — missing or invalid key
{"error":{"code":"unauthorized","message":"Missing API key"}}
{"error":{"code":"unauthorized","message":"Invalid API key"}}

Send Authorization: Bearer snip_... — keys are generated in Settings → API keys.

// 403 — free agent writes spent, or the Free item cap
{"error":{"code":"forbidden","message":"You've used your 5 free agent writes — they landed in your review queue. Unlimited agent writes are part of Pro & Team ($8/user): https://the-snip.com/upgrade"}}
{"error":{"code":"forbidden","message":"Free plan cap reached (25 items). Upgrade for unlimited: https://the-snip.com/upgrade"}}

Reads never 403 for plan. Free workspaces get 5 free agent writes (review-gated); both bodies name the remedy: upgrade at the-snip.com/upgrade and the same key keeps writing.

// 429 — rate limit (60 requests/min per workspace)
{"error":{"code":"rate_limited","message":"Rate limit exceeded (60/min per workspace). Retry in 21s","retry_after_sec":21}}

The response also carries a Retry-After header with the same seconds value — back off and retry.

// 404 — id not visible in your workspace
{"error":{"code":"not_found","message":"Not found"}}

Returned for unknown ids and for ids in other workspaces — existence is never disclosed across tenants.

Rate limit: 60 requests per minute per workspace, across all nine operations.

Hand this API to your LLM

Download a Markdown file that teaches any AI assistant this whole API — the nine operations, the review gate, the error contract. Paste it into your CLAUDE.md, project instructions, or system prompt.

// the-snip-api-setup.md — REST setup, for your agent's context
Download the API setup file

The CLI

A zero-dependency, single-file CLI (Node >= 20, built-in fetch — nothing to install beyond Node) that wraps the same API. It adds no operations of its own.

// install (macOS / Linux)
curl -fsSL https://the-snip.com/cli -o ~/.local/bin/the-snip && chmod +x ~/.local/bin/the-snip

Windows: iwr https://the-snip.com/cli -OutFile the-snip.mjs then run commands as node the-snip.mjs <command> — no chmod or shebang on Windows.

Quickstart: the-snip login snip_...with a key from Settings → API keys, then you're in.

CommandWhat it does
the-snip login snip_...store your workspace API key (~/.the-snip/config.json)
the-snip search "query"search the base — --limit, --type snippet|api|doc|webpage
the-snip get <id>print an item's raw code/body/url to stdout — pipeable
the-snip create snippet --title T -l lang [file]file a snippet from a file or stdin — --description, --tags a,b
the-snip whoamimasked key, base URL, and a validity probe

Add --json to any command to get the raw response body for scripts. Errors print the real server message — including upgrade URLs and retry_after on a 429.

Same base, native protocol

Prefer MCP? The hosted MCP server exposes the same nine operations as native tools for Claude Code, Cursor, OpenClaw, Hermes and any MCP client. The REST surface fits a shared team API request library and anything that can run curl.

Questions, answered.

Is the REST API free?

Reads are free on every plan — any agent can search the base and fetch items on the Free plan. Every Free workspace also gets 5 free agent writes (review-gated, lifetime). Unlimited agent writes (create and update) are part of Pro & Team, $8/user/mo. Once the 5 free writes are spent, a write from a Free workspace returns 403 with a message pointing at the-snip.com/upgrade, and the items already filed stay in the review queue.

How do I authenticate with The-Snip's REST API?

Every request carries a workspace API key as Authorization: Bearer snip_..., generated in Settings → API keys. Keys are workspace-scoped and hashed at rest; a missing or invalid key returns 401. The base URL is https://the-snip.com/api/v1, and the same key works over both REST and the hosted MCP server.

What endpoints does the REST API expose?

Nine operations: POST /search, GET /items/{id}, GET /collections and POST /collections, plus the four creators POST /snippets, /apis, /docs and /webpages, and PATCH /items/{id} to update. There are no delete endpoints on the v1 surface today — these nine are the whole API.

Do REST writes need approval?

Yes. Every item write — POST to /snippets, /apis, /docs, /webpages or a PATCH to /items/{id} — lands with status "in_review" until a human approves it; updating an approved item re-gates it. Creating a collection (POST /collections) is the exception: it returns 201 with no review, because a collection is organizational metadata.

Is there a rate limit on the REST API?

Yes — 60 requests per minute per workspace, across all nine operations. A 429 response carries a retry_after field so clients can back off cleanly.

Start your base — free.

Free: 25 items, no card — plus agent search over the REST API and the hosted MCP server, and 5 free agent writes (review-gated). Pro & Team: $8/user/mo — unlimited items, unlimited agent writes, export/import, team workspaces and review.