GET handler, or call mintWorkspaceToken / handleTokenRequest in any framework.
Import
Usage
Next.js App Router
app/api/aiql/route.ts:
Express
With options
Any framework
Successful response body
ok: false with an error string (HTTP 503 when credentials are missing, otherwise 502).
API Reference
Handler options
Shared bycreateNextHandler, createExpressHandler, handleTokenRequest, and mintWorkspaceToken.
createNextHandler
Returns an asyncGET function compatible with the Next.js App Router Response.json pattern.
createExpressHandler
Returns an Express-style(req, res) => … handler that calls res.status(…).json(…).
handleTokenRequest
Returns{ status, body } so you can adapt the result to any HTTP framework.
mintWorkspaceToken
CallsPOST {baseUrl}/api/embed/tokens and returns { token, expiresIn, expiresAt }. Throws if credentials are missing or the upstream request fails.
Pair these handlers with useToken on the client.