Skip to Content
AutomateExtensions

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:

TypeLocationReloadAccess
RuntimeStored in daas_extensions tableHot-reload, no deploymentAll users
File-basedextensions/<name>/index.mjsRequires server restartRequires 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.

PatternExampleDescription
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.createarticles.items.createCreate in specific collection
{collection}.items.updatearticles.items.updateUpdate in specific collection
versions.create—Content version created
xtr.{category}.{action}xtr.item.promoteWorkflow 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.

Runtime Extensions page with two action hooks and one filter hook

Extension editor for a filter hook on posts.items.create

On the Buildpad Engine backend:

  • Only an administrator can write a hook. An administrator, or a user with read on daas_extensions, can read the list and a hook. Every other route of /api/extensions needs an administrator.
  • Changes apply without a restart. A write through /api/extensions reloads 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)

ColumnTypeDescription
iduuidPrimary key
nametextHuman-readable name
descriptiontextWhat the extension does
eventtextEvent name to subscribe to
typetextfilter or action
codetextJavaScript code body
statustextactive, inactive, or error
sortintegerExecution order
timeout_msintegerExecution timeout in ms (default 5000)
memory_limit_mbintegerMemory limit in MB (default 64)
last_errortextLast error message, if any
last_error_attimestamptzWhen the last error occurred
execution_countintegerTotal number of executions
last_executed_attimestamptzLast execution timestamp
avg_execution_time_msnumericAverage 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:

  • services is also a parameter of the hook. context.services is the same object.
  • services.supabase is not available. A call throws RUNTIME_SUPABASE_UNAVAILABLE. Use services.items(collection).
  • A hook runs as the caller who triggered it, in the caller’s tenant. services.items applies 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 are 400 and HOOK_VALIDATION_FAILED. A plain Error gives the same defaults. A hook that runs longer than its timeout_ms gives 500.
  • 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.