Sanity Library Reference Docs
    Preparing search index...
    interface BenchStartInstanceArgs {
        access?: WorkflowAccess;
        actor?: Actor;
        ancestors?: GlobalDocumentReference<string>[];
        context?: StartContext;
        definition: string;
        grantsFromPath?: string;
        initialFields?: InitialFieldValue[];
        instanceId?: string;
        perspective?: WorkflowPerspective;
        version?: number;
    }
    Index

    Properties

    Replaces the bench's access for this call. When supplied, individual access shortcuts are ignored.

    actor?: Actor

    Actor for this call. Omit to use the bench's actor. Changing only the actor retains the bench's default grants and attributes.

    ancestors?: GlobalDocumentReference<string>[]
    context?: StartContext

    Stable named values supplied when starting this instance. They cannot be changed after start. Effect bindings and conditions read them as $context.<name>; the $effects bag is separate (completed effects' outputs only).

    Values supplied directly to start may be any JSON: a scalar, a GlobalDocumentReference, or an arbitrary object/array. Scalars and GDRs store as their typed context entries; anything else stores as one context.json entry, so all forms read back the same under $context.<name>. A parent's spawn.context has a narrower contract: only strings, numbers, booleans, and full GDRs are accepted; nullish results are omitted, and other objects or arrays reject the spawn.

    definition: string

    The definition's name — which deployed workflow to instantiate.

    grantsFromPath?: string

    URL path on the supplied client where the engine fetches the caller's ACL grants. Identity is always token-resolved — actor is resolved from the supplied client's token, never passed in — and grants feed the advisory $can.* params action conditions can read; omitting this leaves the rendered $can undefined (conditions referencing it fail closed, nothing else is gated engine-side — the real Sanity write boundary still enforces).

    Canvas-style: /canvases/<resourceId>/acl. Project/dataset: /projects/<id>/datasets/<ds>/acl.

    initialFields?: InitialFieldValue[]

    Initial values for input-sourced field entries declared on the workflow definition. Each value is a typed InitialFieldValue whose type + name must match an entry on definition.fields[]. Entries not present here resolve to their default (null for scalars, [] for arrays, or the entry's own initialValue resolution for query/working-memory entries).

    To start an instance "about" a specific document, declare a { type: "subject", name: "subject", initialValue: { type: "input" } } entry on the workflow and pass { type: "subject", name: "subject", value: { id, type } } here. Conditions then read it as $fields.subject, and document pickers key on the subject kind.

    instanceId?: string

    Caller-supplied id; auto-generated otherwise (mint one with instanceDocId). This is start's idempotency key: a retry carrying the same id resumes the earlier attempt's outstanding commits instead of creating a duplicate — the per-instance request ledger can't cover the create (it lives on the instance document), so id identity is the rail. Inputs bind on the create only; a resume never re-reads them.

    perspective?: WorkflowPerspective

    Perspective for content reads, including field queries and subworkflow discovery. An explicit value applies to workflow-field initialization and subsequent reads.

    When omitted, workflow-field queries at start use drafts. After those fields resolve, the instance uses [releaseName] from its first populated workflow release.ref field, or drafts when none is populated. Under drafts, drafts take precedence over published content.

    A child's workflow fields initialize under its parent's perspective. Afterward, the child's first populated workflow release.ref field selects its release perspective; otherwise it inherits the parent's.

    Pass [releaseName] to read under a Content Release, or [releaseName, 'drafts'] to include drafts. Engine-owned instance and definition documents, and system.release documents, always read under raw.

    version?: number

    Optional explicit version. Defaults to the highest deployed version.