Code

execute({ code }) runs your JavaScript on OpenBelt as you, with the workspace in reach as workspace. Send a body that awaits and returns what you want back:

const [found] = await workspace.search("rsvp to a meetup")
const done = await workspace.apps.meetups.fn.rsvp({ event: "intro" })
const { docs } = await workspace.apps.meetups.collection("rsvps").list({ limit: 100 })
return { found: found.path, done, rsvps: docs.length }

What workspace has

Code has no app, secrets or network of its own: what an app needs every time belongs in a function.

For imports and seed data, use collection_add batches instead of looping over add here. See Importing documents over MCP.

Limits

60 seconds, 300 workspace calls, 100 KB of code; a result over 24 KB of JSON comes back cut. An error has kind (syntax, runtime, timeout, limit, sandbox), message and the line of your code.

Source: docs/code.md on GitHub