Documentation sections

Automate

Answer quick calls with functions

A function is one small TypeScript or JavaScript file with a fetch handler. It answers in about a second, with no Docker image and no workflow run. Use it for a webhook receiver, a button on an app page, or a tool an AI can call.

Last reviewed November 15, 2026

In the app Projects → project → Functions

Function or workflow?

Use a function for a quick answer; use a workflow for a long, durable, many-step job. A function runs once and answers. If the job needs waiting, sleeping, or many steps that must survive a restart, write aworkflow instead.

Write a function

A function is one file with no imports. TypeScript is stripped when the function is saved. Declare it insolidactions.yaml:

project: function-echo

functions:
  - id: echo
    name: Echo
    file: functions/echo.ts
    description: Answers with the JSON it was sent.
    webhook: true
    webhook_auth: hmac
    timeout: 10

Then write the file it points to:

export default {
  async fetch(request, env) {
    const input = await request.json().catch(() => ({}));
    return Response.json({ ok: true, echo: input });
  },
};

env holds the project's plain and global variables. A function acts as the project, never as a person: it runs with the project's variables and connections.

Limits

LimitValue
CPU time per call5 seconds
Outbound requests per call50
Timeout1 to 30 seconds, set per function (default 10)
Source size256 KB
Functions per project50
Calls per workspace300 a minute and 1,000,000 a month
New versionsA daily cap on new versions per workspace

Past the call limits a call is refused with rate_limited or quota_exceeded. Past the version cap a save is refused with version_cap_reached.

Make a function

In code
List it under functions: in solidactions.yaml and deploy with the CLI. The file owns the function: the app and MCP can turn it off or on and nothing else.
In the app
Open the project's Functions tab and choose New function. Save deploys: a changed source compiles and becomes the live version, and a compile error names the line and keeps the previous version live. Every older version has Make live, which costs nothing against the version cap. Only people who can edit the project see the tab.
Over MCP
Connected AI tools can list, read, create, change, test-call and delete functions with functions_read, functions_manage and functions_delete. These are for people who can build the project.

Three ways to call one

A webhook URL

A function with webhook: true answers POST /api/webhook/<token> with its own status, body, and content type. Choose how callers prove who they are with webhook_auth:

hmac (default)
The sender signs the request body with the webhook secret.
header
The sender puts the webhook secret in a request header.
none
Anyone who knows the URL can call the function.

The URL and secret are on the project's Webhooks tab (use Reveal), and the CLI lists them too. The CLI lists a function as a row of kind function. Deploy it and list its URL like this:

solidactions project deploy function-echo ./function-echo -e production
solidactions webhook list function-echo --show-secrets

Treat the URL and secret as credentials.

Use --show-secrets only in a trusted terminal and never paste its output into support messages.

A button on an app page

On an app page (a dashboard or a visual page attached to a project), sa.action('<function-slug>', params)calls the function by name:

const answer = await sa.action('echo', { hello: 'world' });
// answer.status, answer.body

The answer carries the function's own status and body. The function's own status, even a 500, counts as a successful action, so the page decides what to do with it. A call the platform refuses, such asfunction_disabled or rate_limited, rejects instead.

A button can call only a function its page grant lists. The grant is captured when the page is published (a dashboard) or saved (a visual page), and only a person who can build the project (edit access to Automate) grants functions. A page published or saved by a person with only Use-level access grants none, so a button on it answers not_granted for everyone. Publish or save the page again after a function gets its first live version, and if the button still answersnot_granted, ask a person who can build the project to publish or save it.

A function with confirm: true asks first: the page shows a confirmation dialog naming the function, and the function does not run until the viewer says yes. The function also receives who pressed the button (SA_VIEWER_ID, SA_VIEWER_TYPE, SA_VIEWER_NAME) and which page (SA_PAGE_ID). That is data for the function, never authority: the function still acts as the project.

Your own confirm text

A function can set its own confirm text, at most 255 characters. The dialog shows it above the standard line. It shows only while confirm is true. Set it in any of three places:

In the app
Type it in the function's editor on the Functions tab.
Over MCP
Pass confirm_text to functions_manage. Null or empty clears it.
In solidactions.yaml
Add confirm_text beside confirm. This needs CLI 3.38 or newer. An older CLI ignores the key without a warning.
functions:
  - id: send-report
    name: Send report
    file: functions/send-report.ts
    confirm: true
    confirm_text: Send the weekly report to everyone?

The file owns a function made in code, so a deploy clears the confirm text when the entry has noconfirm_text, or a blank one. Keep it in the file.

An AI over MCP

A connected AI can test-call the live version with functions_manage and the invokeaction. It sends a JSON object as the input and gets back the function's status, content type, and body. Reading needs the functions:read permission; changing, running, or deleting needsfunctions:edit, because running a function runs its code with its side effects.

Start a workflow after you answer

env.sa.workflows.start(slug, input) starts a workflow of the same project and answers{ run_id }. Add { after: true } as a third argument to start it after the function has answered. You then get { queued: true } with no run id:

export default {
  async fetch(request, env) {
    const input = await request.json().catch(() => ({}));
    // Await it before returning. The workflow starts after this function answers.
    await env.sa.workflows.start('send-report', input, { after: true });
    return Response.json({ ok: true });
  },
};

The trade-off:

  • There is no immediate refusal. A plan limit or a turned-off workflow shows up later as a "Not started" run on the workflow's run list.
  • The run only starts if the function returns a Response below 400 (a 2xx or a 3xx). A 4xx or 5xx, an uncaught throw, a timeout, a limit, an answer over 1 MB or a platform error drops it. A function that answers "bad request" never starts the workflow.
  • Await it before returning. A request sent after the answer is refused with call_over.

Several statements in one call

env.sa.database('NAME') opens a workspace database bound under that variable name. Itsbatch(statements) takes 1 to 50 { sql, args? } statements and runs them in one round trip. It answers one { columns, rows, rowsAffected } per statement, in order:

const db = env.sa.database('ANALYTICS_DB');
const results = await db.batch([
  { sql: 'INSERT INTO events (name) VALUES (?)', args: ['signup'] },
  { sql: 'SELECT COUNT(*) AS total FROM events' },
]);
// results[0].rowsAffected, results[1].rows

A batch is not atomic and does not stop at a failure. Every statement runs, and the statements that succeeded stay applied. The first failing statement is thrown as sql_error with the messagestatement N: ..., where N counts from 1.

A statement that is not an object with a string sql and an optional array args, or a list that is not 1 to 50 statements, is thrown as bad_request before any request is made.

Functions can be switched off

Functions are on or off for the whole SolidActions stack. While they are off, a deploy reportsfunctions_disabled and a function's webhook answers 503. That is an operator setting, not a problem in your code.

Next: put a function behind a webhook, call it from adashboard, or read how projects hold it.