Custom Integrations
Build your own connectors to Cortex.
Cortex provides a REST API for building custom integrations. Any system that can make HTTP requests can push memories.
Authentication
All API requests require an agent key:
Authorization: Bearer crtx_YOUR_KEY_HERE
Pushing Memories
curl -X POST https://your-cortex-host/api/memories \
-H "Authorization: Bearer crtx_YOUR_KEY_HERE" \
-H "Content-Type: application/json" \
-d '{
"content": "We decided to use PostgreSQL for the main database...",
"title": "Database Selection Decision",
"scope": "engineering",
"source": "Architecture Review",
"source_url": "https://docs.company.com/architecture/db-selection",
"tags": ["database", "architecture"]
}'
Example Integrations
Notion
// Sync Notion pages to Cortex
async function syncNotionPage(page) {
const content = await getNotionPageContent(page.id);
await fetch('https://your-cortex-host/api/memories', {
method: 'POST',
headers: {
'Authorization': `Bearer ${CORTEX_API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
content,
title: page.title,
scope: 'public-docs',
source: 'Notion',
source_url: page.url
})
});
}
Confluence
# Sync Confluence pages to Cortex
import requests
def sync_confluence_page(page):
content = page['body']['storage']['value']
requests.post(
'https://your-cortex-host/api/memories',
headers={
'Authorization': f'Bearer {CORTEX_API_KEY}',
'Content-Type': 'application/json'
},
json={
'content': content,
'title': page['title'],
'scope': 'engineering',
'source': 'Confluence',
'source_url': page['_links']['self']
}
)
CI/CD Pipeline
# GitHub Actions example
- name: Push deployment notes to Cortex
run: |
curl -X POST https://your-cortex-host/api/memories \
-H "Authorization: Bearer ${{ secrets.CORTEX_API_KEY }}" \
-H "Content-Type: application/json" \
-d '{
"content": "Deployed v${{ github.sha }} to production",
"title": "Production Deployment ${{ github.run_number }}",
"scope": "engineering",
"source": "GitHub Actions",
"source_url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
}'
Best Practices
| Practice | Description |
|---|---|
| Meaningful titles | Use descriptive titles for easy discovery |
| Source URLs | Always include links to original sources |
| Appropriate scopes | Write to the correct scope for permissions |
| Tags | Use tags for categorization |
| Concise content | Focus on decisions and context, not raw data |
Error Handling
| Status | Description |
|---|---|
401 | Invalid or missing API key |
403 | Scope denied for your role |
400 | Invalid request body |
413 | Content exceeds 20,000 characters |