The POST /gql endpoint accepts a raw GQL query in the request body (not JSON-wrapped). Authentication and namespace selection use the same headers as POST /sql. For the full HTTP reference (headers, response envelope, limits), see POST /gql.
Start SurrealDB with OpenGQL
OpenGQL is gated behind the experimental capability opengql. Pass the storage path after the flag (or use memory):
Environment variable equivalent:
Note
Load sample data
Use POST /sql with namespace main and database main (set via headers below):
POST /gql
Send the GQL query as the raw body with Content-Type: text/plain (or omit; UTF-8 text is expected).
Example response (same envelope as /sql):
Response formats
Set Accept to:
application/json(default)application/cborfor CBOR-encoded results
Parse errors return HTTP 400 with an error payload. If OpenGQL is not enabled on the server, expect a capability or route error (403).
WebSocket RPC
On an authenticated WebSocket session, send the query as the first parameter. Pass typed variables as an optional second object:
With parameters: