Reference
Find the authoritative API and type reference for each Workflows domain. Exact contracts live at the bottom of the corresponding concept page.
Core model
- Engine: engine construction, verbs, transactions, evaluation, errors, actor resolution, and persisted-model governance. See the advanced exports below for lower-level helpers.
- Definitions and instances: definition and instance shapes.
- History and audit trail: retrieving instance history and the complete
HistoryEntryevent reference. - Stages and transitions: stage, visit, and transition contracts.
- Fields: field declarations, stored field types, progress, initial values, validation, and editability.
- Conditions: condition syntax, variables, and evaluation contexts.
- Activities and actions: declarations, evaluation, and projected firing consequences.
- Operations: state-changing operations and value expressions.
- Effects and runtimes: declarations, handlers, draining, mid-dispatch field reports, and completion.
- Guards and enforcement: guard declarations and lifecycle.
- Subworkflows: spawning, child lifecycle, and propagation.
- Global document references: resource-qualified references and deployment helpers. See
expandResourceAliasesandrefsOfbelow.
Advanced exports
These lower-level exports support custom integrations, deployment tooling, and persisted-model diagnostics.
WorkflowConfigInput
WorkflowConfigInput is the authoring shape accepted by defineWorkflowConfig. Every deployment is a WorkflowDeploymentInput.
WorkflowDeploymentInput
WorkflowDeploymentInput requires the reviewed current reader floor as a literal. Reuse this authored object when config and Blueprint entry points share a deployment.
WorkflowConfig
WorkflowConfig is the parsed shape returned by defineWorkflowConfig. It can hold an unverified acknowledgement until a deployment is selected.
WorkflowDeployment
WorkflowDeployment is one parsed deployment. Do not pass it back to an authoring API that requires WorkflowDeploymentInput.
AcknowledgedWorkflowDeployment
AcknowledgedWorkflowDeployment is exported by @sanity/workflow-engine. It is a parsed deployment whose reader-floor acknowledgement has been validated against the definitions a command will submit.
OUTCOME_MARKS
OUTCOME_MARKS maps each ConditionOutcome to the glyph used by condition checklists: ✓ for satisfied, ✗ for unsatisfied, and ? for unevaluable. Use it when a custom integration renders structured condition results instead of checklistLines output.
NEUTRAL_MARK
NEUTRAL_MARK is the bullet used for a condition checklist that has no live verdict. Use it for definition-only explanations where satisfied or unsatisfied marks would imply that the condition was evaluated against a running instance.
Semantic exports
actorFulfillsRole
actorFulfillsRole({actorRoles, required, aliases}) tests whether an actor holds a required role directly or through the definition’s role aliases.
SIGNAL_SEMANTICS
readonly SignalSemantic[]
The three built-in signal labels.
DECISION_SEMANTICS
readonly DecisionSemantic[]
The two action-only decision labels.
ACTION_SEMANTICS
readonly (DecisionSemantic | SignalSemantic)[]
The enumerable built-in action labels; custom labels are validated separately.
SignalSemantic
'signal.positive' | 'signal.caution' | 'signal.critical'
A built-in advisory signal.
DecisionSemantic
'decision.accept' | 'decision.decline'
An action-only advisory decision.
CustomSemantic
`custom.${string}`
A validated custom camel-case meaning.
Semantic
SignalSemantic | CustomSemantic
Allowed on workflows, stages, and activities.
ActionSemantic
DecisionSemantic | Semantic
Allowed on actions.
resolveActor
resolveActor(directory, actor) resolves a person actor through a ProjectUserDirectory. It returns resolved, missing, or inaccessible; agent and system actors return not-person without a user lookup.
userLoginProvider
ClientProjectUser is the project API user record used by actor resolution. userLoginProvider(user) returns user.provider when present, otherwise user.loginProvider. It returns undefined when no user or provider is available. Use this helper because the project user endpoints use different field names for the same display-only value.
User attribute access
resolveUserAttributes
Promise<UserAttributes | undefined>
Resolves the caller’s organization attributes for soft gates. Expected 401–404 responses return undefined.
UserAttributes
Record<string, unknown>
The normalized flat attribute bag.
WorkflowAccess.attributes
UserAttributes | undefined
Supplies attributes to engines and test integrations.
DATA_MODEL_CHANGES
DATA_MODEL_CHANGES is the frozen manifest of governed persisted-model changes, including each change’s document types, compatibility class, introduced model, minimum reader model, applicability, and summary.
requiredModelFeatures
requiredModelFeatures(documentType, document) returns the manifest entries whose feature detectors apply to one canonical stored definition or instance.
requiredReaderModel
requiredReaderModel(documentType, document) returns the oldest engine data model that can safely interpret that stored definition or instance. It returns 0 when no governed feature raises the floor.
DATA_MODEL_MAX_READER
DATA_MODEL_MAX_READER is the highest reader-floor acknowledgement this writer can emit. In version 0.30 it is 8.
requiredDefinitionReaderModel
requiredDefinitionReaderModel(definitions) returns the minimum reader model required by a batch of authored definitions. Role-constrained assignment fields raise the result to 8.
assertReaderModelAcknowledgement
assertReaderModelAcknowledgement(value, {requiredMinReaderModel, context?}) asserts that a reviewed numeric literal meets the submitted definitions’ required floor without exceeding the writer’s supported maximum. It throws ReaderModelAcknowledgementError when the value is missing, malformed, below requiredMinReaderModel, or above DATA_MODEL_MAX_READER. The optional context labels the failing caller.
isRevisionConflict
isRevisionConflict(error) identifies a likely lost optimistic lock for one known revision-guarded write. A bare 409 can also be a create-ID collision, so narrow the operation before using this predicate.
Snapshot diagnostics
diagnoseInstance
Diagnosis
Classifies an evaluated snapshot, including transition-level causes.
documentStuckCause
StuckCause | undefined
Detects committed failed-effect, failed-activity, or hung-effect causes. Undefined is not an all-clear.
findStageNode
Stage | undefined
Tolerantly finds a stage in a definition snapshot.
findActivityNode
Activity | undefined
Tolerantly finds an activity in a stage snapshot.
expandResourceAliases
expandResourceAliases(definition, resourceAliases) returns the workflow definition with logical @alias: references expanded to physical GDRs. It validates alias names and rejects missing or malformed standalone aliases.
refsOf
refsOf(definition) returns the definition’s outgoing spawn dependencies as LogicalRef[], where each row is {name: string, version?: number | 'latest'}.
deployedTagsGroq
deployedTagsGroq() returns a cross-partition GROQ query that lists the distinct tags with deployed definitions, sorted in ascending order. Run it with a client scoped to the workflow resource. It reports observed deployments, so tags with no deployed definitions are absent.
definitionTagsGroq
definitionTagsGroq() returns the same kind of tag query narrowed to one definition. Pass {definition} as the query parameters. A definition deployed under several tags produces several results; the query reports that ambiguity and does not choose a tag for you.
Runtime and integrations
- The reactive session: reactive state and commands.
- CLI: deployment and administration commands.
- MCP server: agent tools and configuration.
- Studio plugin: Studio setup and workflow UI.
- Custom Studio integrations: Studio-bound engine, hooks, and a Document Action example.
- App SDK: building workflow interfaces with the App SDK.
- Reusable UI components: assignment, date, progress, member, and workflow-diagram controls.
Development
Visiting agent?
Workflows includes an MCP server for inspecting, operating, authoring, validating, and deploying workflows. Ask your human to set up the MCP server.