# 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.

Last updated: October 15, 2026

Source: https://www.willo.ai/docs/ai-agents/deploy-an-edge-function

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 is saved to the `draft` branch. With drafting off, it deploys live and saves to `main`. A deploy never rebuilds the site. The result says where it landed. See [Draft and live](https://www.willo.ai/docs/ai-agents/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 the same way 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 a `source_sha256`, a fingerprint of that version.

- For a targeted change, `willo_edit_function` takes `old_text` and `new_text` (or `edits` for several), plus the `source_sha256`. It changes the deployed source and redeploys.
- To replace the whole function, `willo_deploy_function` with `code` also needs that `source_sha256`.

If someone changed the function after the agent read it, the call is refused and the agent reads it again. Nobody's work is overwritten unseen.

## 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:

```json
{ "name": "contact-notify", "source_path": "supabase/functions/contact-notify/index.ts", "summary": "Emails the owner each new contact form." }
```

Saving a file to the repository never changes the running function on its own. The deploy is what 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.

> **Needs approval.**
>
> A function that is public **and** runs with admin powers over your database, with no check on who is calling, is refused at first. The agent can pass `public_admin_reason`, one sentence on why it must be that way, and the deploy then needs your approval on a card.

## Check it works

- `willo_list_functions` lists the functions with their invoke URLs.
- `willo_logs` with the default `service` shows 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. |
| An imported file | Write the missing file to the repository, then deploy again. |
| `public_admin_reason` | Add a caller check, or explain why it must be public and approve the card. |

Deleting a function always needs approval and has no undo.

Related: [willo_deploy_function](https://www.willo.ai/docs/reference/mcp-tools/willo_deploy_function), [willo_edit_function](https://www.willo.ai/docs/reference/mcp-tools/willo_edit_function).
