> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cloudservices.ecowestern.net/llms.txt
> Use this file to discover all available pages before exploring further.

# Deploy a Flow function

> Create, update, and redeploy Flow functions

All deployment routes use an ECS API key with `flow:write`.

## Asset format

`assets` maps file paths to file descriptors:

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "main.ts": {
    "content": "Deno.serve(() => new Response('ok'));",
    "encoding": "utf-8"
  },
  "lib/message.ts": {
    "content": "export const message = 'hello';"
  }
}
```

`encoding` defaults to `utf-8` and may be `base64`. Use `base64` for binary files.

The entrypoint is resolved relative to the asset map. Include every local import in the request.

## Create a function

`POST /flow/functions`

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "name": "hello",
  "entrypoint": "main.ts",
  "assets": {
    "main.ts": {
      "content": "Deno.serve(() => new Response('Hello'));"
    }
  }
}
```

`name` and `assets` are required. `entrypoint` defaults to `main.ts`.

The response is `201 Created` and includes the function record, `revision_id`, and `revision_status`. Save the revision ID for status checks and logs.

## Redeploy a function

`PATCH /flow/functions/:name`

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "entrypoint": "src/main.ts",
  "assets": {
    "src/main.ts": {
      "content": "Deno.serve(() => new Response('updated'));"
    }
  }
}
```

`assets` is required. `entrypoint` is optional. A redeploy creates a new revision while keeping the function name and invocation path stable.

## List and inspect

* `GET /flow/functions` returns `{ "functions": [...] }`.
* `GET /flow/functions/:name` returns one function record.

Both require `flow:read`.

## Delete

`DELETE /flow/functions/:name` requires `flow:delete` and returns `204 No Content`.

Deletion is permanent. Confirm the function name before issuing the request.

## Deployment checklist

* Include the entrypoint in `assets`.
* Include every local import.
* Use `base64` for binary files.
* Save the returned `revision_id`.
* Poll status before sending production traffic.
* Keep a previous successful revision available for rollback.
