Quickstart: deploy a route
Write a service with one route, deploy it, and call it over HTTP.
Before you begin
- An OpenThink account and a project (space) you own, or in which you have the Write Function permission.
- A table in that project. This guide uses a table named
Taskswith the columnsTitle,StatusandAssignee.
Write the service
The first // … comment is the service name. The module must export default a Service.
// Kanban
import { Service, HTTPError } from "think"
const app = new Service()
app.owns("Tasks")
app.post("/tasks/:id/complete", { name: "task:complete", description: "Mark a task as done" }, async (c) => {
const { viewer, store } = c.var.think
const task = await store.get("Tasks", c.req.param("id"))
if (!task) return c.json({ error: "task not found" }, 404)
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 appDeploy it
Deploy with the build tool over MCP (for example from Claude), passing the code as service.code. The result contains the deployed version and its URL.
{ "space": "Kanban", "service": { "code": "<contents of service.js>" } }Call it
Call the route with a project API key or a personal access token in the Authorization header.
curl -X POST https://openthink.app/api/svc/<project>/tasks/<row-id>/complete \
-H "Authorization: Bearer thk_..."Every response carries an x-think-request-id header. Use it to find the call in the logs.
Next steps
- Routes and access: choose who can call each route.
- Previews and rollbacks: ship changes safely to a service people already use.
- Table policies: decide which rows each caller can read and write.