Automations Tools
Tools for account functions, schedules, webhooks, mailhooks, and their run history.
Available Tools
automations_listFunctionsList the current user's account functions (id, name, description, isActive, grants).
Example Call
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "automations_listFunctions",
"arguments": {}
}
}automations_getFunctionGet one account function by id — its code, grants, summary, isActive.
Input Schema
id | stringrequired |
Example Call
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "automations_getFunction",
"arguments": {
"id": "example"
}
}
}automations_createFunctionCreate a new account function. `code` runs as a function BODY with `ctx` and `params` in scope — `export default async (params, ctx) => {…}` is also accepted; `import` is not. Params: name, description?, code?, grants?, maxRetries? (retries when run by an automation on failure; 0 = run once (default), set > 0 ONLY if the function is idempotent — safe to re-run without doubling side effects). Returns the created function (with id). ⚠️ Starts isActive:false — call updateFunction {isActive:true} before pointing a mailhook/webhook/schedule at it, or triggers will fail loudly with "target is INACTIVE". POWERS: ctx.email, ctx.env, and a site's users / entitlements are refused until the OWNER allows that power on the function's Access tab ("Powers & secrets") — you cannot grant it (grants.capabilities does nothing). When the code uses one, tell the owner to allow it there.
Input Schema
name | stringrequired | |
description | string | |
code | string | |
grants | object | |
maxRetries | integer | Retries when run by an automation on failure. 0 = run once (default). Set > 0 ONLY if this function is idempotent (safe to re-run without doubling side effects). |
toolSpec | object | Structured MCP-tool schema { inputSchema, outputSchema?, returns?, sideEffects? } authored WITH the code — describes what this connector takes/returns. |
exposed | boolean | true = the owner's automations & AI may call this as a catalog-listed method (UI: "Automations & AI can use this function"); false (default) = private/internal. |
Example Call
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "automations_createFunction",
"arguments": {
"name": "example",
"description": "example",
"code": "example"
}
}
}automations_updateFunctionUpdate an account function — REQUIRED to change its code, grants or accessRules. Params: id, plus any of name/description/summary/code/isActive/timeout/grants/maxRetries (0 = run once; > 0 only if idempotent)/accessRules ({ execute: <condition> } — who may invoke it from outside). PUBLISHED-APP ACCESS is deny-by-default and needs BOTH: grants.bases includes the site AND accessRules.execute allows the caller (e.g. { execute: { type: "authenticated" } }); the app then calls functions.invokeAccount("<name>", params) from its frontend. Account functions use GLOBAL (account-level) env vars — ctx.env.get/set and {{VAR}} in ctx.fetch read the account store (manage via setEnvVar/listEnvVars/deleteEnvVar). DELIBERATELY SEPARATE from per-site env: site functions read site env, account functions read global env, no fallback between them. ctx.sites is keyed by display NAME, not slug (robust: Object.values(ctx.sites).find(s => s.projectId === id)); methods.call is a SERVICE CALL gated ONLY by exposed:true — the target's execute rules apply to external callers, not this path. ⚠️ New functions start isActive:false — ACTIVATE before pointing a mailhook/webhook/schedule at them.
Input Schema
id | stringrequired | |
name | string | |
description | string | |
summary | string | |
code | string | |
isActive | boolean | |
timeout | integer | |
maxRetries | integer | Retries when run by an automation on failure. 0 = run once. Set > 0 only if idempotent. |
grants | object | |
accessRules | object | |
toolSpec | object | Structured MCP-tool schema — update TOGETHER with the code so they stay in sync; null removes it. |
exposed | boolean |
Example Call
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "automations_updateFunction",
"arguments": {
"id": "example",
"name": "example",
"description": "example"
}
}
}automations_deleteFunctionPermanently delete an account function. Params: id.
Input Schema
id | stringrequired |
Example Call
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "automations_deleteFunction",
"arguments": {
"id": "example"
}
}
}automations_sitesManifestList the account's sites + their tables/fields. Call this for exact site/table/field names before writing code.
Example Call
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "automations_sitesManifest",
"arguments": {}
}
}automations_invokeFunctionRun an account function once (manual test). Params: id (the function id OR its exact name — e.g. "qa_echo"), event? (the input it receives as params). Returns its result and runId.
Input Schema
id | stringrequired | The function id — or its exact name |
event | object |
Example Call
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "automations_invokeFunction",
"arguments": {
"id": "example",
"event": {}
}
}
}automations_listTriggersList an account function's triggers. Param: functionId. Returns { webhooks: [{id, token, isActive, lastTriggered}], schedules: [{id, cronExpression, timezone, isActive, lastTriggered, nextTrigger}] }. Its "On event" triggers: accountEvents_listEventTriggers({ targetKind: "account_function", targetRef }); its email addresses: automations_listMailhooks (targetKind account_function).
Input Schema
functionId | stringrequired |
Example Call
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "automations_listTriggers",
"arguments": {
"functionId": "example"
}
}
}automations_listRunsRun history of one account function, newest first: status, what started it, timing, error, log
Input Schema
functionId | stringrequired | |
limit | integer |
Example Call
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "automations_listRuns",
"arguments": {
"functionId": "example",
"limit": {}
}
}
}automations_createWebhookAdd a webhook trigger to an account function — a secret URL that runs it when POSTed. Param: functionId. Returns { id, token }; the URL is /api/automations/functions/webhook/<token>. The function must be Active (isActive) to actually run.
Input Schema
functionId | stringrequired |
Example Call
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "automations_createWebhook",
"arguments": {
"functionId": "example"
}
}
}automations_setWebhookActiveEnable or disable a webhook trigger. Params: id (webhook id), isActive (boolean).
Input Schema
id | stringrequired | |
isActive | booleanrequired |
Example Call
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "automations_setWebhookActive",
"arguments": {
"id": "example",
"isActive": true
}
}
}automations_deleteWebhookDelete a webhook trigger. Param: id (webhook id).
Input Schema
id | stringrequired |
Example Call
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "automations_deleteWebhook",
"arguments": {
"id": "example"
}
}
}automations_createScheduleAdd a cron schedule trigger to an account function (event-driven — registers an in-process CronJob, no polling). Params: functionId, cronExpression (5-part "min hour day month weekday", e.g. "0 9 * * *" = 9am daily), timezone (default UTC). The function must be Active to run.
Input Schema
functionId | stringrequired | |
cronExpression | stringrequired | |
timezone | string |
Example Call
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "automations_createSchedule",
"arguments": {
"functionId": "example",
"cronExpression": "example",
"timezone": "example"
}
}
}automations_setScheduleActiveEnable or disable a schedule trigger (re-registers/unregisters the CronJob). Params: id (schedule id), isActive (boolean).
Input Schema
id | stringrequired | |
isActive | booleanrequired |
Example Call
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "automations_setScheduleActive",
"arguments": {
"id": "example",
"isActive": true
}
}
}automations_deleteScheduleDelete a schedule trigger (unregisters its CronJob). Param: id (schedule id).
Input Schema
id | stringrequired |
Example Call
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "automations_deleteSchedule",
"arguments": {
"id": "example"
}
}
}automations_listMailAccountsList the account's customer-owned SMTP mailboxes (Mail Accounts). Optional param "projectId" filters to mailboxes a given site may use (unbound + bound to it). Returns safe shape only — id, name, fromAddress, fromName, verified, isDefault, isActive, sentCount — NEVER credentials. sentCount is the CURRENT HOUR'S count used against hourlyLimit, not a lifetime total: it restarts at the size of the first send once an hour has passed with no send, so a drop from 8 to 1 means a new window opened, not lost history. MULTI-TENANT: one mailbox can send under several identities — ctx.email.sendVia(name, { ..., fromName }) sets the display name PER SEND (the verified address never changes), so customers sharing a mailbox each appear as themselves. ⚠️ A send returns fromNameOverridden — that means the platform PUT the name in the From header, NOT that the recipient sees it: some SMTP hosts (shared cPanel/Exim especially) rewrite From on authenticated submission to the mailbox's own configured display name, after the message leaves us and undetectably from here. If a delivered message shows the wrong name, do NOT retry or treat it as a platform bug — set the display name on the mailbox at the mail host, or use a provider allowing per-send names (SES, Postmark, Resend, Mailgun). Use these for outreach/bulk email: sends leave the owner's own domain and reputation and NO platform monthly quota applies (the built-in ctx.email.send does have a plan quota).
Input Schema
projectId | string | Filter to mailboxes usable by this site (unbound + bound to it) |
Example Call
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "automations_listMailAccounts",
"arguments": {
"projectId": "example"
}
}
}automations_createMailAccountAdd a customer-owned SMTP mailbox. Use for outreach: sends leave the customer's own domain and reputation, not the platform's shared sender, and no monthly platform quota applies.
Input Schema
name | stringrequired | Reference used by ctx.email.sendVia (unique per account) |
fromAddress | stringrequired | The address recipients see |
fromName | string | |
replyTo | string | |
host | stringrequired | SMTP host, e.g. smtp.gmail.com |
port | integer | |
secure | boolean | true for implicit TLS (465); false for STARTTLS (587) |
username | stringrequired | |
password | stringrequired | SMTP password / app password — encrypted at rest, never returned |
projectId | string | Bind to ONE site; omit to let anything in the account use it |
isDefault | boolean | |
hourlyLimit | integer |
Example Call
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "automations_createMailAccount",
"arguments": {
"name": "example",
"fromAddress": "example",
"fromName": "example"
}
}
}automations_updateMailAccountUpdate a mail account. Omit password to keep the stored credential.
Input Schema
id | stringrequired | |
name | string | |
fromAddress | string | The address recipients see |
fromName | string | |
replyTo | string | |
host | string | |
port | integer | |
secure | boolean | |
username | string | |
password | string | Only send when rotating the credential |
projectId | string | |
isDefault | boolean | |
isActive | boolean | |
hourlyLimit | integer |
Example Call
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "automations_updateMailAccount",
"arguments": {
"id": "example",
"name": "example",
"fromAddress": "example"
}
}
}automations_deleteMailAccountDelete a mail account by id. Functions calling ctx.email.sendVia with that name will start failing — check usage first.
Input Schema
id | stringrequired |
Example Call
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "automations_deleteMailAccount",
"arguments": {
"id": "example"
}
}
}automations_testMailAccountVerify SMTP credentials (and optionally send a test email)
Input Schema
id | stringrequired | |
to | string | Send a real test email here; omit to only verify the connection |
Example Call
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "automations_testMailAccount",
"arguments": {
"id": "example",
"to": "example"
}
}
}automations_listMailhooksList the account's email triggers (Mailhooks) — each is a unique address like k3f9a2b1c7d8e9@mailhook.serenitiesai.com; any email sent or forwarded there runs its target. Optional param "projectId" also filters to hooks bound to that site. Returns { mailhooks: [{id, address, name, targetKind, targetRef, isActive, receivedCount, lastReceivedAt}] }.
Input Schema
projectId | string | Filter to hooks bound to this site (plus unbound ones) |
Example Call
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "automations_listMailhooks",
"arguments": {
"projectId": "example"
}
}
}automations_createMailhookCreate an inbound email trigger. Returns the generated address — any email sent or forwarded to it runs the target with the parsed email as input.
Input Schema
name | stringrequired | Label shown in the dashboard, e.g. "Support inbox" |
targetKind | stringrequired | What runs when an email arrives |
targetRef | stringrequired | Id of the flow / specialist / account function to run |
projectId | string | Optionally associate with one site (informational for flow targets) |
Example Call
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "automations_createMailhook",
"arguments": {
"name": "example",
"targetKind": "example",
"targetRef": "example"
}
}
}automations_updateMailhookRename, retarget, or pause an email trigger. targetKind and targetRef must be sent together when retargeting.
Input Schema
id | stringrequired | |
name | string | |
targetKind | string | |
targetRef | string | |
isActive | boolean |
Example Call
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "automations_updateMailhook",
"arguments": {
"id": "example",
"name": "example",
"targetKind": "example"
}
}
}automations_deleteMailhookPermanently delete an email trigger. Its address immediately stops accepting mail. Param: id.
Input Schema
id | stringrequired |
Example Call
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "automations_deleteMailhook",
"arguments": {
"id": "example"
}
}
}automations_listInboundEmailsRecent emails a mailhook received — the "did my trigger fire?" history
Input Schema
mailhookId | stringrequired | |
limit | integer |
Example Call
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "automations_listInboundEmails",
"arguments": {
"mailhookId": "example",
"limit": {}
}
}
}automations_listEnvVarsList GLOBAL (account-level) secrets (env vars; Automations → Secrets tab) — name, description, updatedAt. Values are NEVER returned. These are what ACCOUNT functions read via ctx.env.get / {{VAR}}; per-site env vars are a separate store (site listEnvVars).
Example Call
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "automations_listEnvVars",
"arguments": {}
}
}automations_setEnvVarCreate or update a GLOBAL (account-level) env var. Value is encrypted at rest and never returned. Creating an EXISTING name fails unless overwrite:true — pass it only when deliberately rotating a value.
Input Schema
name | stringrequired | |
value | stringrequired | |
description | string | |
overwrite | boolean |
Example Call
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "automations_setEnvVar",
"arguments": {
"name": "example",
"value": "example",
"description": "example"
}
}
}automations_deleteEnvVarDelete a GLOBAL (account-level) env var by name. Account functions reading it will start failing — check usage first.
Input Schema
name | stringrequired |
Example Call
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "automations_deleteEnvVar",
"arguments": {
"name": "example"
}
}
}