Interface IApiKeyAdministrationService
Service for managing and validating API keys.
public interface IApiKeyAdministrationService
Methods
CreateKeyAsync(string, string, AccessLevel, string[], string[], DateTime?, IReadOnlyList<Tag>, string)
Creates a new API key with the specified settings (advanced mode). tags are system-set key-value tags, settable only here (not from the UI) and immutable thereafter. createdBy records who created the key; null for keys created without a user context (e.g. auto-generated), surfaced as "System" in the UI.
Task<IApiKey> CreateKeyAsync(string teamKey, string name, AccessLevel accessLevel, string[] roles = null, string[] scopeOverrides = null, DateTime? expiryDate = null, IReadOnlyList<Tag> tags = null, string createdBy = null)
Parameters
teamKeystringnamestringaccessLevelAccessLevelrolesstring[]scopeOverridesstring[]expiryDateDateTime?tagsIReadOnlyList<Tag>createdBystring
Returns
CreateSystemKeyAsync(string, string[], DateTime?, string)
Creates a new system-level API key with the specified explicit scope set.
Task<IApiKey> CreateSystemKeyAsync(string name, string[] scopes, DateTime? expiryDate = null, string createdBy = null)
Parameters
namestringHuman-readable name for the key.
scopesstring[]Explicit scopes granted to this key. Not resolved through AccessLevel/roles.
expiryDateDateTime?Optional expiry date.
createdBystringIdentity of the user creating the key (for audit).
Returns
DeleteKeyAsync(string, string)
Deletes an API key. Verifies team ownership.
Task DeleteKeyAsync(string teamKey, string key)
Parameters
Returns
DeleteSystemKeyAsync(string)
Deletes a system API key.
Task DeleteSystemKeyAsync(string key)
Parameters
keystring
Returns
GetByApiKeyAsync(string)
Looks up an API key by its raw value. Returns null if no match is found.
Task<IApiKey> GetByApiKeyAsync(string apiKey)
Parameters
apiKeystring
Returns
GetKeysAsync(string)
Returns all API keys for the specified team, creating default keys if fewer than AutoKeyCount exist.
IAsyncEnumerable<IApiKey> GetKeysAsync(string teamKey)
Parameters
teamKeystring
Returns
GetSystemKeysAsync()
Returns all system-level API keys (not bound to a team).
IAsyncEnumerable<IApiKey> GetSystemKeysAsync()
Returns
LockKeyAsync(string, string)
Locks an API key so it can no longer be used for authentication. Verifies team ownership.
Task LockKeyAsync(string teamKey, string key)
Parameters
Returns
LockSystemKeyAsync(string)
Locks a system API key so it can no longer authenticate.
Task LockSystemKeyAsync(string key)
Parameters
keystring
Returns
RefreshKeyAsync(string, string)
Generates a new API key value for an existing key entry. Returns the entity with the raw key visible once.
Task<IApiKey> RefreshKeyAsync(string teamKey, string key)
Parameters
Returns
RefreshSystemKeyAsync(string)
Regenerates a system key's raw value. Returns the entity with the raw key visible once.
Task<IApiKey> RefreshSystemKeyAsync(string key)
Parameters
keystring
Returns
SetRolesAsync(string, string, string[])
Sets the Roles (tenant roles) array on an existing team API key. Verifies team ownership.
Pass null or an empty array to clear all roles.
Task SetRolesAsync(string teamKey, string key, string[] roles)
Parameters
Returns
SetScopeOverridesAsync(string, string, string[])
Sets the ScopeOverrides array on an existing team API key. Verifies team ownership.
Pass null or an empty array to clear all overrides.
Task SetScopeOverridesAsync(string teamKey, string key, string[] scopes)