Tracking down excessive API requests and potential webhook integration issue.
Yes, there is! Sanity has a Request Logs feature that can help you track down where those API requests are coming from.
Accessing Request Logs
If you're on a self-serve plan, you can access request logs directly from your project settings:
- Go to the Usage section at sanity.io/manage
- Scroll to the bottom of the page
- Download up to 1GB of log data from the last 7 days
- You can request a new export every 24 hours
The logs come as GZIPPED NDJSON files that contain detailed information about every request.
What You'll Find in the Logs
The request logs include really useful fields like:
- Request Type: Whether it's API, APICDN, or CDN requests
- Remote IP: The IP address making the request
- User Agent: What client/browser is making the request
- Referrer: Where the request is coming from
- Full URL: The complete request including query parameters
- GROQ Query Identifier: A hashed version of your queries (great for finding duplicate/inefficient queries)
- Timestamp: When each request happened
Analyzing the Data
You can convert the compressed NDJSON to CSV for easier analysis:
gunzip --stdout [logfile].ndjson.gz | npx json2csv --ndjson --output [output].csvOr use tools like jq, GROQ CLI, or even upload samples to ChatGPT to help analyze patterns.
Pro Tip: Filter Out Studio Requests
Requests from Sanity Studio are marked as studioRequest and don't count toward your API usage or cost. Make sure to filter these out when analyzing what's driving your actual API consumption.
Common Culprits to Look For
Based on your situation with CDN enabled, check for:
- Requests with
requestType: "API"instead of"APICDN"(might indicate CDN isn't being used where you think it is) - Repeated identical queries that could be cached better
- Bot traffic (look at User Agent and IP patterns)
- Development environments accidentally hitting production
- Missing dependencies in React hooks causing request loops
You might also want to implement request tags in your code going forward to make it easier to track which parts of your application are making which requests.
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.