nextmail keys
Every command in this namespace, with its arguments, flags and examples.
Commands
Every key in the workspace: list them, read their request log and activity, create, change, switch off, rotate, revoke and delete them, never wider than the calling key, and rotate the calling key's own secret. workspaceId reaches the keys of another workspace the account owns. Changes take an API key that holds keys:manage, so an OAuth access token is refused them with 403 api_key_only.
Every command here also takes the global flags, such as --json, --profile and --dry-run. See the global flags
nextmail keys list
List one page of the workspace's API keys
lsUsage
nextmail keys list [flags]
Returns one page of the workspace's keys, newest first, with what the Settings, API keys page shows: status, scopes, role, send scope, when each was last used, how often, and who made and last changed it. Revoked and expired keys stay listed until somebody deletes them. No secret is ever returned; maskedKey is enough to tell two keys apart.
A key narrowed to some domains or addresses only sees the keys whose send scope sits inside its own, so any other is a 404 rather than a refusal. Over OAuth only the workspace owner reaches it, and a member's token is 403 owner_only.
--workspace-id lists the keys of another workspace the account owns, for an API key with no role and no address or domain limit. An OAuth access token that names one is 403 api_key_only.
Add --all to walk every page: a table on a terminal, one JSON object per line when piped or with --ndjson, and one { items, hasMore, nextCursor } document with --json. --max <n> stops after that many items.
Flags
--limit <n>Rows per page, a whole number from 1 to 100. The server defaults to 25.
Default25--cursor <value>The
nextCursorfrom the previous page, passed back unchanged. Never build one yourself.--q <value>Narrows to keys whose name, masked key, id, scopes, or one of the addresses, domains and IP addresses they are limited to matches, up to 200 characters. Every word has to appear in one of them, ignoring case and accents, and when nothing matches exactly the search allows for a typo instead.
--workspace-id <value>Another workspace whose keys to reach, by the id
workspaces.listreturns, such as oneworkspaces.createjust made. The account the key acts for has to own it, and the calling key needs no role and no address or domain limit, or the call is 403beyond_caller_authority. Any other workspace is a 404. Left out, the calling key's own workspace.--allFetch every page and stream the items as they arrive.
--max <n>Stop after this many items. Implies
--all.--ndjsonPrint every item as one JSON object per line. Implies
--all
Examples
nextmail keys listnextmail keys list --all --max 100nextmail keys list --all > keys.ndjsonAlso available in
- API
GET /keys- TypeScript
keys.list()- Python
keys.list()- Ruby
keys.list- PHP
keys->list- Go
Keys.List- Java
keys().list- C#
Keys.ListAsync
nextmail keys get
Read one API key, without its secret
showviewUsage
nextmail keys get <id> [flags]
Resolves with one key as list shows it. A key narrowed to some domains or addresses only sees the keys whose send scope sits inside its own, so any other is a 404 rather than a refusal. Over OAuth only the workspace owner reaches it, and a member's token is 403 owner_only.
nextmail.me.get() describes the calling key itself and needs no scope; this reads any key the caller can see. --workspace-id reads a key of another workspace the account owns.
Arguments
<id>RequiredKey id, the 24 hex characters after
nm_live_.
Flags
--workspace-id <value>Another workspace whose keys to reach, by the id
workspaces.listreturns, such as oneworkspaces.createjust made. The account the key acts for has to own it, and the calling key needs no role and no address or domain limit, or the call is 403beyond_caller_authority. Any other workspace is a 404. Left out, the calling key's own workspace.
Examples
nextmail keys get 4c1b257a66287fd113bd89d0nextmail keys get 4c1b257a66287fd113bd89d0 --jsonAlso available in
- API
GET /keys/{id}- TypeScript
keys.get()- Python
keys.get()- Ruby
keys.get- PHP
keys->get- Go
Keys.Get- Java
keys().get- C#
Keys.GetAsync
nextmail keys create
Mint a new API key and receive its secret once
newaddUsage
nextmail keys create --name <value> [flags] nextmail keys create --data <json|@file|-> [flags]
Creates a key and resolves with it plus token, the whole secret. That is the only time it appears, so store it before doing anything else.
Left out, scopes is ['emails:send'], the role is the caller's own or none, the send scope is the caller's own or none (none means every address the workspace owns), the IP allowlist is the caller's own or none, and the expiry is the caller's own or none. The key gets the caller's mode. The workspace cap on live keys applies, as a 422 workspace_limit_reached.
It takes an API key that holds keys:manage, and the new key never reaches further than the calling key: anything wider is 403 beyond_caller_authority, and param names the axis. An OAuth access token is refused with 403 api_key_only, because no app is ever given keys:manage.
--workspace-id creates the key in another workspace the account owns, which is how a program that has just made a workspace with workspaces.create gives it a key of its own.
Pass --idempotency-key to make a retry safe. A retry with the same key and the same body resolves with the key the first call made and replayed: true, and mints nothing. The secret is never shown again, so token is null on a replay: rotate the key if the first answer was lost. The same key with a different body is a 422 idempotency_key_reuse.
Flags
--name <value>A name, 1 to 60 characters. Required, here or in
--data.--scopes <a,b>RepeatableThe scopes the key holds, at least one, each held by the caller. Defaults to
['emails:send'].Default["emails:send"]--role-id <value>A role to cap the key. Left out, the caller's own role. A caller with a role can only give its own, and
nullis refused for it.--address-allowlist <a,b>RepeatableSingle addresses the key may send as, at most 50, each owned by the workspace.
--domain-allowlist <a,b>RepeatableWhole domains the key may send as, at most 25, including addresses added to them later. Leave both lists out to inherit the caller's own; send both empty for none.
--expires-in-minutes <n>Minutes until the key expires, 5 to 5,256,000 (ten years). Left out, the caller's own expiry.
--ip-allowlist <a,b>RepeatableUp to 50 IP addresses and ranges the key works from, such as
203.0.113.7,198.51.100.0/24or2001:db8::/32. A call or an SMTP sign-in from anywhere else is refused with 403ip_not_allowed. Left out, the caller's own list, or none. A caller with a list can only give a list inside it.--workspace-id <value>Creates the key in another workspace the account owns, by the id
workspaces.listreturns, such as oneworkspaces.createjust made. The calling key needs no role and no address or domain limit, or the call is 403beyond_caller_authority, and any other workspace is a 404.--role-idthen names a role of that workspace. Left out, the calling key's own workspace.--idempotency-key <value>Makes a retry safe: the same key with the same body resolves with the key the first call made,
replayed: trueandtoken: null, instead of minting another. 1 to 255 letters, digits,_,.,:or-, and the same key with a different body is a 422idempotency_key_reuse.--data <json|@file|->The whole
bodyas JSON, inline, from a file with @path, or - for standard input. Flags override its keys.
Examples
nextmail keys create --name 'Acme Support'nextmail keys create --name 'Acme Support' --scopes emails:send,emails:read --idempotency-key signup-4192nextmail keys create --data @key.jsonAlso available in
- API
POST /keys- TypeScript
keys.create()- Python
keys.create()- Ruby
keys.create- PHP
keys->create- Go
Keys.Create- Java
keys().create- C#
Keys.CreateAsync
nextmail keys update
Rename a key, change its scopes or send scope, or switch it off and on
editUsage
nextmail keys update <id> [flags]
Applies a partial change and resolves with the key as it now stands. scopes, --address-allowlist and --domain-allowlist REPLACE what the key had, and a field left out stays as it was. enabled: false switches the key off: every call with it is refused with inactive_api_key and it keeps its secret, scopes, role and send scope, so enabled: true restores it exactly. That is the reversible alternative to revoke. A revoked key cannot be changed, and answers 409 revoked.
It takes an API key that holds keys:manage, and an OAuth access token is refused with 403 api_key_only, because no app is ever given keys:manage. A key may rename itself, switch itself off and change its own scopes and send scope within what it holds, but never its own IP allowlist. Any other key has to sit inside the calling key before the change and after it, or the call is 403 beyond_caller_authority. --workspace-id reaches a key of another workspace the account owns.
Arguments
<id>RequiredKey id, the 24 hex characters after
nm_live_.
Flags
--name <value>A new name, 1 to 60 characters.
--scopes <a,b>RepeatableThe whole new list of scopes, at least one.
--address-allowlist <a,b>RepeatableThe whole new list of single addresses.
--domain-allowlist <a,b>RepeatableThe whole new list of whole domains.
--enabledFalse switches the key off, true switches it back on.
--ip-allowlist <a,b>RepeatableThe whole new list of IP addresses and ranges the key works from, at most 50. An empty list lets it work from anywhere again. A key cannot change its own list, and a caller with a list can only set one inside it.
--workspace-id <value>Another workspace whose keys to reach, by the id
workspaces.listreturns, such as oneworkspaces.createjust made. The account the key acts for has to own it, and the calling key needs no role and no address or domain limit, or the call is 403beyond_caller_authority. Any other workspace is a 404. Left out, the calling key's own workspace.--data <json|@file|->The whole
patchas JSON, inline, from a file with @path, or - for standard input. Flags override its keys.
Examples
nextmail keys update 4c1b257a66287fd113bd89d0 --name 'Billing sender (paused)' --no-enablednextmail keys update 4c1b257a66287fd113bd89d0 --name 'Billing sender (paused)' --no-enabled --jsonAlso available in
- API
PATCH /keys/{id}- TypeScript
keys.update()- Python
keys.update()- Ruby
keys.update- PHP
keys->update- Go
Keys.Update- Java
keys().update- C#
Keys.UpdateAsync
nextmail keys delete
Remove a revoked key from the list
rmdelremoveUsage
nextmail keys delete <id> [flags]
Deletes a key that has already been revoked. Its request log and activity stay, under Deleted key, so the history of what it did is not lost with it. A key that has not been revoked is refused with 409 not_revoked, so nothing still calling with it loses its credential without somebody deciding that first.
It takes an API key that holds keys:manage, and deletes only a key that sits inside the calling key. An OAuth access token is refused with 403 api_key_only, because no app is ever given keys:manage. --workspace-id reaches a key of another workspace the account owns.
Arguments
<id>RequiredKey id, the 24 hex characters after
nm_live_.
Flags
--workspace-id <value>Another workspace whose keys to reach, by the id
workspaces.listreturns, such as oneworkspaces.createjust made. The account the key acts for has to own it, and the calling key needs no role and no address or domain limit, or the call is 403beyond_caller_authority. Any other workspace is a 404. Left out, the calling key's own workspace.
Examples
nextmail keys delete 4c1b257a66287fd113bd89d0nextmail keys delete 4c1b257a66287fd113bd89d0 --yesAlso available in
- API
DELETE /keys/{id}- TypeScript
keys.delete()- Python
keys.delete()- Ruby
keys.delete- PHP
keys->delete- Go
Keys.Delete- Java
keys().delete- C#
Keys.DeleteAsync
nextmail keys rotate
Give a key a new secret and receive it once
Usage
nextmail keys rotate <id> [flags]
Mints a new secret for a key and resolves with the key plus token, rotationCount and rotatedAt. The id, name, scopes, role, send scope, expiry and request history all carry on; only the secret and keyLast4 change. There is no overlap window: the old secret stops working the instant this returns.
An API key rotates itself with keys:write or keys:manage, as nextmail.me.rotate() does, and any other key that sits inside it with keys:manage. An OAuth access token is refused with 403 api_key_only, because no app is ever given keys:write or keys:manage. --workspace-id reaches a key of another workspace the account owns. A revoked or expired key cannot be rotated, and answers 409 revoked or expired.
Arguments
<id>RequiredKey id, the 24 hex characters after
nm_live_.
Flags
--workspace-id <value>Another workspace whose keys to reach, by the id
workspaces.listreturns, such as oneworkspaces.createjust made. The account the key acts for has to own it, and the calling key needs no role and no address or domain limit, or the call is 403beyond_caller_authority. Any other workspace is a 404. Left out, the calling key's own workspace.
Examples
nextmail keys rotate 4c1b257a66287fd113bd89d0nextmail keys rotate 4c1b257a66287fd113bd89d0 --yesAlso available in
- API
POST /keys/{id}/rotate- TypeScript
keys.rotate()- Python
keys.rotate()- Ruby
keys.rotate- PHP
keys->rotate- Go
Keys.Rotate- Java
keys().rotate- C#
Keys.RotateAsync
nextmail keys revoke
Revoke a key for good
Usage
nextmail keys revoke <id> [flags]
Revokes a key: every later call with it is refused with revoked_api_key, and it can never be switched back on, rotated or changed. reason is kept on the key and in the activity log. Revoking a key that is already revoked changes nothing and resolves with it as it is. A key may revoke itself, which is how an integration that believes its secret leaked retires it at once.
A key never reaches a key wider than itself. A key it revokes has to sit inside it on every axis: scopes the caller holds after its own role has narrowed them, the same role when the caller has one, an expiry no later than the caller's when the caller expires, the caller's mode, an IP allowlist inside the caller's own when it has one, and a send scope inside the caller's own, where one address never covers its whole domain. Anything wider is 403 beyond_caller_authority, and param names the axis.
A key narrowed to some domains or addresses only sees the keys whose send scope sits inside its own, so any other is a 404 rather than a refusal. An OAuth access token is refused with 403 api_key_only, because no app is ever given keys:manage. --workspace-id reaches a key of another workspace the account owns.
Arguments
<id>RequiredKey id, the 24 hex characters after
nm_live_.
Flags
--reason <value>Why, at most 200 characters.
--workspace-id <value>Another workspace whose keys to reach, by the id
workspaces.listreturns, such as oneworkspaces.createjust made. The account the key acts for has to own it, and the calling key needs no role and no address or domain limit, or the call is 403beyond_caller_authority. Any other workspace is a 404. Left out, the calling key's own workspace.--data <json|@file|->The whole
bodyas JSON, inline, from a file with @path, or - for standard input. Flags override its keys.
Examples
nextmail keys revoke 4c1b257a66287fd113bd89d0nextmail keys revoke 4c1b257a66287fd113bd89d0 --reason 'Contractor offboarded'nextmail keys revoke 4c1b257a66287fd113bd89d0 --yesAlso available in
- API
POST /keys/{id}/revoke- TypeScript
keys.revoke()- Python
keys.revoke()- Ruby
keys.revoke- PHP
keys->revoke- Go
Keys.Revoke- Java
keys().revoke- C#
Keys.RevokeAsync
nextmail keys list-requests
List one page of one key's request log
Usage
nextmail keys list-requests <id> [flags]
Returns one page of the calls one key made, newest first, the Requests tab of the key in the app. The request log records every authenticated call a key made: method, path, status, error code, duration, IP and user agent, and never a body or a query string. A call refused before a key could be identified is not in it, and neither is a call made with an OAuth access token. Nothing is pruned, so the log reaches back to a key's first call. --failed-only, statuses, path, since and until narrow it, and they combine.
A deleted key's log stays readable to a key that is not narrowed. A key narrowed to some domains or addresses only sees the keys whose send scope sits inside its own, so any other is a 404 rather than a refusal. Over OAuth only the workspace owner reaches it, and a member's token is 403 owner_only.
Add --all to walk every page: a table on a terminal, one JSON object per line when piped or with --ndjson, and one { items, hasMore, nextCursor } document with --json. --max <n> stops after that many items.
Arguments
<id>RequiredKey id, the 24 hex characters after
nm_live_.
Flags
--failed-onlyOnly calls answered with a status of 400 or more.
Defaultfalse--statuses <n,n>RepeatableOnly calls answered with one of these HTTP status codes, such as
[401, 403]. At most 20, each from 100 to 599, sent comma-separated asstatus.--path <value>Only calls to this route, whatever the method, such as
/emailsor/emails/:id. It matches the route, not the exact path: an id counts as:idand an email address as:address. End it with*to read every route that starts with it, such as/emails/*.--since <when>Only rows at or after this instant. A
Dateis sent as ISO 8601, and a string must already be one.--until <when>Only rows before this instant. It has to be later than
since, or the server answers 400invalid_parameter.--limit <n>Rows per page, a whole number from 1 to 100. The server defaults to 25.
Default25--cursor <value>The
nextCursorfrom the previous page, passed back unchanged. Never build one yourself.--allFetch every page and stream the items as they arrive.
--max <n>Stop after this many items. Implies
--all.--ndjsonPrint every item as one JSON object per line. Implies
--all
Examples
nextmail keys list-requests 4c1b257a66287fd113bd89d0nextmail keys list-requests 4c1b257a66287fd113bd89d0 --failed-only --limit 50nextmail keys list-requests 4c1b257a66287fd113bd89d0 --all --max 100nextmail keys list-requests 4c1b257a66287fd113bd89d0 --all > keys.ndjsonAlso available in
nextmail keys list-activity
List one page of what happened to one key
Usage
nextmail keys list-activity <id> [flags]
Returns one page of one key's audit log, newest first, the Activity tab of the key in the app. Every change to a key is a row: created, updated, rotated, deactivated, reactivated, revoked and deleted, plus auth_failed for every call that presented the key and was refused. actor names who made the change, a person as @username or a key as API key <name> in label, and detail.source says where it came from: console, api, mcp or documentation.
A deleted key keeps its history, readable to a key that is not narrowed. A key narrowed to some domains or addresses only sees the keys whose send scope sits inside its own, so any other is a 404 rather than a refusal. Over OAuth only the workspace owner reaches it, and a member's token is 403 owner_only.
Add --all to walk every page: a table on a terminal, one JSON object per line when piped or with --ndjson, and one { items, hasMore, nextCursor } document with --json. --max <n> stops after that many items.
Arguments
<id>RequiredKey id, the 24 hex characters after
nm_live_.
Flags
--since <when>Only rows at or after this instant. A
Dateis sent as ISO 8601, and a string must already be one.--until <when>Only rows before this instant. It has to be later than
since, or the server answers 400invalid_parameter.--limit <n>Rows per page, a whole number from 1 to 100. The server defaults to 25.
Default25--cursor <value>The
nextCursorfrom the previous page, passed back unchanged. Never build one yourself.--allFetch every page and stream the items as they arrive.
--max <n>Stop after this many items. Implies
--all.--ndjsonPrint every item as one JSON object per line. Implies
--all
Examples
nextmail keys list-activity 4c1b257a66287fd113bd89d0nextmail keys list-activity 4c1b257a66287fd113bd89d0 --all --max 100nextmail keys list-activity 4c1b257a66287fd113bd89d0 --all > keys.ndjsonAlso available in
nextmail keys list-workspace-requests
List one page of the request log of every key
Usage
nextmail keys list-workspace-requests [flags]
Returns one page of every call the workspace's keys made, newest first, the Requests tab of Settings, API keys. The request log records every authenticated call a key made: method, path, status, error code, duration, IP and user agent, and never a body or a query string. A call refused before a key could be identified is not in it, and neither is a call made with an OAuth access token. Nothing is pruned, so the log reaches back to a key's first call. --key-ids, --failed-only, statuses, path, since and until narrow it, and they combine. --key-ids may name a deleted key.
A narrowed key reads only the log of the keys it can see, so naming another key in --key-ids matches nothing.
Add --all to walk every page: a table on a terminal, one JSON object per line when piped or with --ndjson, and one { items, hasMore, nextCursor } document with --json. --max <n> stops after that many items.
Flags
--key-ids <a,b>RepeatableKey ids to read, at most 50, sent comma-separated. Left out, every key the caller can see.
--failed-onlyOnly calls answered with a status of 400 or more.
Defaultfalse--statuses <n,n>RepeatableOnly calls answered with one of these HTTP status codes, such as
[401, 403]. At most 20, each from 100 to 599, sent comma-separated asstatus.--path <value>Only calls to this route, whatever the method, such as
/emailsor/emails/:id. It matches the route, not the exact path: an id counts as:idand an email address as:address. End it with*to read every route that starts with it, such as/emails/*.--since <when>Only rows at or after this instant. A
Dateis sent as ISO 8601, and a string must already be one.--until <when>Only rows before this instant. It has to be later than
since, or the server answers 400invalid_parameter.--limit <n>Rows per page, a whole number from 1 to 100. The server defaults to 25.
Default25--cursor <value>The
nextCursorfrom the previous page, passed back unchanged. Never build one yourself.--allFetch every page and stream the items as they arrive.
--max <n>Stop after this many items. Implies
--all.--ndjsonPrint every item as one JSON object per line. Implies
--all
Examples
nextmail keys list-workspace-requestsnextmail keys list-workspace-requests --failed-only --since 2026-09-22T00:00:00Znextmail keys list-workspace-requests --all --max 100nextmail keys list-workspace-requests --all > keys.ndjsonAlso available in
nextmail keys list-workspace-activity
List one page of what happened to every key
Usage
nextmail keys list-workspace-activity [flags]
Returns one page of the audit log of every key in the workspace, newest first, the Activity tab of Settings, API keys. Every change to a key is a row: created, updated, rotated, deactivated, reactivated, revoked and deleted, plus auth_failed for every call that presented the key and was refused. actor names who made the change, a person as @username or a key as API key <name> in label, and detail.source says where it came from: console, api, mcp or documentation.
--key-ids narrows it, deleted keys included, and since and until keep a window. A narrowed key reads only the activity of the keys it can see.
Add --all to walk every page: a table on a terminal, one JSON object per line when piped or with --ndjson, and one { items, hasMore, nextCursor } document with --json. --max <n> stops after that many items.
Flags
--key-ids <a,b>RepeatableKey ids to read, at most 50, sent comma-separated. Left out, every key the caller can see.
--since <when>Only rows at or after this instant. A
Dateis sent as ISO 8601, and a string must already be one.--until <when>Only rows before this instant. It has to be later than
since, or the server answers 400invalid_parameter.--limit <n>Rows per page, a whole number from 1 to 100. The server defaults to 25.
Default25--cursor <value>The
nextCursorfrom the previous page, passed back unchanged. Never build one yourself.--allFetch every page and stream the items as they arrive.
--max <n>Stop after this many items. Implies
--all.--ndjsonPrint every item as one JSON object per line. Implies
--all
Examples
nextmail keys list-workspace-activitynextmail keys list-workspace-activity --since 2026-09-01T00:00:00Znextmail keys list-workspace-activity --all --max 100nextmail keys list-workspace-activity --all > keys.ndjsonAlso available in
nextmail keys stats
Read what the keys did inside a window
Usage
nextmail keys stats [flags]
Returns the numbers behind the Analytics tab of the API keys page: the mail the keys sent and what became of it, the calls refused because a secret was wrong, revoked or expired, the requests they made and how many failed, the routes they called most with the median time each took, and the status codes they got back.
It covers every key you can see, or the ones --key-ids names. The window runs from since to until, and left out it is the 30 days before now. grain sets the bucket width of the series and --offset-minutes shifts the boundaries so days break where the reader's day does.
Flags
--key-ids <a,b>RepeatableOnly these keys, at most 50. Left out, every key you can see.
--since <when>The start of the window, a
Dateor an ISO 8601 instant. Defaults to 30 days beforeuntil.--until <when>The end of the window, not included. Defaults to now.
--grain <value>Bucket width:
minute,hourorday, defaulting today.Default"day"--offset-minutes <n>Minutes east of UTC to bucket in, from -840 to 840, defaulting to 0.
Default0
Examples
nextmail keys statsnextmail keys stats --grain daynextmail keys stats --jsonAlso available in
- API
GET /keys/stats- TypeScript
keys.stats()- Python
keys.stats()- Ruby
keys.stats- PHP
keys->stats- Go
Keys.Stats- Java
keys().stats- C#
Keys.StatsAsync