Serverless routes, schedules and table triggers for each space
Write a service like Hono, deploy it per space at its own URL, and keep business rules on the server where pages cannot bypass them.
Why Think Service?
Think Service is the server-side logic of an app built on a space. Each space has one service with routes at /api/svc/<space>/…, plus cron schedules and handlers that run when a table changes.
HTML pages, mobile apps, bots, outside systems and AI call the same API. The service runs as the space's service account, and store.asViewer() switches to the caller when a route acts on their behalf.
Benefits
app.owns("Tasks") makes a table writable only through your routes.
Every deploy is an immutable version. Try a preview on real data, promote it, or roll back without rebuilding.
The think module is built in: store, viewer, secrets, Functions and fetch.
Features
Routes
get, post, put, patch, delete with params and wildcards, middleware, HTTPError and onError.
Access per route
space (members and thk_ keys), user (anyone signed in) or public (webhooks, public forms).
Schedules
app.cron with five-field cron and a time zone, as often as every five minutes.
Table triggers
app.onChange runs after rows are added, updated or deleted, whoever wrote them.
Data access
store.get, list, insert, update, delete, sql and query on the space's tables, by name.
Versions and logs
Preview at <space>@<version>, promote, roll back. Logs keep the last 500 calls.
Pricing
Think Service is part of every OpenThink plan, not billed on its own. On Free it runs within the limits below; on Team it draws from the monthly usage credit, and your admin sets the spending cap.
See OpenThink Cloud pricingLimits
| Per call | 10 s CPU, 30 s wait, 50 subrequests |
|---|---|
| Rate | 300 calls per minute per space |
| Size | Body 1 MB, response 2 MB, code 200,000 characters |
| Per service | 100 routes, 10 schedules, 20 table handlers |
| History | 50 versions, 500 logged calls |
Getting started
- 01
Write the service
Export a Service from the think module, with routes, schedules or table triggers.
- 02
Deploy a preview
Use the build tool over MCP with preview: true, and call a route on the preview.
- 03
Promote and call
Promote the version, then call it with a PAT or a thk_ key, or with think.call from a page.
// Kanban
import { Service, HTTPError } from "think"
const app = new Service()
app.owns("Tasks")
app.post("/tasks/:id/complete", async (c) => {
const { viewer, store } = c.var.think
const task = await store.get("Tasks", c.req.param("id"))
if (task?.Assignee !== viewer.email) throw new HTTPError(403, "not the assignee")
await store.update("Tasks", task._id, { Status: "Done" })
return c.json({ ok: true })
})
export default appFrequently asked questions
Where does it run?
On Cloudflare Workers, as an isolated worker loaded for your space.
Can I use npm packages?
Not yet. The think module is built in; fetch reaches outside APIs, up to 50 times per call.
Does a preview use real data?
Yes, like Cloud Run or Workers previews. Schedules and table triggers of a preview do not run.
How do outside systems call it?
With Authorization: Bearer and a PAT or a thk_ key of the space. CORS is open for every origin, without cookies.
Explore other managed services
Think Store
A real SQLite database for every space, with indexes, constraints and relations between tables.
Security & IdentityThink Authz
One permission service for pages, folders, spaces and row policies on every table.
RealtimeThink Collab
Realtime co-editing, presence and change events for every page in a space.
Start building on OpenThink Cloud
Create a free account. Your first space is ready when you land.