All endpoints require Authorization: Bearer <supabase-jwt> unless noted otherwise.
Base URL: http://localhost:8000 (development) or your Railway URL (production).
Redirect to Google OAuth consent screen. No auth required.
Response: 302 Redirect to Google OAuth URL
Exchange authorization code for tokens. No auth required.
Request Body:
{
"code": "4/0AbCD...",
"state": null
}Response:
{
"access_token": "ya29...",
"user_id": "550e8400-e29b-41d4-a716-446655440000",
"expires_at": "2026-03-02T13:00:00Z"
}Refresh the user's Gmail access token.
Response:
{
"access_token": "ya29...",
"user_id": "550e8400-e29b-41d4-a716-446655440000",
"expires_at": "2026-03-02T14:00:00Z"
}Paginated email feed sorted by importance (highest first).
Query Parameters:
| Param | Type | Default | Description |
|---|---|---|---|
page |
int | 1 | Page number (max 1000) |
per_page |
int | 20 | Items per page (max 100) |
Response:
{
"emails": [
{
"id": "550e8400-...",
"gmail_id": "18d7a...",
"thread_id": "18d7a...",
"from_address": "alice@example.com",
"subject": "Q1 Budget Review",
"body_preview": "Hi, please review the attached...",
"importance_score": 8,
"importance_reason": "Budget-related from frequent sender",
"has_draft": true,
"received_at": "2026-03-02T10:30:00Z"
}
],
"total": 42,
"page": 1,
"per_page": 20
}List emails with paused graphs (drafts awaiting swipe approval).
Response:
[
{
"thread_id": "18d7a...",
"email_id": "550e8400-...",
"draft_subject": "Re: Q1 Budget Review",
"draft_body": "Hi Alice, I've reviewed the budget...",
"importance_score": 8,
"confidence": 0.82,
"original_email": {
"from": "alice@example.com",
"subject": "Q1 Budget Review",
"preview": "Hi, please review the attached..."
}
}
]Get a single email with full sanitized body.
Response: Full email row from Supabase.
SSE stream of pipeline progress. Connect via EventSource.
Response: text/event-stream
data: {"node": "gatekeeper", "status": "sanitizing_pii"}
data: {"node": "gatekeeper", "status": "scoring_importance"}
data: {"node": "gatekeeper", "status": "complete", "importance_score": 8}
data: {"node": "oracle", "status": "querying_context"}
data: {"node": "scribe", "status": "generating_draft"}
data: {"node": "scribe", "status": "waiting_approval", "confidence": 0.82}
data: {"status": "stream_end"}
List drafts filtered by status.
Query Parameters:
| Param | Type | Default | Description |
|---|---|---|---|
status |
string | "pending" | Filter: pending, approved, rejected, sent |
Response: Array of draft objects.
Get a single draft with full body.
Edit a draft's body text.
Query Parameters:
| Param | Type | Description |
|---|---|---|
body |
string | New draft body (max 10,000 chars) |
Approve or reject a draft. Resumes the paused LangGraph via Command(resume=...).
Request Body:
{
"approved": true,
"edits": null
}To approve with edits:
{
"approved": true,
"edits": "Hi Alice, thanks for the budget review. Looks good to me!"
}To reject (archive):
{
"approved": false
}Response:
{
"status": "sent",
"draft_id": "550e8400-..."
}Possible status values: sent, edited_and_sent, archived, send_failed
Start Gmail Pub/Sub watch for the authenticated user's inbox.
Stop Gmail watch.
Check current watch status.
Response:
{
"active": true,
"expiry": "2026-03-09T10:00:00Z",
"history_id": "12345"
}Trigger a manual full sync.
Query Parameters:
| Param | Type | Default | Description |
|---|---|---|---|
max_emails |
int | 100 | Max emails to sync |
Get user profile. user_id must match the authenticated user.
Response:
{
"id": "550e8400-...",
"email": "you@gmail.com",
"full_name": "Your Name",
"settings": {
"importance_threshold": 5,
"auto_draft": true
},
"voice_profile": {},
"created_at": "2026-03-01T00:00:00Z"
}Update user settings. user_id must match the authenticated user.
Request Body:
{
"importance_threshold": 7,
"auto_draft": false,
"voice_profile": {}
}| Field | Type | Range | Description |
|---|---|---|---|
importance_threshold |
int | 1-10 | Minimum score to generate a draft |
auto_draft |
bool | — | Auto-send high-confidence (>=0.9) drafts |
voice_profile |
object | — | Custom voice settings |
Gmail Pub/Sub push notification handler. No JWT auth — verified via Google OIDC token.
Called by Google Cloud Pub/Sub when new emails arrive.
Manual trigger for testing. Requires JWT auth.