---
title: "ezgh secrets put"
description: "Write a new version of a secret."
---

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

# ezgh secrets put

{/* Generated by ezgh-cli's internal/tools/clidocs from the ezgh command tree. Don't edit: change the command's help in ezgh-cli and regenerate. */}

```sh
ezgh secrets put <name> [--from-env-file f] [--set K=V]… [--remove K]… [--base N|latest] [--replace] [flags]
```

Write a new version. By default the fields given are changed in a version you build on (`--base`, latest unless you say a number): `--set` and `--from-env-file` add or replace fields, `--remove` drops them, and every other field is carried over. The write fails with a conflict if the secret changed since the base was read; run the command again.

`--replace` makes the new version exactly the fields given, dropping every other field (`--base` and `--remove` don't apply).

`--set` KEY=VALUE sets a field; KEY=@file reads the value from a file (a file that isn't UTF-8 is sent as binary), and KEY=- reads it from stdin. `--set` wins over `--from-env-file`. Values are not printed.

Part of [`ezgh secrets`](/cli/reference/secrets).

## Examples

```sh
ezgh secrets put prod/app --set API_KEY=new --remove OLD_KEY
ezgh secrets put prod/app --from-env-file .env --replace
```

## Flags

| Flag | Type | Default | Description |
| --- | --- | --- | --- |
| `--base` | string | `latest` | the version to build on: a number, or latest |
| `--from-env-file` | string |  | read fields to write from a .env file: KEY=VALUE lines (# comments, export, and quoted values are understood) |
| `--remove` | string, repeatable |  | drop a field (repeat for more) |
| `--replace` | boolean |  | make the new version exactly the fields given, dropping the rest |
| `--set` | string, repeatable |  | set a field: KEY=VALUE, KEY=@file (the file's bytes) or KEY=- (stdin). Repeat for more |

This command also takes the [global flags](/cli/reference#global-flags).

Source: https://docs.ezghcloud.com/cli/reference/secrets-put/index.mdx
