Sanity Library Reference Docs
    Preparing search index...

    The engine-scope bindings pinned once by createEngine and carried explicitly on every raw workflow.* call. Engine methods never take these — they were supplied at construction.

    interface EngineScopeArgs {
        client: WorkflowClient;
        executionContext?: DeclaredExecutionContext;
        idempotencyTtlMs?: number;
        resourceClients?: ResourceClientResolver;
        tag: string;
        workflowResource: WorkflowResource;
    }

    Hierarchy (View Summary)

    Index

    Properties

    The engine resolves its acting identity from this client's token and caches the resolution per client object — the client's auth must be stable for the engine's lifetime. To act as someone else, construct an engine over a client bound to their token (withConfig({token})), never mutate this client's auth in place.

    Any configured apiVersion works: every verb derives its working client onto ENGINE_API_VERSION, on the raw namespace as much as through createEngine — see WorkflowClient.withConfig.

    executionContext?: DeclaredExecutionContext

    Declared execution context — the advisory "via what" stamped on every history entry alongside the token-resolved actor. Construction-scope configuration, never per-call: the runtime half is always inferred, and the declared {kind, id} half labels the host (see EXECUTION_KINDS). Omitted ⇒ runtime-only stamps.

    idempotencyTtlMs?: number

    How long a recorded idempotencyKey dedupes retries (the processedRequests[] row's lifetime). Default 24 hours. Size it to the caller's longest retry horizon — a retry arriving after the row expired re-executes the operation.

    resourceClients?: ResourceClientResolver

    Optional routing override for cross-resource reads (subject + ancestor docs that live in a different Sanity resource than the workflow). Called with a parsed GDR; return a client for that resource, or undefined to let the engine route it — client for the workflow resource itself, a sibling derived from client's credentials for anything else. A served resource is also part of the declared surface for runtime-supplied refs. Engine-scope configuration — see CreateEngineArgs.

    tag: string

    Engine-scope environment partition — required. See validateTag + tags.ts.

    workflowResource: WorkflowResource

    The Sanity resource the engine's own data lives in. Used to mint GDR URIs for every doc the engine writes (definitions, instances, ancestor refs). Mirrors @sanity/client's ClientConfigResource.