Sanity local development causing 25k+ API request spike

4 replies
Last updated: Aug 23, 2024
I have a project that every time I run locally spikes my api request usage like crazy (25k+ request). I’m been back and forth with sanity over email but they mentioned taking it to slack
AI Update

I completely understand the frustration of seeing 25k+ requests just from running your project locally—that's definitely not normal! The Sanity support team was right to point you toward the community for additional help, as this is often an issue others have encountered and solved.

Join the Sanity Community

Sanity's community recently migrated from Slack to Discord in August 2025. The official community platform is now Discord, where you'll find 19,000+ developers and Sanity team members who can help troubleshoot your specific setup.

If the support team mentioned Slack, they may have been referring to the old platform before the migration, but Discord is now the place to be for community support. There are dedicated channels for support questions like yours, and you'll often get responses from people who've dealt with similar issues.

Diagnosing Your Request Spike

While you're waiting for community responses, here are some steps to identify what's causing the spike:

1. Download Your Request Logs

Sanity provides Request Logs that show exactly what's hitting your API. You can:

  • Go to sanity.io/manage → your project → Usage section
  • Scroll to the bottom of the page
  • Download up to 1GB of log data from the last 7 days (up to the day before the download)
  • The logs come in GZIPPED NDJSON format with details like timestamps, query types, referrers, and user agents

You can convert these to CSV for easier analysis:

gunzip --stdout [logfile].ndjson.gz | npx json2csv --ndjson --output analysis.csv

2. Common Culprits for Local Development Spikes

Based on community discussions in the Sanity ecosystem, these are the most common causes:

  • Missing dependencies in useEffect hooks: This causes infinite render loops that repeatedly fetch data
  • Hot module reloading: Your dev server might be refetching data on every code change
  • Multiple preview instances: Running multiple browser tabs or preview windows
  • Webhook loops: If you have webhooks configured that trigger rebuilds which trigger more webhooks
  • CDN/cache disabled: Using useCdn: false in development means every request hits the API directly

3. Use Request Tagging to Identify Sources

Implement request tagging in your client configuration to help identify which part of your code is causing the spike. The tag query parameter allows you to label requests so they're easier to filter in your logs:

const client = createClient({
  projectId: "your-project",
  dataset: "your-dataset",
  apiVersion: "2024-01-24",
  requestTagPrefix: "local-dev" // This tags all requests
});

// Or tag specific queries
const posts = await client.fetch('*[_type == "post"]', {
  tag: 'homepage-query'
});

This makes it much easier to filter your request logs and see exactly which queries are running excessively. When you use requestTagPrefix and per-request tag together, they combine (e.g., local-dev.homepage-query), giving you granular visibility into where requests originate.

4. Filter Out Studio Requests

One important note when analyzing your logs: requests from Sanity Studio (marked as studioRequest) don't count toward your API usage or cost. Make sure to filter these out when doing your analysis so you're focusing on the actual problematic requests.

Get Help on Discord

Once you've gathered some data from your request logs or implemented tagging, head to the Sanity Discord with that information. The community can help you interpret the logs and identify the specific issue in your setup. Having concrete data about which endpoints are being hit and how frequently will make troubleshooting much faster.

Show original thread
4 replies
You would have to provide some more details for anyone to help you.
Have you checked the request logs? Do you have a rouge
useEffect
or similar? What kind of front-end do you have? What have you tried to narrow it down?
I’m almost positive it was my useeffect I had. It had no second argument so I think it was making a ton requests :melting_face:
classic! 😄
🙈 glad it didnt effect any other of my projects! this is my starter repo

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Was this answer helpful?