HTTP API Reference

Functions API reference

Reference documentation for the Sanity Functions HTTP endpoints.

Authentication

Base API server URL

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

  • Durable Function execution ID.

  • includeQueueSysLogsstringdefault: "true"

    Set to "false" to omit the "Message sent to queue" system log entries emitted when a message is enqueued for a queue function.

  • 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
    • attemptinteger

      Optional Durable step attempt positive number, if the log came from a Durable step operation

      Example:1
    • Durable Function execution ID.

      Example:1%2Fdurable-execution%2Fa5f104bf-8f98-4c43-a275-c47cd0e55c91%2F721704c1-73ae-3004-95fa-f472e130fb15
    • levelstring | null
    • messagestringrequired
      Example:This is probably something important
    • Optional unique Durable step ID, if the log came from a Durable step operation

      Example:c81e728d9d4c2f63
    • Optional non-unique Durable step name, if the log came from a named Durable step operation

      Example:flip-coin
    • 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

Stream function logs

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

Path parameters

Query parameters

  • afterstring (date-time)

    ISO 8601 timestamp to stream from, exclusive. Defaults to the newest entry at connect time, so only new logs are sent. Ignored when Last-Event-ID is present.

  • includeQueueSysLogsstringdefault: "true"

    Set to "false" to omit the "Message sent to queue" system log entries emitted when a message is enqueued for a queue function.

Header parameters

Responses

200

Stream of logs

  • datastringrequired

    JSON array of log entries

  • eventstringrequired
  • idstring

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

    • statusesstring

      Comma separated list of statuses to filter by. Takes precedence over status when both are provided.

    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"

        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