Skip to content

FlagsCore

Defined in: core.ts:214

The admin core surface.

Property Modifier Type Defined in
options readonly Required<Omit<FlagsCoreOptions, | "runtimeStorage" | "comparators" | "matchers" | "hooks" | "onHookError" | "retention">> & object core.ts:215
archiveFlag(
flagKey,
projectKey?,
environmentKey?
): Promise<Flag>;

Defined in: core.ts:252

Archive a flag: stamp Flag.archivedAt so it is excluded from the next compiled snapshot (leaves SDK payloads) while remaining in the draft for restore. Throws NotFoundError if the flag does not exist.

Parameter Type
flagKey string
projectKey? string
environmentKey? string

Promise<Flag>


createEnvironment(projectKey, input): Promise<EnvironmentMeta>;

Defined in: core.ts:236

Parameter Type
projectKey string
input { key: string; name?: string; }
input.key string
input.name? string

Promise<EnvironmentMeta>


createProject(input): Promise<ProjectMeta>;

Defined in: core.ts:231

Parameter Type
input { key: string; name?: string; }
input.key string
input.name? string

Promise<ProjectMeta>


deleteFlag(
flagKey,
projectKey?,
environmentKey?
): Promise<void>;

Defined in: core.ts:246

Parameter Type
flagKey string
projectKey? string
environmentKey? string

Promise<void>


deleteSegment(
segmentKey,
projectKey?,
environmentKey?
): Promise<void>;

Defined in: core.ts:264

Parameter Type
segmentKey string
projectKey? string
environmentKey? string

Promise<void>


deleteSnapshot(input): Promise<void>;

Defined in: core.ts:310

Delete a snapshot’s payload from both source and runtime storage. Guarded: the active and the latest versions throw SnapshotProtectedError (protecting the runtime, and preventing nextVersion from reusing a deleted version number). Appends an action: "delete" audit entry — the payload is removed, the fact remains. Vetoable via a before hook (snapshot.delete); the after event (snapshot.deleted) carries the full snapshot for offloading.

Parameter Type
input { by?: Actor | null; environmentKey?: string; projectKey?: string; version: string; }
input.by? Actor | null
input.environmentKey? string
input.projectKey? string
input.version string

Promise<void>


diffDraft(projectKey?, environmentKey?): Promise<DraftDiff>;

Defined in: core.ts:272

Field-level diff of the current draft (flags + segments) against the draft as it was at the last publish — i.e. the unpublished changes. changed is false when there is nothing to publish.

Parameter Type
projectKey? string
environmentKey? string

Promise<DraftDiff>


discardDraft(projectKey?, environmentKey?): Promise<Draft>;

Defined in: core.ts:274

Discard all unpublished changes: reset the draft to the last-published state.

Parameter Type
projectKey? string
environmentKey? string

Promise<Draft>


evaluate(input): Promise<FlagEvaluationResult[]>;

Defined in: core.ts:341

Evaluate flags against a context (test targeting) using the draft or active snapshot.

Parameter Type
input EvaluateInput

Promise<FlagEvaluationResult[]>

const results = await core.evaluate({
context: { targetingKey: "user-123", plan: "pro" },
source: "draft",
});
for (const r of results) {
console.log(r.key, r.value, r.reason);
}

getActiveSnapshot(projectKey?, environmentKey?): Promise<Snapshot | null>;

Defined in: core.ts:323

Parameter Type
projectKey? string
environmentKey? string

Promise<Snapshot | null>


getActiveVersion(projectKey?, environmentKey?): Promise<string | null>;

Defined in: core.ts:324

Parameter Type
projectKey? string
environmentKey? string

Promise<string | null>


getDraft(projectKey?, environmentKey?): Promise<Draft>;

Defined in: core.ts:242

Parameter Type
projectKey? string
environmentKey? string

Promise<Draft>


getFlag(
flagKey,
projectKey?,
environmentKey?
): Promise<Flag | null>;

Defined in: core.ts:244

Parameter Type
flagKey string
projectKey? string
environmentKey? string

