> ## Documentation Index
> Fetch the complete documentation index at: https://developers.telnyx.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Environment Variables

> Functions run as containers, so configuration arrives as ordinary environment variables — declared in the project manifest, injected from secrets and bindings, or set by the platform.

Functions run as real containers, so configuration reaches your code as ordinary process environment variables — `process.env`, `os.environ`, `os.Getenv`, `System.getenv`. There is no separate configuration API to learn.

## What's in the environment

| Variable               | Where it comes from                                                                                                                                           |
| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `PORT`                 | Set by the platform. Your HTTP server must listen on it.                                                                                                      |
| Every `[env_vars]` key | Declared in `func.toml`; injected verbatim on each deploy.                                                                                                    |
| Every secret key       | `telnyx-edge secrets add <key> <value>` injects the key into **all** functions in your organization. See [Secrets](/docs/edge-compute/configuration/secrets). |
| `TELNYX_API_KEY`       | Injected when the function declares a `[telnyx]` binding. This is how non-TypeScript runtimes call the [Telnyx API](/docs/edge-compute/telnyx-api).           |

## Declaring variables

Define non-sensitive configuration under `[env_vars]` in `func.toml`:

```toml theme={null}
[edge_compute]
func_id   = "7819cf01-39a8-400e-9bce-3d792ffa4017"
func_name = "demo-ts"

[env_vars]
LOG_LEVEL   = "info"
MAX_RETRIES = "3"
DEBUG       = "false"
```

Three behavioral contracts:

* **All values are strings.** Parse numbers and booleans in your code.
* **Changes take effect on the next `telnyx-edge ship`** — there is no live update.
* **Names share the `env` namespace with bindings.** If an `[env_vars]` entry has the same name as a declared binding — or is named `SECRETS` while a `[[secrets]]` block is declared — `ship` **warns** that one shadows the other on `env` and still proceeds; rename one. (A *binding* named `SECRETS`, or a duplicate `[[secrets]]` handle, is a hard error.)

`[env_vars]` values are plaintext in `func.toml` and end up in version control. Put credentials in [secrets](/docs/edge-compute/configuration/secrets) instead.

## Reading variables

<Tabs>
  <Tab title="TypeScript / JavaScript">
    ```ts theme={null}
    const port = Number(process.env.PORT ?? 8080);         // set by the platform
    const logLevel = process.env.LOG_LEVEL ?? "info";      // from [env_vars]
    const maxRetries = Number(process.env.MAX_RETRIES ?? "3");
    const debug = process.env.DEBUG === "true";
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    import os

    log_level = os.environ.get("LOG_LEVEL", "info")
    max_retries = int(os.environ.get("MAX_RETRIES", "3"))
    debug = os.environ.get("DEBUG", "false").lower() == "true"
    ```
  </Tab>

  <Tab title="Go">
    ```go theme={null}
    package function

    import (
        "os"
        "strconv"
    )

    func loadConfig() (logLevel string, maxRetries int, debug bool) {
        logLevel = os.Getenv("LOG_LEVEL")
        if logLevel == "" {
            logLevel = "info"
        }
        maxRetries, _ = strconv.Atoi(os.Getenv("MAX_RETRIES"))
        debug, _ = strconv.ParseBool(os.Getenv("DEBUG"))
        return
    }
    ```
  </Tab>

  <Tab title="Quarkus (Java)">
    ```java theme={null}
    String logLevel = System.getenv().getOrDefault("LOG_LEVEL", "info");
    int maxRetries = Integer.parseInt(System.getenv().getOrDefault("MAX_RETRIES", "3"));
    boolean debug = Boolean.parseBoolean(System.getenv("DEBUG"));
    ```
  </Tab>
</Tabs>

## Environment variables vs secrets

|            | `[env_vars]`                                         | Secrets                                  |
| ---------- | ---------------------------------------------------- | ---------------------------------------- |
| Stored     | Plaintext in `func.toml`, committed to git           | Server-side; the CLI never prints values |
| Scope      | One function                                         | Every function in the organization       |
| Changed by | Editing `func.toml`, then `ship`                     | `telnyx-edge secrets add`, then `ship`   |
| Use for    | Log levels, feature flags, public URLs, tuning knobs | API keys, passwords, signing keys        |

## Next Steps

* [Secrets](/docs/edge-compute/configuration/secrets) — the server-side counterpart for sensitive values, including the typed `env.SECRETS` surface for TypeScript
* [Bindings](/docs/edge-compute/runtime/bindings) — typed, pre-authenticated handles instead of raw variables
* [Configuration](/docs/edge-compute/configuration) — the full manifest reference: every `func.toml` and `telnyx.toml` key
