You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Later steps can use `AGENT_MEMORY_TOKEN` as the bearer token when calling the API.
113
+
**JSON output format for `token add`**
114
+
115
+
When you use `--format json`, `agent-memory token add` returns a JSON object with fields like:
116
+
117
+
```json
118
+
{
119
+
"token": "the-plaintext-token",
120
+
"hash": "abc12345def67890...",
121
+
"description": "CI bootstrap token",
122
+
"created_at": "2025-07-10T18:30:00.000000+00:00",
123
+
"expires_at": "2025-08-09T18:30:00.000000+00:00"
124
+
}
125
+
```
126
+
127
+
You can extract any of these fields in your scripts (for example, `.token` or `.hash` with `jq`).
128
+
129
+
#### Terraform example (register a pre-generated token)
130
+
131
+
If you generate tokens outside Redis Agent Memory Server (for example via a secrets manager), you can register them using `--token` so the server only ever stores a hash:
132
+
133
+
```hcl
134
+
variable "agent_memory_token" {
135
+
type = string
136
+
sensitive = true
137
+
}
138
+
139
+
resource "terraform_data" "agent_memory_token" {
140
+
provisioner "local-exec" {
141
+
environment = {
142
+
AGENT_MEMORY_TOKEN = var.agent_memory_token
143
+
}
144
+
145
+
command = <<EOT
146
+
TOKEN_JSON=$(agent-memory token add \
147
+
--description "Terraform bootstrap" \
148
+
--token "$AGENT_MEMORY_TOKEN" \
149
+
--format json)
150
+
echo "$TOKEN_JSON" > agent-memory-token.json
151
+
EOT
152
+
}
153
+
}
154
+
```
155
+
156
+
For Terraform versions earlier than 1.4, you can use a `null_resource` instead of `terraform_data`.
157
+
158
+
In both cases, store the plaintext token in a secure secret store (GitHub Actions secrets, Terraform variables, Vault, etc.). The server will hash it before storing. When the CLI generates a token (without `--token`), it displays the plaintext only once; when using `--token` with a pre-generated value, ensure you've already stored it securely.
-`--description TEXT` / `-d TEXT`: **Required**. Description for the token (e.g., "API access for service X")
143
143
-`--expires-days INTEGER` / `-e INTEGER`: **Optional**. Number of days until token expires. If not specified, token never expires.
144
+
-`--format [text|json]`: **Optional**. Output format. `text` (default) is human-readable; `json` is machine-readable and recommended for CI or scripting.
145
+
-`--token TEXT`: **Optional**. Use a pre-generated token value instead of having the CLI generate one. The CLI will hash and store the provided token; make sure you've stored the plaintext securely in your secrets manager or CI system.
Lists all authentication tokens, showing masked token hashes, descriptions, and expiration dates.
160
168
161
169
```bash
162
-
agent-memory token list
170
+
agent-memory token list [--format text|json]
171
+
```
172
+
173
+
When `--format json` is used, the command prints a JSON array of token summaries suitable for scripting and CI pipelines. The default `text` format produces human-readable output like the example below.
174
+
**JSON Output Example:**
175
+
```json
176
+
[
177
+
{
178
+
"hash": "abc12345def67890xyz",
179
+
"description": "API access token",
180
+
"created_at": "2025-07-10T18:30:00.000000+00:00",
181
+
"expires_at": "2025-08-09T18:30:00.000000+00:00",
182
+
"status": "Active"
183
+
},
184
+
{
185
+
"hash": "def09876uvw54321...",
186
+
"description": "Service account token",
187
+
"created_at": "2025-07-10T19:00:00.000000+00:00",
188
+
"expires_at": null,
189
+
"status": "Never Expires"
190
+
}
191
+
]
163
192
```
164
193
165
194
**Example Output:**
@@ -183,7 +212,19 @@ Expires: Never
183
212
Shows detailed information about a specific token. Supports partial hash matching for convenience.
184
213
185
214
```bash
186
-
agent-memory token show TOKEN_HASH
215
+
agent-memory token show TOKEN_HASH [--format text|json]
216
+
```
217
+
218
+
When `--format json` is used, the command prints a JSON object with token details (including status) suitable for scripting and CI pipelines. The default `text` format produces human-readable output.
0 commit comments