Skip to main content
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

Authorization
string
required
Bearer token from an authenticated Supabase session. See the note on RAG auth.

Request Body

query
string
required
The question to answer.
workspace_id
string
required
UUID of the workspace whose documents to search.
options
object

Response

status
string
"success"
result
object
usage
object
Token/quota usage for this query
performance
object
Timing/processing metrics
workspace_id
string
timestamp
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

StatusErrorCause
400Query is required and must be a stringMissing/invalid query
400workspace_id is requiredMissing workspace_id
401Authentication requiredMissing/invalid session
403Access denied to workspaceCaller isn’t a member of the workspace
403RAG service not enabled for this workspaceRAG hasn’t been enabled/provisioned yet — upload a document first
429Monthly quota exceeded (includes quota and current_usage)Workspace has used its monthly query quota
500Failed to process queryServer error (see details in response)