OpenThink Cloud

Routes and access

Declare HTTP routes, set who may call them, and build responses.

Declaring routes

Use app.get, app.post, app.put, app.patch, app.delete or app.all with a path, optional metadata and one or more handlers.

  • Paths look like /tasks or /tasks/:id. A trailing * matches the rest of the path, read with c.req.param("*").
  • Routes declared first win.
  • Up to 100 routes per service.

Route metadata

FieldDescription
nameName used to call the route from an HTML page with think.call(name, args) and from MCP. Letters, digits and _ . : -; must be unique.
descriptionWhat the route does.
accessWho may call it: "space" (default), "user" or "public". See below.

Access levels

ValueWho can call the route
spacePeople invited to the project, the project's thk_ API keys, and people who can open an HTML page of the project (through think.call). This is the default.
userAnyone signed in to OpenThink.
publicAnyone, including callers who are not signed in. viewer is null. Use it for webhooks from Stripe or GitHub and for public forms.

Read-only API keys can only call GET routes.

Middleware and errors

js
app.use(async (c, next) => { /* before */ await next() })
app.use("/admin/*", requireAdmin)

app.onError((err, c) => c.json({ error: "internal" }, 500))

Throw new HTTPError(status, message) anywhere in a handler to return { error } with that status.

The request

c.req provides param(k), query(k), queries(k), header(k), await json(), await text(), await parseBody(), method, path, url and raw (the underlying Request).

Responses

  • c.json(data, status?, headers?), c.text, c.html, c.body, c.redirect(url), c.notFound(), c.status(n), c.header(k, v).
  • Returning a plain object sends it as JSON with status 200. Returning a Response also works.
  • You cannot set set-cookie, CORS headers or a Content Security Policy.

Calling from outside

  • Send Authorization: Bearer <key> with a project API key (thk_…) or a personal access token (ank_…). Keys limited to specific tables cannot call service routes.
  • CORS is open to every origin, without credentials.
  • Request bodies are limited to 1 MB and responses to 2 MB.

Last updated 2026-12-03 UTC. Something wrong or missing? Send feedback.