Sanity Library Reference Docs
    Preparing search index...

    A field declaration whose location determines its scope and lifetime. Workflow fields initialize at start; stage and activity fields initialize on each stage visit. FieldSource controls initialization; Editable controls direct edits independently.

    required: true is valid only on workflow-scope fields with an input source. It requires a non-null value at start or spawn. On subject, doc.ref, and doc.refs, selected targets must also remain readable in the workflow perspective after initialization. Missing targets block normal actions, triggered actions, and transitions. Abort and permitted field edits remain available. subject is also workflow-scope-only, with at most one subject per definition. Each scope may declare at most one dueDate or dueDatetime field, always top-level.

    types is a nonempty list of accepted document types on subject, doc.ref, or doc.refs; omit it to accept any document type. On subject, types instead governs which documents the definition's applicability read matches: an unscoped subject never matches a system document (isSystemDocumentType), and naming a reserved-namespace type in types matches it. Naming an engine-owned type fails defineWorkflow and deploy validation; to run a workflow from another workflow, use spawn. A stored definition that names one never matches it. roles constrains assignment eligibility only on assignee and assignees. FieldShape, ChoiceOptions, and ScalarValidation define the nested-shape and scalar constraints. Authoring conveniences are accepted by AuthoringFieldEntry.

    interface FieldEntry {
        description?: string;
        editable?: Editable;
        fields?: FieldShape[];
        group?: string[];
        initialValue?:
            | { type: "input" }
            | { query: string; type: "query" }
            | { type: "literal"; value: unknown }
            | {
                field: string;
                path?: string;
                scope?: "workflow" | "stage";
                type: "fieldRead";
            };
        name: string;
        of?: FieldShape[];
        options?: ChoiceOptions;
        required?: boolean;
        roles?: string[];
        title?: string;
        type: | "string"
        | "number"
        | "boolean"
        | "object"
        | "actor"
        | "datetime"
        | "array"
        | "text"
        | "url"
        | "doc.ref"
        | "doc.refs"
        | "subject"
        | "release.ref"
        | "progress"
        | "date"
        | "dueDate"
        | "dueDatetime"
        | "assignee"
        | "assignees";
        types?: string[];
        validation?: ScalarValidation;
    }
    Index

    Properties

    description?: string
    editable?: Editable
    fields?: FieldShape[]
    group?: string[]
    initialValue?:
        | { type: "input" }
        | { query: string; type: "query" }
        | { type: "literal"; value: unknown }
        | {
            field: string;
            path?: string;
            scope?: "workflow" | "stage";
            type: "fieldRead";
        }
    name: string
    of?: FieldShape[]
    options?: ChoiceOptions
    required?: boolean
    roles?: string[]

    Non-empty assignment eligibility constraint. User roles apply aliases; collective roles match literally.

    title?: string
    type:
        | "string"
        | "number"
        | "boolean"
        | "object"
        | "actor"
        | "datetime"
        | "array"
        | "text"
        | "url"
        | "doc.ref"
        | "doc.refs"
        | "subject"
        | "release.ref"
        | "progress"
        | "date"
        | "dueDate"
        | "dueDatetime"
        | "assignee"
        | "assignees"
    types?: string[]
    validation?: ScalarValidation