# sinch functions

Manage Sinch Functions — the full lifecycle from creation through deployment and operations.

## sinch functions init

Initialize a new function from a template. Downloads the template, prompts for variables and secrets, sets up the project directory, and installs dependencies.

**Syntax**

```sh
sinch functions init [template] [options]
```

**Options**

| Option                | Description                                                                                                                                                                                                                                                                           |
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `[template]`          | Template name to use (e.g., `simple-voice-ivr`)                                                                                                                                                                                                                                       |
| `--name <name>`       | Function name (defaults to template name)                                                                                                                                                                                                                                             |
| `--runtime <runtime>` | Runtime: `node` or `csharp`. Optional when `[template]` is given — the CLI infers the runtime from the template name and only prompts when no template arg is passed. If the same template exists for both runtimes, Node.js is used by default; pass `--runtime csharp` to override. |
| `--skip-install`      | Skip `npm install` for Node.js projects                                                                                                                                                                                                                                               |
| `--non-interactive`   | Use defaults without prompting                                                                                                                                                                                                                                                        |

## sinch functions list

List all functions in the current project.

```sh
sinch functions list
```

## sinch functions deploy

Deploy the function in the current directory to production. Packages the source into a ZIP, reads configuration from `.env` (Node.js) or `appsettings.json` / `dotnet user-secrets` (C#), and submits a deployment job.

For C# functions, the CLI builds and health-checks locally before deploying. Secrets are pulled from the OS keychain automatically. After deployment, the CLI automatically updates your Voice callback URL or Conversation webhook if configured.

For Node.js functions, deploy stops before packaging if there is no `.env` file in the project directory — without one the deployed function has no configuration and will not run. Run [`sinch env init`](./env.md) to recreate it. This is a hard error, not a warning, so `--force` does not bypass it.

**Syntax**

```sh
sinch functions deploy [options]
```

**Options**

| Option              | Description                                        |
| ------------------- | -------------------------------------------------- |
| `-n, --name <name>` | Override function name                             |
| `--no-wait`         | Submit deployment and return immediately           |
| `--non-interactive` | Use defaults without prompting                     |
| `--no-docs`         | Skip documentation generation                      |
| `--private`         | Deploy to private namespace (internal access only) |

## sinch functions dev

Start a local development server with hot reload. The server restarts automatically when you save changes.

On first run, prompts whether to create a tunnel for receiving webhooks locally. Use `--tunnel` or `--no-tunnel` to override.

**Syntax**

```sh
sinch functions dev [options]
```

**Options**

| Option              | Description                                               |
| ------------------- | --------------------------------------------------------- |
| `-p, --port <port>` | Port to listen on (default: `3000`)                       |
| `-d, --debug`       | Enable debugger — creates `.vscode/launch.json` if absent |
| `--tunnel`          | Force tunnel creation                                     |
| `--no-tunnel`       | Disable tunnel and reset any "always" preference          |

## sinch functions status

Show the current status and details of a deployed function.

```sh
sinch functions status [function-id]
```

If `function-id` is omitted, reads it from `sinch.json` in the current directory.

## sinch functions logs

View historical logs for a deployed function. Opens an interactive terminal UI showing a table of requests. Press Enter on any row to see request/response details.

**Syntax**

```sh
sinch functions logs [function-id] [options]
```

**Options**

| Option                 | Description                                                |
| ---------------------- | ---------------------------------------------------------- |
| `-f, --follow`         | Stream logs in real-time                                   |
| `-n, --lines <number>` | Number of historical entries to load (default: `50`)       |
| `--level <level>`      | Filter by log level: `debug`, `info`, `warning`, `error`   |
| `--search <text>`      | Filter entries containing this text                        |
| `--since <duration>`   | Show logs from the last duration (e.g., `1h`, `30m`, `5s`) |

**Interactive UI controls**

| Key             | Action                                    |
| --------------- | ----------------------------------------- |
| `Up` / `Down`   | Navigate rows                             |
| `Enter` / click | Open request detail                       |
| `Esc` / `Q`     | Close detail or quit                      |
| `J`             | Copy request as JSON to clipboard         |
| `C`             | Copy request as cURL command to clipboard |

## sinch functions logs stream

Alias for `sinch functions logs --follow`. Connects to the live log stream and displays new requests as they arrive.

```sh
sinch functions logs stream [function-id] [options]
```

## sinch functions download

Download the deployed source code of a function as a ZIP file.

```sh
sinch functions download [function-id]
```

## sinch functions delete

Delete a deployed function. Prompts for confirmation unless `--force` is passed.

```sh
sinch functions delete <function-id>
```

## sinch functions docs

Generate AI-powered documentation for the function in the current directory. Reads the function source and writes a `README.md`.

```sh
sinch functions docs
```