Promise<Flag | null>


getProject(projectKey): Promise<
| ProjectMeta
| null>;

Defined in: core.ts:232

Parameter Type
projectKey string

Promise< | ProjectMeta | null>


getSegment(
segmentKey,
projectKey?,
environmentKey?
): Promise<Segment | null>;

Defined in: core.ts:258

Parameter Type
segmentKey string
projectKey? string
environmentKey? string

Promise<Segment | null>


getSnapshot(
version,
projectKey?,
environmentKey?
): Promise<Snapshot | null>;

Defined in: core.ts:318

Parameter Type
version string
projectKey? string
environmentKey? string

Promise<Snapshot | null>


importDraft(
input,
projectKey?,
environmentKey?
): Promise<Draft>;

Defined in: core.ts:281

Replace the draft from an imported document ({ flags, segments? }, e.g. a downloaded snapshot). Validates flags + segments (and references) before writing; throws DraftValidationError on invalid input. Does not publish — the caller reviews the resulting draft diff and publishes.

Parameter Type
input { flags: Record<string, Flag>; segments?: Record<string, Segment>; }
input.flags Record<string, Flag>
input.segments? Record<string, Segment>
projectKey? string
environmentKey? string

Promise<Draft>


listAudit(projectKey?, environmentKey?): Promise<AuditEntry[]>;

Defined in: core.ts:325

Parameter Type
projectKey? string
environmentKey? string

Promise<AuditEntry[]>


listEnvironments(projectKey): Promise<EnvironmentMeta[]>;

Defined in: core.ts:235

Parameter Type
projectKey string

Promise<EnvironmentMeta[]>


listFlags(projectKey?, environmentKey?): Promise<Flag[]>;

Defined in: core.ts:243

Parameter Type
projectKey? string
environmentKey? string

Promise<Flag[]>


listProjects(): Promise<ProjectMeta[]>;

Defined in: core.ts:230

Promise<ProjectMeta[]>


listSegments(projectKey?, environmentKey?): Promise<Segment[]>;

Defined in: core.ts:257

Parameter Type
projectKey? string
environmentKey? string

Promise<Segment[]>


listSnapshots(projectKey?, environmentKey?): Promise<string[]>;

Defined in: core.ts:316

Parameter Type
projectKey? string
environmentKey? string

Promise<string[]>


listSnapshotSummaries(projectKey?, environmentKey?): Promise<SnapshotSummary[]>;

Defined in: core.ts:317

Parameter Type
projectKey? string
environmentKey? string

Promise<SnapshotSummary[]>


publish(input?): Promise<Snapshot>;

Defined in: core.ts:288

Parameter Type
input? { by?: Actor | null; environmentKey?: string; message?: string; projectKey?: string; }
input.by? Actor | null
input.environmentKey? string
input.message? string
input.projectKey? string

Promise<Snapshot>


replaceDraft(draft): Promise<Draft>;

Defined in: core.ts:265

Parameter Type
draft Draft

Promise<Draft>


restoreFlag(
flagKey,
projectKey?,
environmentKey?
): Promise<Flag>;

Defined in: core.ts:254

Restore an archived flag by clearing Flag.archivedAt.

Parameter Type
flagKey string
projectKey? string
environmentKey? string

Promise<Flag>


rollback(input): Promise<Snapshot>;

Defined in: core.ts:294

Parameter Type
input { by?: Actor | null; environmentKey?: string; message?: string; projectKey?: string; version: string; }
input.by? Actor | null
input.environmentKey? string
input.message? string
input.projectKey? string
input.version string

Promise<Snapshot>


upsertFlag(
flag,
projectKey?,
environmentKey?
): Promise<Flag>;

Defined in: core.ts:245

Parameter Type
flag Flag
projectKey? string
environmentKey? string

Promise<Flag>


upsertSegment(
segment,
projectKey?,
environmentKey?
): Promise<Segment>;

Defined in: core.ts:263

Parameter Type
segment Segment
projectKey? string
environmentKey? string

Promise<Segment>