Build your first app on a space
A task list with row rules and a small API, using Think Store, Think Authz and Think Service.
About 15 minutes- 01
Create an account and a space
Sign in with Google. Your first space is ready when you land; make another for this app. The space id is the part after /s/ in its URL, and stands for <space> below.
Create a space - 02
Add a Database
In the space choose New → Database and name it Tasks. Keep the Name column and add a Select column named Status with the option Todo. A Database lives in Think Store and is closed until you add a policy.
- 03
Write the row rules
Everyone in the space reads every task; people add tasks as themselves and edit only their own. Send this with the build tool over MCP, or PUT /api/spaces/<space>/policies with { table, policies }. A wrong rule is rejected with its position.
{ "space": "<space>", "policies": [{ "table": "Tasks", "rules": [ { "action": "select", "using": "true" }, { "action": "insert", "check": "row.by == me" }, { "action": "update", "using": "row.by == me" } ] }] } - 04
Deploy a service
One route reads with the service account, the other writes as the caller. Deploy it with build { service: { code } } over MCP; add preview: true to try a version on real data first.
// Tasks import { Service } from "think" const app = new Service() // The service account reads every open task app.get("/tasks", { name: "tasks:list" }, async (c) => { const { store } = c.var.think return c.json(await store.list("Tasks", { where: { Status: "Todo" } })) }) // A person adds a task: their role and the Table Policy apply app.post("/tasks", { name: "tasks:add" }, async (c) => { const { Name } = await c.req.json() const row = await c.var.think.store.asViewer().insert("Tasks", { Name, Status: "Todo" }) return c.json(row, 201) }) export default app - 05
Call it and watch the logs
Create a key on the API keys page of console.openthink.app. Every response carries x-think-request-id; find that call in the Service tab or the console logs.
Open the console# From your server, with a thk_ key of the space curl https://openthink.app/api/svc/<space>/tasks \ -H "Authorization: Bearer thk_…" // From an HTML page in the space, as the person viewing it await think.call("tasks:add", { Name: "Write the launch post" })