Update an API key - Spacefast Docs
Update an API key
Updates the key’s name, metadata, activation and expiry instants, IP allowlist, or its scope and permissions, and returns the updated key. scope and permissions change together, and must stay on the key’s existing owning team and collection. A key cannot change its own permissions, validity window, or IP allowlist, and a key minted by device login cannot change any of them. Secrets are fixed at creation; create a new key instead.
PATCH /v1/api-keys/{apiKeyId}
Authorization
Authorization: Bearer <token>
with an API key (sfa_ prefix), an OAuth access token, a session token, or a Space machine credential (sfm_ prefix).
- or -
Authorization: OAuth2 access token
OAuth 2.0 with Spacefast scopes. People use the authorization code flow; machines use client credentials.
Scopes: teams:create
Path parameters
apiKeyIdstring required
min length 1
Request body
required application/json
expiresAtstring| any
Expiry to set, as an ISO 8601 timestamp. Null makes the key never expire.ipAllowliststring[] | any
Replaces the addresses the key may be used from. Null allows any address.metadataobject
Replaces the metadata stored with the key.namestring | any
Name to set on the key. Null clears it.notBeforestring| any
Activation instant to set, as an ISO 8601 timestamp. Null makes the key usable immediately.permissionsstring[]
Action set to replace the key's permissions with. Send it together withscope. min items 1 · max items 64scopeobject
Target to recompile the key's policy against. Send it together withpermissions, and it must resolve to the key's existing owning team and collection.
Responses
200 Response for status 200
$schemastring
Canonical JSON Schema URL for this response body. The server also sends it in theLink: rel="describedby"response header.dataobject requiredcollectionstring required
teamfor a key acting on the owning team's own resources,partnerfor a key acting on customer resources that team manages. Allowed:teampartnercreatedAtstringrequired
ISO 8601 timestamp when the key was created.createdByUserIdstring required
User account that created the key.enabledboolean required
False once the key is revoked, which stops it authenticating.expiresAtstring| any required
ISO 8601 timestamp from which requests presenting the key are rejected. Null when it does not expire.idstring required
API key ID (key_prefix).ipAllowliststring[] | any required
Exact IP addresses and IPv4 CIDR ranges the key may be used from. Null when any address is allowed.lastRequestAtstring| any required
ISO 8601 timestamp of the most recent request made with the key. Null until it is used.metadataobject required
Metadata stored with the key when it was created or last updated.namestring | any required
Name given to the key. Null when it was created without one.notBeforestring| any required
ISO 8601 timestamp before which requests presenting the key are rejected. Null when it works from creation.ownerPrincipalobject | any required
Principal that owns the key. Ownership only: what the key may do comes frompolicy. Null on platform-owned keys.policyobject | any required
Policy the key authorizes by. Null on a device login key, whose authority is recompiled from the holder's live team roles on every request.presetstring | any required
Named permission bundle the key is labeled with. Null when it was created from an explicit policy or permission list.revokedAtstring| any required
ISO 8601 timestamp when the key was revoked. Null while it is still usable.secretPreviewstring required
Masked form of the secret: its first eight characters and its last four, joined by three dots.subjectobject | any required
What the key acts as in audit records.teamScopeobject | any required
Teams a device login key follows the holder's membership in. Null on a key that authorizes by a fixedpolicy.updatedAtstringrequired
ISO 8601 timestamp of the last change to the key.