# sinch env

Manage a function's `.env` file.

Node.js only. C# functions keep configuration in `appsettings.json` / `dotnet user-secrets`, and these commands exit with an error if `sinch.json` declares `runtime: csharp`.

## sinch env init

Create `.env` from your `sinch.json` variables and stored credentials. Use this to recover a deleted or missing `.env` — for example after a fresh clone, or when `sinch functions deploy` refuses to run because the file is gone.

```sh
sinch env init [--force]
```

**Options**

| Option | Description |
|  --- | --- |
| `--force` | Overwrite an existing `.env` file. |


Without `--force`, the command refuses to touch an existing `.env` rather than overwrite work in progress.

**What it writes**

The scaffold contains your project identifiers (`PROJECT_ID`, `FUNCTION_ID`, `PROJECT_ID_API_KEY`), every variable declared in `sinch.json`, and an empty `KEY=` line for each secret.

**What it cannot restore**

- **Secret values.** These live in the OS keychain and resolve at deploy time, so they are written as empty placeholders. Add any that are missing with `sinch secrets add <KEY> <VALUE>`.
- **Non-secret values you typed by hand.** The CLI has no record of what they were — re-enter them.


To restore a deployed function completely, including its secret values, use `sinch functions download <function-id>` instead.

## Related

- [`sinch functions deploy`](/assets/functions.b8b8f7893a52b7d9657dc25287a0cd29c8090664aaee50a82dac24858d65c1d4.63d64e7d.md) — refuses to deploy a Node.js function with no `.env`
- [`sinch secrets` commands](/assets/secrets.991de099f34c5ede9b5cf8b0f21e5dcfafc23cd23142a4b659932aca5d4021aa.63d64e7d.md) — store secret values in the OS keychain
- [Configuration and secrets](/docs/functions/functions/concepts/configuration-secrets) — how `.env`, `sinch.json`, and the keychain fit together