dsc api-key¶
Manage Discourse API keys (admin scope).
There's a chicken-and-egg here: you need an existing admin key in your dsc.toml to use any of these commands. Bootstrapping the very first key still has to happen via the Admin UI.
dsc api-key list¶
Lists all keys with their id, description, the user they act as (or (all-users) for global keys), the last-used timestamp, and whether they're active or revoked.
dsc api-key show¶
Shows one key via GET /admin/api/keys/:id.json: description, acting user, truncated key, timestamps, status, and any scopes. JSON/YAML output is the key object exactly as Discourse returns it. The secret is never returned.
dsc api-key create¶
Creates a new key. The secret value is only displayed at creation time — capture it from the output and store it somewhere safe (your dsc.toml, a password manager). Re-fetching the key later is impossible by design.
--username makes the key act as that specific user; omit for a global all-users key. Honours --dry-run (prints the intended action without creating the key).
dsc api-key create myforum "ops-runbook bot" --username system
dsc api-key create myforum "alice's read-only key" -u alice -f json
Scoped keys (e.g. write-only-to-topics) are not yet supported — those need to be created via the Admin UI for now.
dsc api-key revoke¶
Revokes the key by ID (soft: sets revoked_at, the key stops authenticating but the record is kept). Use dsc api-key list to find the ID. Honours --dry-run. Reversible with dsc api-key undo-revoke.
dsc api-key undo-revoke¶
Undoes a previous revoke, reactivating the key. Alias: unrevoke. Honours --dry-run.
dsc api-key delete¶
Permanently removes the key record via DELETE /admin/api/keys/:id.json - unlike revoke, this cannot be undone. Alias: rm. Honours --dry-run.
All three mutation commands return an object containing id and action under JSON/YAML output. Text remains the default.