canonical: https://jentic.com/apis/sanity.io/sanity-user-attributes

# Sanity User Attributes API

The Sanity User Attributes API stores attributes such as location, department, or year_started on the users of a Sanity organization, for use in access control. It defines attribute keys with a type such as string, string-array, integer, number, or boolean, sets and deletes values per user, and reads them back with the value from each source. Attributes can come from SAML single sign-on or be set through this API: when both exist, the Sanity value shadows the SAML one, and each attribute reports its activeSource and activeValue. It is available from API version v2026-04-27.

## For AI agents

Define typed attribute keys for a Sanity organization, set or clear attribute values on users, and see which value, SAML or Sanity, is active for access control.

## Scope

Does not assign roles, invite users, or configure SSO providers. Use for defining and setting Sanity organization user attributes only.

## Capabilities

- Define an organization attribute key such as year_started with a type of string, string-array, integer, integer-array, number, number-array, or boolean
- List an organization's attribute definitions grouped by key, with the sources, saml or sanity, where each is defined
- Set attribute values on a user by key in one call, creating the Sanity definition automatically when the key has none
- Read a user's attributes with values from each source plus the activeSource and activeValue used in access control
- Delete a user's Sanity attribute values by key so that any SAML value for the same key becomes active again
- Read the calling user's own attributes in an organization, paged with limit and cursor

## Use cases

### AI agent keeping user attributes in sync

An agent asked to mirror department and location from an HR system into Sanity searches Jentic for 'set Sanity user attributes', loads updateUserAttributes, and posts an attributes array of key and value pairs for each user. Keys without a Sanity definition get one automatically, and the response shows the activeValue now used for access control, all without the Sanity token entering its context.

Example prompt: POST `/v2026-04-27/organizations/{organizationId}/users/{sanityUserId}/attributes` with attributes [{key: 'department', value: 'Marketing'}, {key: 'location', value: 'UK'}] and confirm the returned activeValue for each

### Overriding SAML values for one user

SSO providers sync attributes through SAML, but sometimes one user needs a different value. Setting a Sanity value for the same key shadows the SAML value while keeping it visible in the values object. Deleting the Sanity value with deleteUserAttributes restores the SAML value as active, shown by activeSource saml in the response.

Example prompt: Call GET `/v2026-04-27/organizations/{organizationId}/users/{sanityUserId}/attributes` to read the location attribute, then DELETE the same path with attributes [{key: 'location'}] and confirm activeSource is saml

### Managing the attribute schema

Before values can be relied on, an organization agrees its attribute keys and types. createAttributeDefinition adds an API-managed key with a type, returning alreadyExists when it was already there, and is refused with 403 when a SAML definition exists for that key. deleteAttributeDefinition removes a key only when it is API-managed and no user holds a value for it, otherwise it fails with 409.

Example prompt: GET `/v2026-04-27/organizations/{organizationId}/attribute-definitions`, then POST the same path with key year_started and type integer if it is not listed

## Key endpoints

| Method | Path | Description |
| --- | --- | --- |
| GET | `/v2026-04-27/organizations/{organizationId}/attribute-definitions` | List attribute definitions |
| POST | `/v2026-04-27/organizations/{organizationId}/attribute-definitions` | Create an attribute definition |
| GET | `/v2026-04-27/organizations/{organizationId}/users/{sanityUserId}/attributes` | Get a user's attributes |
| POST | `/v2026-04-27/organizations/{organizationId}/users/{sanityUserId}/attributes` | Set a user's attribute values |
| DELETE | `/v2026-04-27/organizations/{organizationId}/users/{sanityUserId}/attributes` | Delete a user's attribute values |
| GET | `/v2026-04-27/organizations/{organizationId}/users/me/attributes` | Get your own attributes |

## Key resources

- **Attribute definitions** — Organization-level keys with a type and the sources, saml or sanity, that define them
- **User attributes** — Per-user values from each source, with the activeSource and activeValue in effect

## 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:** 70 / 100
- **Maturity:** AI-Aware
- **Dimensions:**
  - Foundational Compliance: 74 / 100
  - Developer Experience & Jentic Compatibility: 70 / 100
  - AI-Readiness & Agent Experience: 55 / 100
  - Agent Usability: 94 / 100
  - Security: 60 / 100
  - AI Discoverability: 98 / 100
- **View full report:** https://jentic.com/apis/sanity.io/sanity-user-attributes/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 User Attributes API by hand means pinning the v2026-04-27 path prefix, sending a bearer token, and handling the 403 and 409 rules around SAML definitions and in-use keys. 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 organization id and the user id in the URL path (`/organizations/{organizationId}/users/{sanityUserId}/...`), so a rule can pin your agent to one organization, or one user, and the operations you pick. You choose the operations it may call, so destructive ones like deleteAttributeDefinition or deleteUserAttributes are not included unless you add them.
- **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 'set Sanity user attributes' or 'list Sanity attribute definitions', and Jentic returns the matching operation, such as updateUserAttributes or listAttributeDefinitions, with its input schema.

## Related APIs

- **Sanity Roles API** — Roles, grants, and SAML role mappings for Sanity projects
- **Sanity Projects API** — Manage the projects and members of a Sanity organization
- **Okta API** — Identity provider that manages user profile attributes
- **Auth0 Management API** — Manage user metadata and roles in your own application

## FAQ

### What authentication does the Sanity User Attributes API use?

Per its OpenAPI spec, the API uses a bearer token, a personal or robot Sanity API token, in the Authorization header. Listing attribute definitions also requires the sanity.organization.manage permission. Through Jentic the token is stored by your own instance and attached at call time.

### How do SAML and Sanity attribute values interact?

An attribute key can have a value from SAML single sign-on, from this API, or both. When both exist, the Sanity value takes precedence and shadows the SAML one, while the values object still shows both. Each attribute reports activeSource and activeValue, and deleting the Sanity value makes the SAML value active again.

### Can I create SAML attribute definitions with this API?

No. createAttributeDefinition only creates API-managed Sanity definitions; SAML definitions are created automatically during SSO authentication. Creating a Sanity definition for a key that already has a SAML definition returns 403, and a definition can only be deleted when it is API-managed and no user holds a value for it.

### What are the rate limits for the Sanity User Attributes 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 User Attributes API. Jentic connects it directly from the API Directory: import it, store your Sanity token once, and your agent calls the attribute operations it needs without loading a separate server's tool definitions.

### How do I set a user's attributes through Jentic?

Search Jentic for 'set Sanity user attributes', load the updateUserAttributes operation, and execute POST `/v2026-04-27/organizations/{organizationId}/users/{sanityUserId}/attributes` with an attributes array of key and value pairs. 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 User Attributes API?

Yes. A rule that allows only the two GET attribute operations under `/v2026-04-27/organizations/or0Bc1hcJ` lets the agent read user attributes in that organization, while setting values, deleting values, and changing definitions stay off its list. Every call it makes is logged.
