✨Discover storytelling in the AI age with Pixar's Matthew Luhn at Sanity Connect, May 8th—register now

Request tags

Request tags in Sanity Log Delivery can be added to API and CDN requests for filtering and aggregating log data, supported by @sanity/client.

Request tags are values assigned to API and CDN requests that can be used to filter and aggregate log data within request logs from your Sanity Content Lake. The tagging can be achieved by adding the tag query parameter to the request URL, typically in the format:

GET /data/query/<dataset>?query=<GROQ-query>&tag=<custom-defined-tag>

SDK Support

@sanity/client has out-of-the-box support for tagging every API and CDN request on two levels:

  1. Globally: Using the requestTagPrefix client configuration parameter
  2. Per Request: Pass the tag option to the SDK’s Request method.

This provides a flexible method for tagging requests:


Code example

The following example will result in a query with tag=website.landing-page.

const client = createClient({
  projectId: "<project>",
  dataset: "<dataset>",
  token: "",
  useCdn: false, 
  apiVersion: "2024-01-24",
  requestTagPrefix: "website" // Added to every request

const posts = await client.fetch('*[_type == "post"]', {
  tag: `landing-page`, // Appended to requestTagPrefix for this individual request

Was this article helpful?