curl -X POST https://suite.sundaypyjamas.com/api/v1/rag/query \
-H "Authorization: Bearer <supabase_access_token>" \
-H "Content-Type: application/json" \
-d '{
"query": "What were the top risks identified in the Q2 report?",
"workspace_id": "9d4c1a2e-...",
"options": { "max_sources": 3 }
}'
{
"status": "success",
"result": {
"answer": "The Q2 report identifies three key risks: supply chain delays, rising customer acquisition costs, and increased competitive pressure in the EU market.",
"confidence": 0.86,
"sources": [
{
"content": "Supply chain delays increased average fulfillment time by 4 days...",
"document": "report.pdf",
"page": 12,
"confidence": 0.91,
"relevance_score": 0.88
}
]
},
"usage": {},
"performance": {},
"workspace_id": "9d4c1a2e-...",
"timestamp": "2026-07-08T10:05:00Z"
}
RAG
POST /rag/query
Ask a natural-language question grounded in your uploaded documents
POST
/
api
/
v1
/
rag
/
query
curl -X POST https://suite.sundaypyjamas.com/api/v1/rag/query \
-H "Authorization: Bearer <supabase_access_token>" \
-H "Content-Type: application/json" \
-d '{
"query": "What were the top risks identified in the Q2 report?",
"workspace_id": "9d4c1a2e-...",
"options": { "max_sources": 3 }
}'
{
"status": "success",
"result": {
"answer": "The Q2 report identifies three key risks: supply chain delays, rising customer acquisition costs, and increased competitive pressure in the EU market.",
"confidence": 0.86,
"sources": [
{
"content": "Supply chain delays increased average fulfillment time by 4 days...",
"document": "report.pdf",
"page": 12,
"confidence": 0.91,
"relevance_score": 0.88
}
]
},
"usage": {},
"performance": {},
"workspace_id": "9d4c1a2e-...",
"timestamp": "2026-07-08T10:05:00Z"
}
Authentication
string
required
Bearer token from an authenticated Supabase session. See the note on RAG auth.
Request Body
string
required
The question to answer.
string
required
UUID of the workspace whose documents to search.
object
Show options
Show options
number
default:"5"
Maximum number of source chunks to retrieve.
number
default:"0.7"
Minimum relevance score (0–1) for a chunk to be included as a source.
boolean
default:"true"
Whether to include source metadata in the response.
string
Optional identifier to associate this query with a conversation for context continuity.
Response
string
"success"object
object
Token/quota usage for this query
object
Timing/processing metrics
string
string
ISO 8601
curl -X POST https://suite.sundaypyjamas.com/api/v1/rag/query \
-H "Authorization: Bearer <supabase_access_token>" \
-H "Content-Type: application/json" \
-d '{
"query": "What were the top risks identified in the Q2 report?",
"workspace_id": "9d4c1a2e-...",
"options": { "max_sources": 3 }
}'
{
"status": "success",
"result": {
"answer": "The Q2 report identifies three key risks: supply chain delays, rising customer acquisition costs, and increased competitive pressure in the EU market.",
"confidence": 0.86,
"sources": [
{
"content": "Supply chain delays increased average fulfillment time by 4 days...",
"document": "report.pdf",
"page": 12,
"confidence": 0.91,
"relevance_score": 0.88
}
]
},
"usage": {},
"performance": {},
"workspace_id": "9d4c1a2e-...",
"timestamp": "2026-07-08T10:05:00Z"
}
Errors
| Status | Error | Cause |
|---|---|---|
| 400 | Query is required and must be a string | Missing/invalid query |
| 400 | workspace_id is required | Missing workspace_id |
| 401 | Authentication required | Missing/invalid session |
| 403 | Access denied to workspace | Caller isn’t a member of the workspace |
| 403 | RAG service not enabled for this workspace | RAG hasn’t been enabled/provisioned yet — upload a document first |
| 429 | Monthly quota exceeded (includes quota and current_usage) | Workspace has used its monthly query quota |
| 500 | Failed to process query | Server error (see details in response) |
⌘I