Create a fleet API key
const url = 'https://example.com/api/nss/keys';const options = { method: 'POST', headers: { 'X-Ssoossh-Key-Secret': '<X-Ssoossh-Key-Secret>', 'Content-Type': 'application/json' }, body: '{}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://example.com/api/nss/keys \ --header 'Content-Type: application/json' \ --header 'X-Ssoossh-Key-Secret: <X-Ssoossh-Key-Secret>' \ --data '{}'Fleet key admin role and admins only. Returns the key and its secret; the secret is shown this once and never again, so the caller must store it now. expires_at defaults to nss.key_max_lifetime from now, and a later one is trimmed to that; with the setting at 0 a key created without one never expires. Afterwards only a rotation renews it. notification_email defaults to the creator’s address.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”The new key
Responses
Section titled “Responses”The key and its secret
object
object
object
CreatedBy is the creator’s users.id, and CreatedByUsername their username, empty when the account is gone.
CurrentGeneration is 1 at creation and grows by one per rotation.
ExpiresAt is when the key stops being accepted, set at creation and renewed by each rotation; absent for a key that never expires.
GroupName is the group whose members manage this key, empty for none.
ID is “nss_” and 8 base32 characters, what hosts send as X-Ssoossh-Key-Id. Fixed for the key’s life.
KeySourceAlertAt is when the key source alert (nss.key_source_alert) last fired for the key: more source addresses in one day than the limit. Absent unless it fired in the last 7 days.
LastUsedAt is the last lookup any host made with the key, from the retained usage, so up to a minute behind; absent for a key no host has used.
MissRateAlertAt is when the miss rate alert (nss.miss_alert_rate) last fired for the key: many lookups for names the directory does not hold. Absent unless it fired in the last 7 days.
NotificationEmail is where the key’s mail goes, empty for nowhere.
Permissions is what the caller may do with this key, decided by the server so the UI never reimplements the role matrix. A revoked key carries view alone.
PreviousExpiresAt is when the previous secret stops being accepted, absent when there is no previous secret.
RevokedAt, RevokedBy (a users.id) and RevokedByUsername record a revocation, absent while the key is live.
RotatedAt is the last rotation, absent for a key never rotated.
Status is derived from the revocation and expiry.
Example
{ "data": { "key": { "permissions": [ "view" ], "status": "active" } }}Malformed body, a missing name, a past expiry or a bad address
object
Data is always null on an error response.
Error is a human-readable message. Branch on the HTTP status rather than this string; it is for humans and logs.
ErrorCode is a machine-readable error classifier. One of the error_code constants from internal/apitypes; use this to decide whether to retry or branch on the failure mode.
Example
{ "error": "certificate request \"9f1c…\" not found", "error_code": "not_found"}No valid session
object
Data is always null on an error response.
Error is a human-readable message. Branch on the HTTP status rather than this string; it is for humans and logs.
ErrorCode is a machine-readable error classifier. One of the error_code constants from internal/apitypes; use this to decide whether to retry or branch on the failure mode.
Example
{ "error": "certificate request \"9f1c…\" not found", "error_code": "not_found"}Not the fleet key admin role, or no user record
object
Data is always null on an error response.
Error is a human-readable message. Branch on the HTTP status rather than this string; it is for humans and logs.
ErrorCode is a machine-readable error classifier. One of the error_code constants from internal/apitypes; use this to decide whether to retry or branch on the failure mode.
Example
{ "error": "certificate request \"9f1c…\" not found", "error_code": "not_found"}Nss_disabled: nss.enabled is false
object
Data is always null on an error response.
Error is a human-readable message. Branch on the HTTP status rather than this string; it is for humans and logs.
ErrorCode is a machine-readable error classifier. One of the error_code constants from internal/apitypes; use this to decide whether to retry or branch on the failure mode.
Example
{ "error": "certificate request \"9f1c…\" not found", "error_code": "not_found"}