Skip to main content
Use the factory helpers for a ready-made 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

On failure the helpers return ok: false with an error string (HTTP 503 when credentials are missing, otherwise 502).

API Reference

Handler options

Shared by createNextHandler, createExpressHandler, handleTokenRequest, and mintWorkspaceToken.

createNextHandler

Returns an async GET 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

Calls POST {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.