canonical: https://jentic.com/apis/sanity.io/sanity-usage-api

# Sanity Usage API

The Sanity Usage API reports how much of each metered resource a Sanity project, media library, organization, or context has consumed. A snapshot call returns a map of metric names such as apirequests, apicdnrequests, documents, or assets to their value for a day, month, or year, along with the latest timestamp recorded for each metric. A history call returns the same metrics over a date range, aggregated by period and optionally as a running total. For organizations, scoped calls break AI and embeddings metrics such as ai-usage and embeddings-reads down per user.

## For AI agents

Read Sanity usage metrics such as API requests, CDN requests, documents, and assets for a project or organization, as a snapshot or as daily, monthly, or yearly history.

## Scope

Does not change plans, set usage limits, or return billing invoices. Use for reading Sanity usage metrics only.

## Capabilities

- Get a usage snapshot for a project, media-library, organization, or context, with each metric's value and latest timestamp
- Pull usage history between from and to dates, aggregated by day, month, or year
- Compute cumulative usage with cumulative and cumulative_period, for example a daily running total that resets each month
- Limit the response to named metrics through the comma-separated metrics parameter, such as apicdnrequests,documents,assets
- Break organization AI metrics such as content-agent-queries, ai-usage, and embeddings-writes down per user with the user scope
- Compare against the previous billing window by setting snapshotPeriod to previousPeriod

## Use cases

### AI agent watching plan usage

An agent that keeps an eye on a Sanity bill searches Jentic for 'get Sanity project usage', loads the getResourceSnapshot operation, and requests apirequests, apicdnrequests, documents, and assets for the current month. It compares the values with the previous window by repeating the call with snapshotPeriod set to previousPeriod and flags a sharp rise, with the Sanity token injected at call time.

Example prompt: Call GET `/v2026-09-01/usage/{resourceType}/{resourceId}/snapshot` with resourceType project, resourceId abc123, and metrics apirequests,apicdnrequests,documents,assets, then report each value

### Usage trend reporting

Finance or engineering leads want to see how usage grows over time. The history operation returns metrics between from and to dates aggregated by day, month, or year. A day period accepts at most 90 days and a month period at most 24 calendar months, and setting cumulative to true turns counter metrics into a running total.

Example prompt: Call GET `/v2026-09-01/usage/{resourceType}/{resourceId}/history` with resourceType organization, resourceId or0Bc1hcJ, period month, from 2025-01-01, and to 2025-12-31

### Per-user AI usage in an organization

When AI features drive cost, it helps to know who is using them. The scoped snapshot and history operations accept the user scope on organizations and return per-user values for metrics such as content-agent-queries, content-agent-actions, ai-usage, embeddings-writes, and embeddings-reads. Other metrics and resource types return no scoped data.

Example prompt: Call GET `/v2026-09-01/usage/{resourceType}/{resourceId}/{scope}/snapshot` with resourceType organization, scope user, and metrics ai-usage,content-agent-queries, then rank users by ai-usage

## Key endpoints

| Method | Path | Description |
| --- | --- | --- |
| GET | `/v2026-09-01/usage/{resourceType}/{resourceId}/snapshot` | Get a usage snapshot |
| GET | `/v2026-09-01/usage/{resourceType}/{resourceId}/history` | Get usage history over a date range |
| GET | `/v2026-09-01/usage/{resourceType}/{resourceId}/{scope}/snapshot` | Get a per-user usage snapshot |
| GET | `/v2026-09-01/usage/{resourceType}/{resourceId}/{scope}/history` | Get per-user usage history |

## Key resources

- **Usage snapshots** — Metric values and latest timestamps for one day, month, or year
- **Usage history** — Metric values per period between from and to dates, optionally cumulative
- **Scoped usage** — Per-user breakdown of organization AI and embeddings metrics

## AI readiness

This API is usable in Jentic One now. Its AI-readiness score against Jentic's framework shows where it stands today and where improvements would make it even easier for agents to use.

