Manage Sinch Functions — the full lifecycle from creation through deployment and operations.
Initialize a new function from a template. Downloads the template, prompts for variables and secrets, sets up the project directory, and installs dependencies.
Syntax
sinch functions init [template] [options]Running this from a pipeline? See CI/CD.
Voice templates. Every template in the voice category runs a Voice service picker, whether or not the template declares VOICE_SERVICE_ID itself. "Create a new one" is the first choice and the default whenever the project has services; choosing an existing service is opt-in. Either way, init writes the id as VOICE_SERVICE_ID in .env (Node.js) or appsettings.json (C#); the Functions API then points that service's inbound webhook at the deployed function itself, server-side, during sinch functions deploy. Skipping the picker leaves the value unset, and init prints the key to set later. No Voice Application Key or Secret is requested — that legacy pair is prompted for only by a template that names VOICE_APPLICATION_KEY among its variables.
--non-interactive never calls the picker (it never lists services from the API), so a voice template gets no VOICE_SERVICE_ID unless one is supplied with --voice-service-id. Without it, init omits the key and prints a warning instead of writing it blank.
Creating a service and renting a number. Interactively, the picker offers "Create a new one" (asked as a yes/no question, default yes, when the project has no services). A new service is named after the function. Init then asks whether to rent a phone number for it (default no), for a region (default US) and an optional area code. It searches for one LOCAL voice number, shows its price, and orders it only after you confirm. The number is linked to the service and written to .env (or appsettings.json) as VOICE_FROM_NUMBER. Only US numbers can be rented from init; another region skips the number step with one note and init carries on.
When init creates a service or rents a number, it records them in sinch.json as createdResources, along with the function name. A sinch functions deploy of that function sends them to the API, so deleting the function releases them, and clears each one once the API's record of the function lists it. Deploying under another name with --name does not send them, so a scratch or preview copy cannot claim them. A service you picked is never recorded.
Renting a number costs money. A non-interactive run orders only with --force; --rent-number without it fails before anything is created, and names --force. --create-voice-service alone is free.
Voice functions are initialised with accessKey: "managed" in sinch.json, so deploy uses a managed key unless you change it.
--json. With --json, init never prompts (it implies --non-interactive) and prints one document on stdout: { name, path, template, runtime, functionId?, voiceServiceId?, phoneNumber?, warnings? }. Errors are printed as JSON and the exit code follows the usual contract.
Examples:
# A new voice service, no number
sinch functions init simple-voice-ivr --non-interactive --create-voice-service
# A new service plus a US number in area code 415 (costs money)
sinch functions init simple-voice-ivr --non-interactive --create-voice-service --rent-number US --area-code 415 --forceOptions
| Option | Description |
|---|---|
[template] | Template name to use (e.g., simple-voice-ivr). May also be given as runtime/template-name (e.g., node/simple-voice-ivr), the form printed by sinch templates list and sinch templates show — the prefix sets the runtime, and it is an error if it contradicts --runtime. |
--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 |
--voice-service-id <id> | Voice v2 service to route inbound calls through (voice templates only). Required for a routed voice function in a non-interactive init; interactively the default stays "Create a new one". |
--create-voice-service | Create a new Voice v2 service named after the function (voice templates only). Free. |
--rent-number <region> | Rent a LOCAL number and link it to the service. Only US is supported; other regions skip the step. Costs money; with --non-interactive or --json it also needs --force. |
--area-code <digits> | Area code for --rent-number. |
-f, --force | Confirm the number rental without asking. |
--json | Print one JSON document; never prompts. |
List all functions in the current project.
sinch functions listDeploy 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. An empty value in .env / appsettings.json also resolves from the CLI's own process environment before falling back to the keychain, so a caller that injects secrets straight into the deploy process (no on-disk secret store to read from) doesn't need one. A filled value whose name looks like a credential (OPENAI_API_KEY, GITHUB_TOKEN; not MAX_TOKENS or PUBLIC_KEY) also deploys as a secret, and other filled values deploy as plain configuration. For C#, appsettings.json also ships inside the package, so deploy warns about a filled credential there: leave it blank and set it with dotnet user-secrets instead. After deployment, the CLI automatically updates your Voice v1 application callback URL or Conversation webhook if configured; a Voice v2 service (VOICE_SERVICE_ID) is pointed at the function by the Functions API itself, not the CLI.
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 to recreate it. This is a hard error, not a warning, so --force does not bypass it.
On an interactive first deploy, the CLI asks whether to use a managed key for the function (default: yes) and saves the choice as accessKey: "managed" or accessKey: "profile" in sinch.json; use --managed-keys to select and persist managed keys without prompting. Existing accessKey values are reused without prompting, while --non-interactive and truthy CI use profile for the current deploy without adding the field.
Any warnings the API returns for the deployment (for example, about the managed key configuration) are printed after the deploy and included in the --json output.
When sinch.json records a functionId and the function with that id still has the deploy's name, deploy updates that function by id and sends the recorded versionId as the base version. If the function was deleted, or has a different name, deploy warns that it is deploying by name and says why. Any other failure to look the function up fails the deploy.
If the function changed since the copy was taken, the API refuses the deploy as stale. Interactively, deploy says which version the function is at now and asks whether to overwrite it (default: no). With --non-interactive, a truthy CI or --json, or if you decline, deploy exits with code 103; pass --overwrite to deploy anyway. --force only covers validation warnings and does not skip this check.
The first CLI deploy of an existing function moves it to CLI management for good: the web editor, rollback from the dashboard and the Assistant are then turned off for it. Before packaging, deploy says so when the function exists and isn't CLI-managed yet. Interactively it asks whether to continue (default: yes), and declining deploys nothing and exits 0. With --non-interactive, a truthy CI, --json or no terminal, it prints the notice and deploys; under --json the notice is in warnings. A new function, a function already managed from the CLI, and a deploy with SINCH_CLIENT=ai-builder get no notice.
After a deploy under the name in sinch.json, deploy records the functionId and the new versionId there. A deploy under a different --name leaves both unchanged, so a preview deploy never moves the project off its own function. The --json output and --no-wait output include versionId.
Syntax
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 |
--managed-keys | Use and persist a managed access key |
--no-docs | Skip documentation generation |
--public | Deploy to the public namespace (internet-accessible) |
--force | Deploy despite validation warnings without prompting |
--overwrite | Deploy even if the function changed since this copy was taken |
-m, --message <text> | Note saved on the new version |
--json | Print the result as JSON and suppress progress output |
--private | Deploy to private namespace (internal access only) |
--strict-audit | Fail the deploy if the dependency audit finds anything at --audit-level |
--audit-level <level> | Severity the dependency audit reports on: low, moderate, high (default), critical |
Dependency audit
Node functions are audited before upload. The CLI runs npm audit --omit=dev in the function directory and prints a one-line summary. It never blocks unless you pass --strict-audit, so an advisory feed outage cannot stop a deploy; if the audit cannot run (no lockfile, offline, timeout) it says so and continues. Dev dependencies are excluded because the platform build prunes them.
The same step fails the deploy on dependencies the platform build cannot resolve: paths on your machine (file:, link:, portal:, or a relative, absolute, home or Windows drive path) and git checkouts (git+, git://, git@, github:, gitlab:, bitbucket:). Neither is uploaded with the function, so the build would fail later with a less obvious error. Unlike the audit above, this check includes devDependencies, because the build installs them before pruning. This is a hard error, not a warning, so --force does not bypass it. Publish the packages, or vendor them into the function directory, before deploying.
Both checks are Node-only; C# functions skip them.
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
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 |
--non-interactive | No prompts: no tunnel unless the preference is "always" |
Show the current status and details of a deployed function.
sinch functions status [function-id]If function-id is omitted, reads it from sinch.json in the current directory.
List a function's version history, newest first. Versions from every source (CLI deploys, the web, the Assistant, templates, rollbacks) are listed, each with its number, source, state, creation time and message. The live version is marked ● live.
Versions do not show an author yet.
sinch functions versions [function-id] [options]If function-id is omitted, reads it from sinch.json in the current directory.
Options
| Option | Description |
|---|---|
--page <n> | Page of versions to show (default: 1) |
--page-size <n> | Versions per page (default: 20) |
--json | Print { versions, pagination } as one JSON document |
When the history spans more than one page, the output says which page it shows and how to reach the next one.
Example
sinch functions versions --page 2 --page-size 10View logs for a deployed function. By default it prints the most recent requests and exits; -f instead streams new requests as they arrive, without the recent ones. -i opens an interactive terminal UI with a table of requests (with -f, the table shows only new requests); press Enter on any row to see request/response details.
Syntax
sinch functions logs [function-id] [options]Options
| Option | Description |
|---|---|
-f, --follow | Stream logs in real-time |
-i, --interactive | Open the interactive terminal UI; with -f it updates live |
-n, --lines <number> | Number of recent entries to load, a positive whole number (default: 100, max 500) |
--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) |
--json | Print JSON to stdout instead of text (see below) |
--lines, --level, --search and --since apply only to recent logs. The live stream (-f, -i -f or logs stream) ignores them and shows every new request.
Interactive UI controls (with -i)
| Key | Action |
|---|---|
Up / Down | Navigate rows |
Enter | Open request detail |
Esc | Close detail |
Q | Close detail, or quit from the list |
Ctrl+C | Quit |
JSON output
--json prints machine-readable output and nothing else on stdout. It cannot be combined with --interactive.
Without --follow, one document is printed:
{
"function": { "id": "fn-1", "name": "my-function", "status": "active" },
"requests": []
}requests holds the same entries the table shows, honouring --lines, --level, --search and --since.
With --follow, the output is NDJSON: one compact request object per line, as each request arrives. If the connection to the log stream drops, the command prints an error document and exits with code 1 rather than waiting silently.
On failure the command prints { "error": "...", "statusCode": 500, "serverBody": "..." } to stdout and exits with code 1. statusCode and serverBody appear only when the API returned them.
Alias for sinch functions logs --follow. Connects to the live log stream and displays new requests as they arrive.
sinch functions logs stream [function-id] [options]| Option | Description |
|---|---|
--level <level> | Accepted but not applied: the stream shows every request |
--search <text> | Accepted but not applied: the stream shows every request |
--json | Print one compact request object per line (NDJSON), as for logs -f |
Download the deployed source code of a function as a ZIP file.
sinch functions download [function-id]download fetches the function's live version and records its id as versionId in sinch.json, so the next sinch functions deploy is checked against the version you downloaded. A function with no live version downloads as before and records none.
The function's configuration is fetched before anything is written. If that fails, the command exits with an error and writes no directory, sinch.json or .env; an existing target directory is left as it was.
If the function has secrets, download offers to fetch and install them locally. With --non-interactive, or when there is no TTY to answer on, the fetch is skipped and the command prints the sinch secrets add line to run by hand.
With --json, the command never prompts and prints { functionId, versionId?, path, files } (versionId is left out when there is no live version; files is left out with --no-extract, where path is the ZIP file). It fails with an error naming the missing input if [function-id] is omitted, or naming --force if the target directory already exists. Secrets are not fetched.
Delete a deployed function. Prompts for confirmation unless --force is passed.
sinch functions delete <function-id>With --json, --force or --non-interactive is required and the command prints { functionId, deleted: true }.
Restore an earlier version's code as a new version of the function.
sinch functions rollback <version> [function-id] [-m <text>] [--no-wait] [--non-interactive] [--json]<version> is the version number sinch functions versions shows, or the version's id. [function-id] defaults to the functionId in sinch.json. -m, --message saves a note on the new version.
Rollback restores code only. Environment variables, settings and database data stay as they are.
When it can prompt, the command names the version, says it restores code only, and asks for confirmation (default: no). Declining creates nothing and exits 0. --non-interactive, a truthy CI or --json roll back without asking.
A version whose build failed can't be restored. The command shows the API's reason and exits 103. An unknown version exits 102.
By default the command waits for the new version's build, reports the outcome the way deploy does, and exits non-zero if the build failed. --no-wait returns once the rollback is accepted.
After a rollback the local copy no longer matches the live code, and sinch.json is not changed. Run sinch functions download to pull the restored code. Until you do, a deploy from the old copy is refused as stale and exits 103 when it can't ask.
With --json, the command prints { functionId, version, restoredFromVersionId } and no other output. Without --no-wait it prints the document once the build has finished; a failed build prints an { error } document and exits non-zero instead.
Check the function configuration before deployment.
sinch functions validate [-n <name>]With --json, the command prints { valid, errors, warnings }, where each issue has code, message and, when there is one, suggestion. When valid is false it exits 78 after printing that document.
Generate AI-powered documentation for the function in the current directory. Reads the function source and writes a README.md.
sinch functions docs


