Deploy an edge function from your agent
Have your agent create, change and redeploy one of your backend's edge functions, including functions split across several files.
On this page
Edge functions are small pieces of server code (Deno, TypeScript) that run on your business's backend at /functions/v1/<name>. Your agent can create, change and redeploy them with a read + act token. Deploying a function runs without a card, as it does in Willo's chat, and can be undone from the dashboard.
Where it deploys
While the business is drafting, a deploy goes to the draft backend and the function's source, with every local file it imports, is saved to the draft branch. With drafting off, it deploys live and saves to main. A deploy never rebuilds the site. The result's git block names the commit, or says saved_to_git: false and why. See Draft and live.
Create a new function
Prompt: "Create an edge function called contact-notify that receives the contact form and emails me."
The agent calls willo_deploy_function with:
name: the slug, letters, digits, dashes and underscores, starting with a letter;code: the full source;summary: one plain sentence for you on what it does for the business.
Willo checks the source as chat does. A key written into the code is refused: read secrets from the environment and add them on the dashboard. Tables the function writes to must exist.
Change an existing function
The agent must read before it overwrites. willo_get_function returns the deployed source and its source_sha256 fingerprint.
- For a targeted change,
willo_edit_functiontakesold_textandnew_text(oreditsfor several), plus thesource_sha256. It changes the deployed source and redeploys. - To replace the whole function,
willo_deploy_functionwithcodealso needs thatsource_sha256.
If someone changed it since, the call is refused and the agent reads it again. Nobody's work is overwritten unseen.
The live version while drafting
While the business is drafting, willo_get_function returns the draft's version of a function the draft changed. Pass target: "live" to read the version the live backend is running: its source, verify_jwt, source_sha256 and the names of the secrets it reads (never their values). It is Willo's saved copy, not a read from the backend. willo_list_functions with target: "live" gives each function's live_source_sha256 the same way.
Edits always apply to the draft. Read without target before editing.
Put back the version before a publish
If a publish broke a function, willo_get_function with version: "before_last_publish" returns Willo's copy of the version live ran before the latest publish that changed it, dated, or says that publish created it.
To restore it, the agent reads the current version (no version), then deploys the old code with willo_deploy_function, passing the current version's source_sha256. The deploy goes to the draft, and publishing puts it live. For a function split across files, only index.ts comes back; the other files deploy as the repository has them now.
Deploy from the repository
When the function's source is already in the repository, for example after the agent edited it with willo_edit_file, deploy that file instead of sending code:
{ "name": "contact-notify", "source_path": "supabase/functions/contact-notify/index.ts", "summary": "Emails the owner each new contact form." }Saving a file never changes the running function; the deploy ships it.
Functions with several files
A function's index.ts can import local files, such as ../_shared/cors.ts. Willo reads every local file it imports from the repository's draft branch and ships them in the same deploy. Write the shared file with willo_write_file first, then deploy. If an imported file is missing, the deploy is refused and nothing changes.
Public functions and verify_jwt
By default a function only accepts calls that carry a valid key from your backend, such as your site's public key or a signed-in member's session (verify_jwt: true). Set verify_jwt: false for an endpoint an outside service calls, such as a webhook receiver that checks its sender's signature itself. A redeploy from source_path keeps the function's current setting unless the agent passes one.
Check it works
willo_list_functionslists the functions with their invoke URLs.willo_logsshows recent function errors, from the draft backend while drafting.
When a deploy fails
A refused deploy changed nothing; the message says why. Common reasons:
| Message mentions | Fix |
|---|---|
source_sha256 | Read the function again with willo_get_function, then retry with the new value. |
| A secret in the source | Move the value to a dashboard secret and read it from the environment. |
public_admin_reason | Add a caller check, or explain why it must be public and approve the card. |
| The check could not follow the user | Bind the user straight from auth.getUser as the message shows, use user.id whole in the check, and re-send. |
| The security check could not finish | Split the function into smaller ones, or move large data into a table or a storage file. This can't be approved on a card. |
Deleting a function always needs approval and has no undo.
Related: willo_deploy_function, willo_edit_function.