Functions API reference

Reference documentation for the Sanity Functions HTTP endpoints.

Authentication

Base API server URL

Staging External API

https://api.sanity.work

Production External API

https://api.sanity.io

Functions

Retrieve function logs

get/{apiV}/functions/{functionId}/logs

By default, this route returns a list of the last 100 log entries. To get a different set of items, you can use the offset and limit parameters in the query string of the GET request.

Path parameters

Query parameters

  • limitstringdefault: "100"

    The maximum number of logs to retrieve.

  • offsetstringdefault: "0"

    The offset, from the last log entry, to begin retrieval.

Header parameters

Responses

200

Logs retrieve

  • limitnumberrequired
    Example:1
  • logsarrayrequired
    Show child attributes
    items
    • levelstring | null
    • messagestringrequired
      Example:This is probably something important
    • requestIdstringrequired
      Example:c19d92ea-f3c1-4fc1-a2a4-7d7e08527584
    • timestring (date-time)required
      Example:"2025-10-09T10:50:09.486Z"
  • nextstring
    Example:/vX/functions/123456/logs?limit=1&offset=2
  • offsetnumberrequired
    Example:1
  • prevstring
    Example:/vX/functions/123456/logs?limit=1&offset=0

Delete logs for a function

delete/{apiV}/functions/{functionId}/logs

Path parameters

Header parameters

Responses

200

Logs deleted successfully

    Stream function logs

    get/{apiV}/functions/{functionId}/logs/stream

    Path parameters

    Header parameters

    Responses

    200

    Logs retrieve

    • logsobjectrequired
      Show child attributes

      Invoke a function

      post/{apiV}/functions/{functionId}/invoke

      Path parameters

      Query parameters

      • syncdefault: false

        Whether to invoke functions synchronously, defaults to false.

      Header parameters

      Request body application/json

      • eventobjectrequired
        Show child attributes
        • dataobjectrequired
          Show child attributes

        Responses

        200

        Function Invoked

        • schema | null

        List functions

        get/{apiV}/functions

        Path parameters

        Query parameters

        • includeProjectsdefault: false

          When true and the request is organization scoped, include functions for all projects under the organization

        • regionstring

          The region of the deployed resource

        • statusstring

          State of function

        Header parameters

        Responses

        200

        List of functions

        • functionsarrayrequired
          Show child attributes
          items
          • deletedAtstring (date-time) | nullrequired

            Date resource was deleted

            Example:"2021-07-01T12:00:00.000Z"
          • displayNamestring | nullrequired

            The human-readable name of the function

            Example:Log Sweeper
          • idstringrequired

            The ID of the resource

            Example:abcd123456
          • memorynumberdefault: 1024required

            Memory allocated to function

            Example:256
          • namestring | nullrequired

            The unique name of the blueprint resource

            Example:log-sweeper
          • resourceIdstring | nullrequired

            Resource ID

            Example:24s6f8sr
          • resourceTypestring | nullrequired

            Type of resource (i.e. project or organization)

            Example:project
          • robotIdstring | nullrequired

            Robot Token ID

            Example:g-qS7j8qb0uvL4
          • runtimestringdefault: "nodejs24.x"required

            Runtime for function

            Example:nodejs24.x
          • statusstringrequired

            State of function

            Example:assigned
          • storagenumberdefault: 512required

            Ephemeral storage allocated to function in MB

            Example:512
          • timeoutnumberdefault: 10required

            Timeout for function in seconds

            Example:60
          • typestringrequired
          • urlstring | nullrequired

            Function invocation URL

            Example:https://my-function-123456-uc.a.run.app
          • contentSubdefault: {}
            Show child attributes
            • createdAtstring (date-time)required

              Date resource was created

              Example:"2021-07-01T12:00:00.000Z"
            • updatedAtstring (date-time)required

              Date resource was last updated

              Example:"2021-07-01T12:00:00.000Z"

          Read a function

          get/{apiV}/functions/{functionId}

          Path parameters

          Header parameters

          Responses

          200

          Function

          • funcrequired
            Show child attributes
            • deletedAtstring (date-time) | nullrequired

              Date resource was deleted

              Example:"2021-07-01T12:00:00.000Z"
            • displayNamestring | nullrequired

              The human-readable name of the function

              Example:Log Sweeper
            • idstringrequired

              The ID of the resource

              Example:abcd123456
            • memorynumberdefault: 1024required

              Memory allocated to function

              Example:256
            • namestring | nullrequired

              The unique name of the blueprint resource

              Example:log-sweeper
            • resourceIdstring | nullrequired

              Resource ID

              Example:24s6f8sr
            • resourceTypestring | nullrequired

              Type of resource (i.e. project or organization)

              Example:project
            • robotIdstring | nullrequired

              Robot Token ID

              Example:g-qS7j8qb0uvL4
            • runtimestringdefault: "nodejs24.x"required

              Runtime for function

              Example:nodejs24.x
            • statusstringrequired

              State of function

              Example:assigned
            • storagenumberdefault: 512required

              Ephemeral storage allocated to function in MB

              Example:512
            • timeoutnumberdefault: 10required

              Timeout for function in seconds

              Example:60
            • typestringrequired
            • urlstring | nullrequired

              Function invocation URL

              Example:https://my-function-123456-uc.a.run.app
            • contentSubdefault: {}
              Show child attributes
              • createdAtstring (date-time)required

                Date resource was created

                Example:"2021-07-01T12:00:00.000Z"
              • updatedAtstring (date-time)required

                Date resource was last updated

                Example:"2021-07-01T12:00:00.000Z"

            List environment variable keys

            get/{apiV}/functions/{functionId}/envvars

            Path parameters

            Header parameters

            Responses

            200

            List of environment variable keys

            • envvarsarrayrequired
              Show child attributes
              items
              • string

            Update an environment variable

            put/{apiV}/functions/{functionId}/envvars/{envVarKey}

            Path parameters

            • apiVstringrequired
            • envVarKeystringrequired

              The key of the environment variable

            • functionIdstringrequired

              The ID of the resource

            Header parameters

            Request body application/json

            Responses

            204

            The environment variable was updated successfully

            Delete an environment variable

            delete/{apiV}/functions/{functionId}/envvars/{envVarKey}

            Path parameters

            • apiVstringrequired
            • envVarKeystringrequired

              The key of the environment variable

            • functionIdstringrequired

              The ID of the resource

            Header parameters

            Responses

            204

            Environment Variable Deleted

            sanity.ioAll Systems Operational© Sanity 2026
            Change site theme