- **Score:** 73 / 100
- **Maturity:** AI-Aware
- **Dimensions:**
  - Foundational Compliance: 100 / 100
  - Developer Experience & Jentic Compatibility: 72 / 100
  - AI-Readiness & Agent Experience: 52 / 100
  - Agent Usability: 94 / 100
  - Security: 75 / 100
  - AI Discoverability: 81 / 100
- **View full report:** https://jentic.com/apis/sanity.io/sanity-usage-api/scorecard
- **How the score is calculated:** https://docs.jentic.com/reference/api-readiness-framework/overview/
- **More about the dimensions:** https://docs.jentic.com/reference/api-readiness-framework/specification/#dimensional-model-overview

### Score it yourself

Every API in the directory is allowlisted, so you can re-score it with no key required.

- **Score your own API:** https://jentic.com/scorecard.md
- **Scoring CLI agent skill:** https://github.com/jentic/jentic-api-scorecard/blob/main/skills/jentic-api-scorecard/SKILL.md

```sh
npx @jentic/api-scorecard-cli score <openapi-url>
```

## Why Jentic

- **Setup:** Wiring the Sanity Usage API by hand means sending a bearer token, encoding resourceType and resourceId in the path, and working within period-dependent range limits that return 400 when exceeded. Through Jentic you install once, import it from the API Directory, store the token once, and your agent calls it.
- **Permission scoping:** Sanity puts the resource type and ID in the URL path (`/usage/{resourceType}/{resourceId}/...`), so a rule can pin your agent to one project or organization. Every operation is a read, so the agent can report usage but cannot change any setting through this API.
- **Credential handling:** Your Sanity token is stored once, encrypted, by your own Jentic One instance and injected at execution time. It never enters the agent's prompt, logs, or context.
- **Discovery method:** Agents search Jentic by intent such as 'get Sanity project usage' or 'show Sanity usage history', and Jentic returns the getResourceSnapshot or getResourceHistory operation with its path and query parameters.

## Related APIs

- **Sanity Projects API** — List the Sanity projects and organizations whose usage you read
- **Sanity Activity Log API** — Read the activity behind changes in a Sanity organization
- **Contentful API** — Headless CMS with its own management API

## FAQ

### What authentication does the Sanity Usage API use?

Per its OpenAPI spec, the Sanity Usage API uses a bearer token in the Authorization header, declared with a JWT bearer format, on all four operations. Through Jentic the Sanity token is stored by your own instance and attached at call time, so it stays out of the agent's context.

### Which resource types does the Sanity Usage API support?

The resourceType path parameter accepts project, media-library, organization, or context, and any other value is rejected with a 400. For context, the resourceId is the owning organization's ID.

### How far back can I request Sanity usage history?

It depends on the period. A day period accepts at most 90 days between from and to, a month period at most 24 calendar months, and a year period is unlimited. Without from, history starts 30 days before today, and exceeding a limit returns a 400.

### What are the rate limits for the Sanity Usage API?

The OpenAPI spec does not specify rate limits. Check the Sanity documentation at https://www.sanity.io/docs for current API limits for your plan.

### Is there a Sanity MCP server?

You don't need an MCP server to give your agent the Sanity Usage API. Jentic connects it directly from the API Directory: import it, store your Sanity token once, and your agent calls the snapshot or history operation when it needs usage numbers.

### How do I check Sanity project usage through Jentic?

Search Jentic for 'get Sanity project usage', load the getResourceSnapshot operation, and execute GET `/v2026-09-01/usage/{resourceType}/{resourceId}/snapshot` with resourceType project and your project ID. To run it on your own infrastructure, install Jentic One from its GitHub repo.

### Can I limit what my agent is allowed to do with the Sanity Usage API?

Yes. A rule that allows only GET `/v2026-09-01/usage/project/abc123/snapshot` and its history twin lets a reporting agent read one project's numbers without seeing organization-wide or per-user usage. Every call it makes is logged.
