Sanity Library Reference Docs
    Preparing search index...
    interface WorkflowInstance {
        _createdAt: string;
        _id: string;
        _rev: string;
        _type: "sanity.workflow.instance";
        _updatedAt: string;
        abortedAt?: string;
        ancestors: GlobalDocumentReference<string>[];
        completedAt?: string;
        context: ContextEntry[];
        currentStage: string;
        definition: string;
        definitionSnapshot: string;
        effectHistory: EffectHistoryEntry[];
        fields: ResolvedFieldEntry[];
        history: HistoryEntry[];
        lastChangedAt: string;
        minReaderModel?: number;
        modelVersion?: number;
        pendingEffects: PendingEffect[];
        perspective?: WorkflowPerspective;
        pinnedContentHash?: string;
        pinnedVersion: number;
        processedRequests?: ProcessedRequest[];
        stages: StageEntry[];
        startedAt: string;
        subworkflows?: SubworkflowEntry[];
        tag: string;
        workflowResource: WorkflowResource;
        [key: string]: unknown;
    }

    Hierarchy (View Summary)

    Indexable

    • [key: string]: unknown
    Index

    Properties

    _createdAt: string
    _id: string
    _rev: string
    _type: "sanity.workflow.instance"
    _updatedAt: string
    abortedAt?: string

    Set (to the same instant as completedAt) when the instance was hard-stopped via abortInstance rather than reaching a terminal stage. completedAt is always stamped alongside it so every "in-flight" query (!defined(completedAt)) treats aborted and completed instances uniformly; this field is what distinguishes them.

    ancestors: GlobalDocumentReference<string>[]

    Chain of ancestor workflow instances, root-first. Each entry is a GDR pointing at a WORKFLOW_INSTANCE_TYPE document in the engine's own workflow resource.

    completedAt?: string
    context: ContextEntry[]

    The start seed: named values set once at startInstance (or by a parent's spawn.context) and never mutated after. Conditions and effect bindings read them as $context.<name>.

    currentStage: string
    definition: string

    Reference to the deployed definition, by its name.

    definitionSnapshot: string

    Frozen JSON snapshot of the definition at the moment the instance started.

    effectHistory: EffectHistoryEntry[]

    Workflow-level resolved field entries. Populated from the workflow definition's fields[] declarations plus the caller-supplied initialFields at startInstance. Persists for the lifetime of the instance.

    To declare "the subject document of this workflow", add a { type: "doc.ref", name: "subject", initialValue: { type: "input" } } entry to the workflow definition. Conditions then read it as $fields.subject. There is no other subject mechanism.

    history: HistoryEntry[]
    lastChangedAt: string
    minReaderModel?: number

    Reader floor — the oldest engine data model that can safely interpret this document. Derived from its persisted features and the retained model-4 baseline, and written alongside WorkflowInstance.modelVersion. Full persists never lower it.

    modelVersion?: number

    Engine data-model stamp — the shape contract this document conforms to (see DATA_MODEL_VERSION), orthogonal to the definition-content pins (pinnedVersion / pinnedContentHash). Stamped at create and re-asserted on every full persist; absent on documents last written before the stamp existed (model 0).

    pendingEffects: PendingEffect[]
    perspective?: WorkflowPerspective

    Optional perspective applied to field-entry query reads and spawn forEach.groq discovery. When unset the engine treats reads as "raw" (no filtering). Set at startInstance time to scope a workflow's reads to a Content Release stack (e.g. [releaseName] or [releaseName, "drafts"]).

    Engine-internal reads of instance / definition documents are always raw, regardless of this field.

    pinnedContentHash?: string

    Content fingerprint of the pinned definition version (see hashDefinitionContent). Pinned alongside the version so a consumer can detect a deployed definition that drifted from what this instance started on. Advisory — the engine enforces nothing; this enables detection, not prevention. Absent when the instance was started against a definition deployed before content-addressing (it had no hash to pin).

    pinnedVersion: number
    processedRequests?: ProcessedRequest[]

    Idempotency ledger — see ProcessedRequest. Optional because instances persisted before the ledger existed lack it (any commit materialises it, empty). Only keyed operations add rows — it never grows on instances whose callers pass no idempotencyKey.

    stages: StageEntry[]

    Per-stage instance entries — one StageEntry per stage the instance has been in, in entry order. Past stages persist with exitedAt set; the current stage is the entry whose exitedAt is undefined. Each entry owns its activities.

    startedAt: string
    subworkflows?: SubworkflowEntry[]

    Workflow-scope registry of every child this instance ever spawned; see SubworkflowEntry. Rows are never deleted; a row without resolved is a live child (watched, hydrated, propagating), one with it is terminal, and a live row with abortPending is condemned — the cascade owes it an abort. Rendered as the $subworkflows condition var. Absent only on instances persisted before the registry existed.

    tag: string

    Engine-scope environment partition stamped on the instance at create time. Reads are scoped to a single tag, so an engine only sees instances whose tag equals its own.

    workflowResource: WorkflowResource

    The Sanity resource this instance lives in. Stored on the doc so any internal operation can mint GDRs for ancestors / spawned children / etc. without re-supplying it. Mirrors @sanity/client's ClientConfigResource.