Build a Kanban board
A task table, row policies for assignees and a board API with Think Store, Think Authz and Think Service.
You will build the backend of a small Kanban board for a team: everyone sees the tasks assigned to them or created by them, only the assignee can move a card, and the board is served by your own API.
| Part | Service |
|---|---|
A Tasks table with a status and an assignee | Think Store |
| Who sees and moves which card | Think Authz |
GET /board and POST /tasks/:id/move | Think Service |
Before you begin
- An OpenThink account. Sign up at iam.openthink.app.
- A personal access token (
ank_…) from your account page, for setting policies and for calling the service as yourself. - An AI client connected to OpenThink over MCP, such as Claude, to deploy the service.
1. Create the project and the table
In OpenThink, create a space named Kanban. It appears as a project in the console. In the space, choose New → Database, name it Tasks and give it three columns:
| Column | Type | Notes |
|---|---|---|
Title | Title | The name of the card. |
Status | Select | Options To do, Doing, Done. |
Assignee | Person | OpenThink users. You can write an email address; it is stored as a user ID. |
2. Write the policy
The policy decides which rows each person can read and write. People see a task when it is assigned to them or when they created it; anyone may add tasks as themselves; only the assignee may change a task, and only its Status.
[
{ "action": "select", "using": "me in row.Assignee || row.by == me" },
{ "action": "insert", "check": "row.by == me" },
{ "action": "update", "using": "me in row.Assignee", "columns": ["Status"] }
]Set it with your personal access token. Replace <project> with the project ID shown in the console.
export ANK=ank_...
curl -X PUT https://openthink.app/api/spaces/<project>/policies \
-H "Authorization: Bearer $ANK" -H "Content-Type: application/json" \
-d '{ "table": "Tasks", "policies": [
{ "action": "select", "using": "me in row.Assignee || row.by == me" },
{ "action": "insert", "check": "row.by == me" },
{ "action": "update", "using": "me in row.Assignee", "columns": ["Status"] } ] }'A rule that names a column the table does not have is rejected with the position of the error. See the condition language for every operator.
3. Invite the team
Share the space with your teammates and give them View access. Because Tasks now has a policy, they can open it and work in it, but only as far as the policy allows. You, the owner, always see every row.
4. Add tasks over REST
In the console, open the project and create an API key under API keys → Create key with Read and write. Then find the table ID and add a few cards:
export THK=thk_...
curl https://openthink.app/api/v1/tables -H "Authorization: Bearer $THK"
curl -X POST https://openthink.app/api/v1/tables/<table-id>/rows \
-H "Authorization: Bearer $THK" -H "Content-Type: application/json" \
-d '{ "rows": [
{ "values": { "Title": "Write the landing page", "Status": "To do", "Assignee": ["an@example.com"] } },
{ "values": { "Title": "Set up billing", "Status": "Doing", "Assignee": ["binh@example.com"] } } ] }'Each email must belong to an OpenThink account; otherwise the request fails and nothing is written. A key acts as the project owner, so the policy does not limit it.
5. Deploy the board service
The service reads and writes with store.asViewer(), so every call runs as the caller under the policy from step 2. The service never decides who may move a card; the policy does.
// Kanban
import { Service, HTTPError } from "think"
const STATUSES = ["To do", "Doing", "Done"]
const app = new Service()
app.owns("Tasks")
// The board of the caller: only the tasks the policy lets them see
app.get("/board", { name: "board", description: "Tasks of the caller, by column" }, async (c) => {
const { store } = c.var.think
const rows = await store.asViewer().list("Tasks", { orderBy: "Title", limit: 200 })
const columns = Object.fromEntries(STATUSES.map((s) => [s, []]))
for (const r of rows) (columns[r.Status] ?? columns["To do"]).push({ id: r._id, title: r.Title })
return { columns }
})
// Move a card: the policy only lets the assignee change Status
app.post("/tasks/:id/move", { name: "task:move", description: "Move a task to another column" }, async (c) => {
const { store } = c.var.think
const { status } = await c.req.json()
if (!STATUSES.includes(status)) throw new HTTPError(400, "status must be one of " + STATUSES.join(", "))
const n = await store.asViewer().update("Tasks", c.req.param("id"), { Status: status })
if (!n) throw new HTTPError(404, "no such task assigned to you")
return { ok: true }
})
export default appAsk your AI client to deploy it with the build tool, passing the code as service.code:
{ "space": "Kanban", "service": { "code": "<contents of service.js>" } }6. Call the board
Call the routes with a personal access token so the service knows who is calling. A teammate with their own token sees only their cards:
curl https://openthink.app/api/svc/<project>/board \
-H "Authorization: Bearer $ANK"
curl -X POST https://openthink.app/api/svc/<project>/tasks/<row-id>/move \
-H "Authorization: Bearer $ANK" -H "Content-Type: application/json" \
-d '{ "status": "Done" }'Moving a card that is not assigned to the caller returns 404: under the policy the row does not match, so update changes nothing.
7. Check the logs
Every response carries an x-think-request-id header. In the console, open Logs to see each call with its route, status, duration and console output.
Next steps
- Draw the board in an HTML page of the space and call the routes with
think.call("board"). See HTML pages. - Notify the assignee when a card moves with a table-change handler.
- Ship changes safely with previews and rollbacks.