Table of Contents

Class ApiKeyEntity

Namespace
Tharga.Team.Service
Assembly
Tharga.Team.Service.dll

Default MongoDB entity for API keys.

public record ApiKeyEntity : EntityBase, ISupportInitialize, IEquatable<PersistableEntityBase>, IEntity<ObjectId>, IEquatable<EntityBase<ObjectId>>, IEquatable<EntityBase>, IApiKey, IEquatable<ApiKeyEntity>
Inheritance
PersistableEntityBase
EntityBase<ObjectId>
EntityBase
ApiKeyEntity
Implements
IEquatable<PersistableEntityBase>
IEntity<ObjectId>
IEquatable<EntityBase<ObjectId>>
IEquatable<EntityBase>
Inherited Members
EntityBase.ToString()
EntityBase.GetHashCode()
EntityBase.Equals(EntityBase<ObjectId>)
EntityBase.Equals(EntityBase)
EntityBase.<Clone>$()
EntityBase.EqualityContract
EntityBase<ObjectId>.Equals(PersistableEntityBase)
EntityBase<ObjectId>.Id
PersistableEntityBase.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

AccessLevel?

ApiKey

The raw API key value (only populated on creation; otherwise empty).

[BsonIgnoreIfDefault]
public string ApiKey { get; init; }

Property Value

string

ApiKeyHash

Hashed value of the API key used for verification.

public required string ApiKeyHash { get; init; }

Property Value

string

ApiKeyPrefix

First 8 characters of the raw API key for indexed prefix lookup. Avoids full table scan.

[BsonIgnoreIfNull]
public string ApiKeyPrefix { get; init; }

Property Value

string

CreatedAt

When this key was created.

[BsonIgnoreIfNull]
public DateTime? CreatedAt { get; init; }

Property Value

DateTime?

CreatedBy

User who created this key (identity/display name). Null if not recorded.

[BsonIgnoreIfNull]
public string CreatedBy { get; init; }

Property Value

string

DisabledAt

When this key was disabled. Null means enabled.

[BsonIgnoreIfNull]
public DateTime? DisabledAt { get; init; }

Property Value

DateTime?

DisabledBy

Who disabled this key. Null means enabled.

[BsonIgnoreIfNull]
public string DisabledBy { get; init; }

Property Value

string

ExpiryDate

Expiry date. Null means no expiry.

[BsonIgnoreIfNull]
public DateTime? ExpiryDate { get; init; }

Property Value

DateTime?

Key

Unique identifier for this API key entry.

public required string Key { get; init; }

Property Value

string

LastUsedAt

When this key was last used to authenticate. Null if never used.

[BsonIgnoreIfNull]
public DateTime? LastUsedAt { get; init; }

Property Value

DateTime?

Name

Human-readable name for this API key.

public required string Name { get; init; }

Property Value

string

OwnerMemberKey

Owning team member (Key) for an owner-scoped ("private") key, or null for a normal team-wide key. Private keys are hidden from other members in the UI and can only be recycled/locked/deleted by their owner (a Developer-role caller may still manage them for audit).

[BsonIgnoreIfNull]
public string OwnerMemberKey { get; init; }

Property Value

string

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

IReadOnlyList<Tag>

TeamKey

Team that owns this API key. Null for system keys (not bound to a team).

[BsonIgnoreIfDefault]
public string TeamKey { get; init; }

Property Value

string