Sanity Library Reference Docs
    Preparing search index...

    Interface FunctionContextBeta

    The context object passed to the function handler.

    interface FunctionContext {
        clientOptions: {
            apiHost?: string;
            dataset: string;
            projectId: string;
            token: string;
        };
        eventResourceId: string;
        eventResourceType: string;
        functionResourceId: string;
        functionResourceType: string;
        local?: boolean;
    }
    Index

    Properties

    clientOptions: {
        apiHost?: string;
        dataset: string;
        projectId: string;
        token: string;
    }

    Options that can be passed to a @sanity/client constructor to configure it against the project and dataset which triggered the event. Note that you should always specify an explicit apiVersion in YYYY-MM-DD format (e.g. 2025-05-01).

    Constructing a client with the options from the context:

    const client = createClient({
    apiVersion: '2025-05-01',
    ...context.clientOptions,
    })
    eventResourceId: string

    The resource ID of the event source; resource ID that invoked the function.

    eventResourceType: string

    The resource type of the event source; resource type that invoked the function.

    functionResourceId: string

    The resource ID of the function container; resource ID that houses the function.

    functionResourceType: string

    The resource type of the function container; resource type that houses the function.

    local?: boolean

    local is set to true when testing your function locally. i.e. sanity function test func-name Otherwise, the property is not set.