Skip to content
🌐

REST API

Integrate elephant.md into any platform with the REST API.

Get Started

  1. 1
    Get a token

    Log in via the CLI (npx elephant-md login github) or OAuth, then grab your token from ~/.tusk/config.json.

  2. 2
    Make a request
    curl https://elephant.md/api/v1/health
    # => { "status": "ok" }
  3. 3
    Authenticate
    curl -H "Authorization: Bearer <token>" \
      https://elephant.md/api/v1/documents

Authentication

Pass a Bearer token in the Authorization header, or set the elephant_token cookie. Public endpoints work without authentication.

Header
Authorization: Bearer <your-token>

Documents

POST/api/v1/documentsAuth

Create a new document.

Request body
{
  "title": "My Document",
  "content": "# Hello world",
  "category": "guide",
  "visibility": "public",
  "slug": "my-document",
  "description": "A short description",
  "tags": ["ai", "agents"]
}
ParamTypeNote
titlestringrequired
contentstringrequired — markdown
categorystringrequired — guide, reference, tutorial, blog, note, snippet, doc
visibilitystringpublic, unlisted (default), private
slugstringAuto-generated from title if omitted
tagsstring[]Optional tag list
GET/api/v1/documentsAuth

List your documents. Supports filtering and pagination.

QueryTypeNote
visibilitystringFilter by visibility
categorystringFilter by category
limitnumber1–100, default 20
offsetnumberPagination offset
GET/api/v1/documents/@:user/:slug

Fetch a document's full content and metadata.

POST/api/v1/documents/:id/versionsAuth

Push a new version of an existing document.

Request body
{ "content": "# Updated content" }
PATCH/api/v1/documents/:idAuth

Update document metadata (title, visibility, tags, etc.).

Request body
{
  "title": "New Title",
  "visibility": "public",
  "category": "guide",
  "tags": ["updated"],
  "pin_order": 1
}
DELETE/api/v1/documents/:idAuth

Permanently delete a document and all its versions.

POST/api/v1/documents/:id/restoreAuth

Restore a previous version by content hash.

Request body
{ "hash": "abc123..." }

Bookmarks

POST/api/v1/documents/:id/bookmarkAuth

Toggle a bookmark on a document. Calling again removes it.

Response
{
  "bookmarked": true,
  "bookmarkCount": 12
}
GET/api/v1/bookmarksAuth

List your bookmarked documents with pagination.

QueryTypeNote
limitnumber1–100, default 20
offsetnumberPagination offset

Collections

Organize documents into named collections. All endpoints require authentication.

POST/api/v1/collectionsAuth

Create a new collection.

Request body
{
  "name": "AI Agents Toolkit",
  "description": "Essential prompts and configs",
  "visibility": "public"
}
GET/api/v1/collectionsAuth

List your collections with item counts.

GET/api/v1/collections/:id

Get a collection's details and all its items.

PATCH/api/v1/collections/:idAuth

Update collection name, description, or visibility.

Request body
{
  "name": "Updated Name",
  "visibility": "private"
}
DELETE/api/v1/collections/:idAuth

Delete a collection. Items are not deleted.

POST/api/v1/collections/:id/itemsAuth

Add a document to a collection.

Request body
{ "documentId": "abc-123-..." }
DELETE/api/v1/collections/:id/items/:docIdAuth

Remove a document from a collection.

PATCH/api/v1/collections/:id/itemsAuth

Reorder items in a collection.

Request body
{ "order": ["id-1", "id-2", "id-3"] }

Users & Profiles

GET/api/v1/users/@:username

Get a public user profile with their documents.

QueryTypeNote
limitnumber1–100, default 20
offsetnumberPagination offset
Response
{
  "username": "nickbrooks",
  "displayName": "Nick Brooks",
  "bio": "...",
  "avatarUrl": "https://...",
  "documents": [...],
  "total": 15
}

Installs

Track agent installs for documents. Used by the CLI and MCP server to record which documents have been installed.

POST/api/v1/installsAuth

Record a document install.

Request body
{
  "documentId": "abc-123-...",
  "agentType": "claude"
}
GET/api/v1/installsAuth

List your installed documents.

Rate Limits

Rates scale with your trust tier (0–3). Every response includes rate limit headers.

Response headers
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 58
X-RateLimit-Reset: 1709836800

When rate limited, the API returns 429 with a retryAfter field in seconds.

Error Handling

All errors return a consistent JSON shape with an error code and human-readable message.

Error response
{
  "ok": false,
  "code": "NOT_FOUND",
  "message": "Document not found"
}
CodeStatusMeaning
UNAUTHORIZED401Missing or invalid token
NOT_FOUND404Resource does not exist
VALIDATION_ERROR400Invalid request data
CONFLICT409Slug or resource already exists
RATE_LIMITED429Too many requests
CONTENT_BLOCKED422Content scanning rejected