Chat API
Asynchronous chat between humans and LLM agents — poll, reply, history, unread count, file uploads.
Chat API
The Chat API enables asynchronous messaging between humans and LLM agents. Unlike synchronous chat (ChatGPT-style), the human can leave messages while the agent is working — the agent polls between tool calls.
How It Works
Human (browser) ──POST /chat/send──▶ Synapse ◀──GET /chat/poll── Agent (LLM)
│
└── marks messages as read on poll- Human sends a message via the web UI (uses JWT)
- Message is stored, marked as unread
- Agent polls
GET /chat/pollbetween tool calls - Poll returns all unread messages and marks them as read
- Agent processes the message, optionally replies via
POST /chat/reply
Endpoints
GET /chat/poll
Poll for new messages from the human. Returns unread messages and marks them as read. Use this between tool calls.
curl -H "Authorization: Bearer YOUR_MIND_KEY" \
https://synapse.schaefer.zone/chat/pollResponse:
{
"messages": [
{
"id": "msg_001",
"role": "human",
"content": "How's the deployment going?",
"created_at": "2026-06-27T..."
}
]
}POST /chat/reply
Send a message as the agent.
curl -X POST https://synapse.schaefer.zone/chat/reply \
-H "Authorization: Bearer YOUR_MIND_KEY" \
-H "Content-Type: application/json" \
-d '{"content": "Deployment is 80% done. CI is green, just waiting for Docker push."}'POST /chat/send
Send a message as the human (requires JWT, not Mind Key).
curl -X POST https://synapse.schaefer.zone/chat/send \
-H "Authorization: Bearer YOUR_JWT" \
-H "Content-Type: application/json" \
-d '{"content": "Can you check the logs?"}'GET /chat/history
Get recent chat history (both roles).
curl -H "Authorization: Bearer YOUR_MIND_KEY" \
"https://synapse.schaefer.zone/chat/history?limit=50"GET /chat/unread
Get unread message count.
# Count unread messages from human (for agent)
curl -H "Authorization: Bearer YOUR_MIND_KEY" \
"https://synapse.schaefer.zone/chat/unread?role=agent"
# Count unread messages from agent (for human)
curl -H "Authorization: Bearer YOUR_JWT" \
"https://synapse.schaefer.zone/chat/unread?role=human"GET /chat/status
Get chat session status (last message timestamps, unread counts).
curl -H "Authorization: Bearer YOUR_MIND_KEY" \
https://synapse.schaefer.zone/chat/statusPOST /chat/upload
Upload a file attachment for a specific message (multipart form).
curl -X POST https://synapse.schaefer.zone/chat/upload \
-H "Authorization: Bearer YOUR_JWT" \
-F "message_id=msg_001" \
-F "file=@screenshot.png"GET /chat/files/:message_id
List file attachments for a message.
curl -H "Authorization: Bearer YOUR_JWT" \
https://synapse.schaefer.zone/chat/files/msg_001GET /chat/file/:file_id
Download a file attachment.
curl -H "Authorization: Bearer YOUR_JWT" \
https://synapse.schaefer.zone/chat/file/file_001 --output download.pngPolling Pattern
# Pseudo-code
while working:
messages = poll_chat()
for msg in messages:
process_message(msg)
reply(f"Acknowledged: {msg.content}")
do_one_tool_call()