Overview
The Docs API lets you manage rich text documents in Copera. Documents support hierarchical nesting, Markdown content, full-text search, and asynchronous content updates. Requires a Personal Access Token (cp_pat_).
The Copera Node.js SDK and CLI fully support all Docs operations. Choose your preferred tool below.
Quick Start
# Get document tree
curl -X GET https://api.copera.ai/public/v1/docs/tree \
-H "Authorization: Bearer cp_pat_YOUR_TOKEN"
# Create a document
curl -X POST https://api.copera.ai/public/v1/docs/ \
-H "Authorization: Bearer cp_pat_YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "title": "My Document" }'
# Get document content as Markdown
curl -X GET https://api.copera.ai/public/v1/docs/{docId}/md \
-H "Authorization: Bearer cp_pat_YOUR_TOKEN"
# Update document content
curl -X POST https://api.copera.ai/public/v1/docs/{docId}/md \
-H "Authorization: Bearer cp_pat_YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "operation": "replace", "content": "# New Content" }'
# Search documents
curl -X GET "https://api.copera.ai/public/v1/docs/search?q=meeting" \
-H "Authorization: Bearer cp_pat_YOUR_TOKEN"
npm install @copera.ai/sdk
import { CoperaAI } from '@copera.ai/sdk' ;
const copera = CoperaAI ({ apiKey: 'cp_pat_your_token' });
// Browse document tree
const tree = await copera . doc . getDocTree ({ depth: 3 });
// Create a document
const doc = await copera . doc . createDoc ({
title: 'Project Notes' ,
content: '# Project Notes \n\n Initial content here.'
});
// Get document metadata
const details = await copera . doc . getDocDetails ({ docId: 'doc-id' });
// Get document content as Markdown
const { content } = await copera . doc . getDocContent ({ docId: 'doc-id' });
// Update metadata (title, icon, cover)
await copera . doc . updateDoc ({
docId: 'doc-id' ,
title: 'Updated Title' ,
icon: { type: 'emoji' , value: '📋' }
});
// Update content (replace, append, or prepend)
await copera . doc . updateDocContent ({
docId: 'doc-id' ,
operation: 'append' ,
content: ' \n ## New Section \n\n Appended via SDK.'
});
// Search documents
const results = await copera . doc . searchDocs ({
q: 'meeting notes' ,
limit: 20
});
// Delete a document
await copera . doc . deleteDoc ({ docId: 'doc-id' });
@copera.ai/sdk Full SDK documentation and source code
curl -fsSL https://cli.copera.ai/install.sh | bash
# Browse document tree
copera docs tree
copera docs tree --parent < i d > # subtree
# Search documents
copera docs search "keyword"
# Get document metadata
copera docs get < i d >
# Get content as Markdown
copera docs content < i d >
copera docs content < i d > --no-cache
# Create a document
copera docs create --title "New Doc"
# Update content
copera docs update < i d > --content "# New content"
copera docs update < i d > --operation append
cat content.md | copera docs update < i d > # from stdin
# Delete a document
copera docs delete < i d > --force
copera-cli CLI installation, configuration, and full command reference
Available Operations
Operation Description Get Doc Tree Browse the hierarchical document tree with configurable depth Get Doc Retrieve document metadata (title, icon, cover, dates) Get Doc Content Get the document body as Markdown Create Doc Create a new document with optional parent and initial content Update Doc Update document metadata (title, icon, cover) Update Doc Content Replace, append, or prepend Markdown content (async, returns 202) Delete Doc Soft-delete a document (owner only) Search Docs Full-text search with highlighted matches
Next Steps