Class ApiKeyEntity
Default MongoDB entity for API keys.
public record ApiKeyEntity : EntityBase, ISupportInitialize, IEquatable<PersistableEntityBase>, IEntity<ObjectId>, IEquatable<EntityBase<ObjectId>>, IEquatable<EntityBase>, IApiKey, IEquatable<ApiKeyEntity>
- Inheritance
-
PersistableEntityBaseEntityBase<ObjectId>EntityBaseApiKeyEntity
- Implements
-
IEquatable<PersistableEntityBase>IEntity<ObjectId>IEquatable<EntityBase>
- Inherited Members
-
EntityBase.ToString()EntityBase.GetHashCode()EntityBase.Equals(EntityBase<ObjectId>)EntityBase.Equals(EntityBase)EntityBase.<Clone>$()EntityBase.EqualityContractEntityBase<ObjectId>.Equals(PersistableEntityBase)EntityBase<ObjectId>.IdPersistableEntityBase.NeedsCleaning()PersistableEntityBase.BeginInit()PersistableEntityBase.EndInit()PersistableEntityBase.CatchAll
Properties
AccessLevel
Access level for this API key. Null defaults to Administrator.
[BsonIgnoreIfNull]
[BsonRepresentation(BsonType.String)]
public AccessLevel? AccessLevel { get; init; }
Property Value
ApiKey
The raw API key value (only populated on creation; otherwise empty).
[BsonIgnoreIfDefault]
public string ApiKey { get; init; }
Property Value
ApiKeyHash
Hashed value of the API key used for verification.
public required string ApiKeyHash { get; init; }
Property Value
ApiKeyPrefix
Indexed lookup value, so authenticating a key verifies one candidate. The first 16 bytes of the key's SHA-256 as hex. An older key holds the first 8 characters of the raw key, a prefix every key of its team shares, until its first use replaces them.
[BsonIgnoreIfNull]
public string ApiKeyPrefix { get; init; }
Property Value
CreatedAt
When this key was created.
[BsonIgnoreIfNull]
public DateTime? CreatedAt { get; init; }
Property Value
CreatedBy
User who created this key (identity/display name). Null if not recorded.
[BsonIgnoreIfNull]
public string CreatedBy { get; init; }
Property Value
DisabledAt
When this key was disabled. Null means enabled.
[BsonIgnoreIfNull]
public DateTime? DisabledAt { get; init; }
Property Value
DisabledBy
Who disabled this key. Null means enabled.
[BsonIgnoreIfNull]
public string DisabledBy { get; init; }
Property Value
ExpiryDate
Expiry date. Null means no expiry.
[BsonIgnoreIfNull]
public DateTime? ExpiryDate { get; init; }
Property Value
Key
Unique identifier for this API key entry.
public required string Key { get; init; }
Property Value
LastUsedAt
When this key was last used to authenticate. Null if never used.
[BsonIgnoreIfNull]
public DateTime? LastUsedAt { get; init; }
Property Value
Name
Human-readable name for this API key.
public required string Name { get; init; }
Property Value
OwnerMemberKey
Owner of an owner-scoped ("private", shown as "Personal") key, or null for a shared key. On a team key this is the owning team member (Key); on a system key it is the owning user's key — the same value, since a member key is the user key. Private keys are hidden from others in the UI and can only be recycled/locked/disabled/deleted by their owner (a caller holding the Oversee system scope may still manage them, for audit).
[BsonIgnoreIfNull]
public string OwnerMemberKey { get; init; }
Property Value
Roles
Tenant roles assigned to this API key.
[BsonIgnoreIfNull]
public string[] Roles { get; init; }
Property Value
- string[]
ScopeOverrides
Individual scope overrides (additional scopes beyond AccessLevel and roles).
[BsonIgnoreIfNull]
public string[] ScopeOverrides { get; init; }
Property Value
- string[]
SystemScopes
Explicit scopes granted to a system key at creation time. Null/empty for team keys.
[BsonIgnoreIfNull]
public string[] SystemScopes { get; init; }
Property Value
- string[]
Tags
System-set key-value tags on this API key. A list (not a map), so a key may repeat.
Set only at creation via the service; immutable thereafter and not editable from the UI.
Each tag is surfaced as a tag.{Key} claim on the authenticated principal.
[BsonIgnoreIfNull]
[BsonSerializer(typeof(TagListBsonSerializer))]
public IReadOnlyList<Tag> Tags { get; init; }
Property Value
TeamKey
Team that owns this API key. Null for system keys (not bound to a team).
[BsonIgnoreIfDefault]
public string TeamKey { get; init; }