APIs and SDKs
Request tags for filtering logs in @sanity/client
Learn how to use request tags to identify and filter API requests in your Sanity project's request logs for debugging and monitoring.
Request tags help you identify and filter API requests in your project's request logs. This is valuable for debugging, monitoring performance, and understanding how your application uses the API.
You can set tags at the client level or per request:
import {createClient} from '@sanity/client'
// Set default tag on client
const client = createClient({
projectId: 'your-project-id',
dataset: 'production',
apiVersion: '2026-03-01',
requestTagPrefix: 'myapp', // Prefix for all requests
})
// Tag individual queries
const posts = await client.fetch(
'*[_type == "post"]',
{},
{tag: 'homepage-posts'}
)
// Request appears in logs as: myapp.homepage-posts
// Tag getDocument requests
const post = await client.getDocument('post-123', {
tag: 'post-detail'
})
// Tag listeners
const subscription = client.listen(
'*[_type == "post"]',
{},
{tag: 'realtime-posts'}
).subscribe(update => {
// ...
})Tags appear in your project's API request logs in the Sanity management console, where you can filter and analyze request patterns, identify slow queries, and debug issues.