Extensions
Extensions add custom event hooks and REST endpoints to the platform.
On the Buildpad Engine backend, extensions are runtime extensions: hooks stored in the daas_extensions table. The Engine runs them. File-based extensions and custom REST endpoints (/api/ext/*) are not available. The Studio answers /api/ext/* with 501 EXTENSIONS_UNAVAILABLE.
There are two types:
| Type | Location | Reload | Access |
|---|---|---|---|
| Runtime | Stored in daas_extensions table | Hot-reload, no deployment | All users |
| File-based | extensions/<name>/index.mjs | Requires server restart | Requires Docker image access |
Event Names
Both extension types subscribe to the same events. Use a specific collection prefix for targeted hooks, or the global form to catch all collections.
| Pattern | Example | Description |
|---|---|---|
items.create | — | Create in any collection |
items.update | — | Update in any collection |
items.delete | — | Delete in any collection |
items.read | — | Read in any collection |
items.query | — | Query (filter-only) |
{collection}.items.create | articles.items.create | Create in specific collection |
{collection}.items.update | articles.items.update | Update in specific collection |
versions.create | — | Content version created |
xtr.{category}.{action} | xtr.item.promote | Workflow action event |
Runtime Extensions
Runtime extensions are stored in the daas_extensions database table and hot-reloaded without deployment. They are ideal for dynamic business logic managed via MCP or the API.
In the Studio, the Extensions page lists the hooks with their event, type and status. Click a hook to edit its code, event, type, sort order and timeout.


On the Buildpad Engine backend:
- Only an administrator can write a hook. An administrator, or a user with
readondaas_extensions, can read the list and a hook. Every other route of/api/extensionsneeds an administrator. - Changes apply without a restart. A write through
/api/extensionsreloads the hook in every Engine process: at once with Valkey, within 30 seconds without it. - Stop all hooks with the Engine’s
RUNTIME_EXTENSIONS_ENABLED=false. Use this when a broken filter hook refuses writes.
Database schema (daas_extensions)
| Column | Type | Description |
|---|---|---|
id | uuid | Primary key |
name | text | Human-readable name |
description | text | What the extension does |
event | text | Event name to subscribe to |
type | text | filter or action |
code | text | JavaScript code body |
status | text | active, inactive, or error |
sort | integer | Execution order |
timeout_ms | integer | Execution timeout in ms (default 5000) |
memory_limit_mb | integer | Memory limit in MB (default 64) |
last_error | text | Last error message, if any |
last_error_at | timestamptz | When the last error occurred |
execution_count | integer | Total number of executions |
last_executed_at | timestamptz | Last execution timestamp |
avg_execution_time_ms | numeric | Average execution time |
Code context
Filter hooks receive (payload, meta, context) and must return the payload. On the Engine, the return value replaces the payload. A filter hook that returns nothing keeps the payload as it is:
// Auto-generate slug from title
if (!payload.slug && payload.title) {
payload.slug = payload.title.toLowerCase().replace(/\s+/g, '-');
}
return payload;Action hooks receive (meta, context) and the return value is ignored:
// Log creation
console.log(`Item created in ${meta.collection} by ${context.accountability?.user}`);Both have access to context.services:
// Items — CRUD on any collection
const svc = await context.services.items('articles');
const items = await svc.readByQuery({ filter: { status: { _eq: 'published' } } });
await svc.createOne({ title: 'New Article' });
await svc.updateOne(id, { status: 'draft' });
// Other services
const cols = await context.services.collections();
const flds = await context.services.fields();
const files = await context.services.files();
const vers = await context.services.versions();
const rels = await context.services.relations();
// Send email
await context.services.mail({ to: 'user@example.com', subject: 'Hi', html: '<p>Hello</p>' });
// Trigger / list cron jobs
await context.services.cron.trigger('job-id-or-name');
const jobs = await context.services.cron.list();
// Whitelisted environment variables
const apiKey = context.services.env.MY_API_KEY;
// Safe HTTP (domain-restricted — configure EXTENSION_ALLOWED_DOMAINS)
const res = await context.services.fetch('https://api.example.com/data');
// Raw Supabase client (bypasses RLS — use with caution). Supabase backend only.
const { data } = await context.services.supabase.from('table').select('*');On the Buildpad Engine backend:
servicesis also a parameter of the hook.context.servicesis the same object.services.supabaseis not available. A call throwsRUNTIME_SUPABASE_UNAVAILABLE. Useservices.items(collection).- A hook runs as the caller who triggered it, in the caller’s tenant.
services.itemsapplies the caller’s permissions. Pass{ elevated: true }to act as an administrator. The activity log still names the caller. - Refuse a write from a filter hook with
throw new HookError(message, statusCode, code). The defaults are400andHOOK_VALIDATION_FAILED. A plainErrorgives the same defaults. A hook that runs longer than itstimeout_msgives500. - Recursion stops at depth 8. A hook that writes to the collection it handles does not loop without end. Past depth 8, the write runs without hooks.
- An action hook runs after the commit. Its errors are logged and do not change the response.
Managing via MCP
The extensions MCP tool lets AI agents manage runtime extensions. On the Engine, the tool is for administrators only. Its actions are list, read, create, update, delete, activate, deactivate and clone:
// Create
{ "action": "create", "name": "Auto-slug", "event": "articles.items.create",
"type": "filter", "code": "...", "status": "inactive" }
// Activate
{ "action": "activate", "id": "extension-uuid" }
// List
{ "action": "list", "status": "active" }Create extensions with status: "inactive" and verify them before activating — for example by activating against a test collection first and checking last_error and the Logs page. A broken filter hook can block write operations for the affected collection.
File-Based Extensions
File-based extensions are not available on the Buildpad Engine backend. Write the logic as a runtime extension, a cron job or a custom service.
File-based extensions are JavaScript modules in the extensions/ directory. They can register event hooks and custom REST endpoints under /api/ext/. They are loaded at server startup. See File-Based Extensions.