Skip to content

ApiKeyRecord

Namespace AgentPrism · Assembly AgentPrism.Abstractions.dll

An API key’s database-stored view, which CARRIES no raw VALUE.

public sealed record ApiKeyRecord : IEquatable<ApiKeyRecord>

objectApiKeyRecord

IEquatable<ApiKeyRecord>

object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

This record has no raw key. Only an irreversible SHA-256 digest sits in the database (nowhere but ApiKeyRecord.KeyPrefix); the raw value is returned once, only at creation time, via ApiKeyCreationResult.PlaintextKey.

public ApiKeyRecord()

The creation time (UTC).

public required DateTimeOffset CreatedAt { get; init; }

DateTimeOffset

The expiration. Never expires if null.

public DateTimeOffset? ExpiresAt { get; init; }

DateTimeOffset?

The key identifier.

public required Guid Id { get; init; }

Guid

true if the key is not revoked and has not expired.

public bool IsActive { get; }

bool

For DISPLAY ONLY (the UI list, GET /api/api-keys). The actual authentication decision is made in ApiKeyAuthenticator with an injected TimeProvider; using DateTimeOffset.UtcNow here is not a security decision and does not affect testability.

The raw value’s first characters; used to distinguish the key in a list.

public required string KeyPrefix { get; init; }

string

The last-used time. Used to spot an unused key.

public DateTimeOffset? LastUsedAt { get; init; }

DateTimeOffset?

The name for the operator to recognize the key by.

public required string Name { get; init; }

string

The revocation timestamp. The row is not DELETED; the audit trail is preserved through this field.

public DateTimeOffset? RevokedAt { get; init; }

DateTimeOffset?

The scope set. The effective authority is role ∩ scope.

public required IReadOnlyList<ApiKeyScope> Scopes { get; init; }

IReadOnlyList<ApiKeyScope>

The tenant the key is bound to. On authentication, the tenant is resolved FROM HERE.

public required string TenantId { get; init; }

string

public override bool Equals(object? obj)

obj object?

bool

public bool Equals(ApiKeyRecord? other)

other ApiKeyRecord?

bool

public override int GetHashCode()

int

public override string ToString()

string

operator ==(ApiKeyRecord?, ApiKeyRecord?)

Section titled “ operator ==(ApiKeyRecord?, ApiKeyRecord?)”
public static bool operator ==(ApiKeyRecord? left, ApiKeyRecord? right)

left ApiKeyRecord?

right ApiKeyRecord?

bool

operator !=(ApiKeyRecord?, ApiKeyRecord?)

Section titled “ operator !=(ApiKeyRecord?, ApiKeyRecord?)”
public static bool operator !=(ApiKeyRecord? left, ApiKeyRecord? right)

left ApiKeyRecord?

right ApiKeyRecord?

bool