Security
Trusted issuer token exchange
A trusted issuer gets tokens from one endpoint, POST /auth/authority/token on https://api2.cursor.sh. The endpoint keeps its cursor.sh host. It accepts two grants:
- JWT bearer. Your backend signs one assertion, and gets an access token.
- Refresh token. A client presents a refresh token from an earlier exchange, and gets a new access token and a new refresh token. The issuer must have refresh tokens turned on.
Requests are form-encoded. Responses are JSON and must not be cached.
The JWT bearer grant is the RFC 7523 JWT bearer grant. The grant type is urn:ietf:params:oauth:grant-type:jwt-bearer, and the request carries one signed JWT in the assertion field, not client_assertion. The endpoint refuses any other grant type.
Signing keys
Register a public key for the issuer before the first exchange. See Set up an issuer.
| Algorithm | Key type | Required JWK members |
|---|---|---|
RS256 | RSA, 2048 bits or more | kty, alg, use, n, e |
ES256 | EC, curve P-256 | kty, alg, use, crv, x, y |
- Set
usetosigandalgto the algorithm in the table. - Leave out
kid. Grok Build assigns each key a key ID and shows it in the issuer's key list. Put that ID in thekidheader of every JWT you sign with the key. - Register the public key only. A JWK with private key members, or with members other than those listed, is refused.
Sign the assertion
Your backend signs one JWT for each exchange, with a key registered for the issuer. The assertion authenticates the request as coming from your issuer and names who the token acts as (sub), the scopes you want, and the mint mode. It lasts at most 60 seconds.
Set alg to the algorithm of the registered key, kid to its key ID, and typ to authority-subject-assertion+jwt:
JSON
{
"alg": "ES256",
"kid": "YOUR_KEY_ID",
"typ": "authority-subject-assertion+jwt"
}
Assertion claims, for a token that signs a member in to the CLI. The sub is an example user ID:
JSON
{
"iss": "YOUR_CLIENT_KEY",
"sub": "user_PDSPmvukpYgZEDXsoNirw3CFhy",
"aud": "https://api2.cursor.sh/auth/authority/token",
"scopes": ["cli:session"],
"iat": 1767225600,
"exp": 1767225660,
"jti": "UNIQUE_ASSERTION_ID",
"cursor_mint_mode": "member"
}
| Claim | Required | Value |
|---|---|---|
iss | Yes | The issuer's client key. |
sub | Yes | Who the token acts as, not the client key. See Subject and mint mode. |
aud | Yes | https://api2.cursor.sh/auth/authority/token, as one string and not an array. |
iat, exp | Yes | Whole seconds. exp can be at most 60 seconds after iat. |
jti | Yes | Accepted once. |
scopes | Yes | An array of one or more scope names, with no duplicates. Each must be one of the mode's scopes. |
cursor_mint_mode | No | member, team, or service_token. Defaults to member. |
The assertion follows these rules:
- The header can contain only
alg,kid, andtyp. - The JWT can be at most 8 KiB.
- Grok Build allows 30 seconds of clock skew. An
iatmore than 30 seconds in the future is refused, and so is a JWT more than 30 seconds past itsexp. - A
jtican't be reused. Sign a fresh assertion for every exchange. - Keep your server's clock in sync. A drifting clock causes
invalid_grant.
Subject and mint mode
The assertion's cursor_mint_mode and sub claims go together. The issuer must allow the mode you name.
cursor_mint_mode | Dashboard mode | sub |
|---|---|---|
member, or left out | On behalf of a member | The member's user ID. It's the id that the Admin API's Get Team Members endpoint returns, in its user_… form. |
team | Team-level | The numeric ID of a team that is the owner, or that belongs to the owning organization, as a string. |
service_token | Admin-owned service token | The public ID of a live API key that belongs to a team service account inside the owner. |
In member mode, pass the user_… ID as you received it. Grok Build decodes it and checks the user against the issuer's owner:
- On a team's issuer, the user must be a member of that team, or an admin of the organization the team belongs to.
- On an organization's issuer, the user must be a member of that organization.
A sub that doesn't decode to a user, or that names a user outside the owner, is refused with invalid_grant.
Only a team's issuer can mint cli:session. The CLI session always runs in that team. An organization's issuer that asks for cli:session is refused with invalid_scope.
A token from another trusted issuer exchange can't be the source of a service_token exchange.
Token request
Post the assertion as a form. The values below are placeholders, not real credentials:
Bash
curl -X POST https://api2.cursor.sh/auth/authority/token \
-d grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer \
-d client_id=authority_client_EXAMPLE \
-d assertion=SIGNED_ASSERTION_JWT \
-d expires_in=900
| Field | Required | Description |
|---|---|---|
grant_type | Yes | urn:ietf:params:oauth:grant-type:jwt-bearer. |
client_id | Yes | The issuer's client key. |
assertion | Yes | The signed assertion JWT. |
expires_in | No | A shorter token lifetime than the mode's maximum, as a positive whole number of seconds. |
Token response
JSON
{
"access_token": "ACCESS_TOKEN_REDACTED",
"token_type": "Bearer",
"expires_in": 899,
"scope": "cli:session"
}
| Field | Description |
|---|---|
access_token | An opaque token. It isn't a JWT, so don't parse it. |
token_type | Always Bearer. |
expires_in | Seconds until the token expires. It's never more than 3,600, the mode's maximum, or the expires_in you sent, and it can be a second lower than you asked for. |
scope | A space-separated list of the scopes the token carries. |
refresh_token | Present only on member-mode exchanges, when the issuer has Issue refresh tokens turned on. |
Use a cli:session token as the API key of the CLI or SDK. See CLI sign-in. Send a token with team or organization scopes as a Bearer token on API requests:
Bash
curl https://api.cursor.com/teams/members \
-H "Authorization: Bearer ACCESS_TOKEN_REDACTED"
Refresh an access token
When the issuer has refresh tokens turned on, a client can renew without your backend:
Bash
curl -X POST https://api2.cursor.sh/auth/authority/token \
-d grant_type=refresh_token \
-d refresh_token=REFRESH_TOKEN_REDACTED
| Field | Required | Description |
|---|---|---|
grant_type | Yes | refresh_token. |
refresh_token | Yes | The newest refresh token from this chain. |
scope | No | A space-separated subset of the scopes a refresh would return, to narrow this one access token. It doesn't narrow later refreshes. |
The response has the same fields as a token response, and always includes a new refresh_token.
- No client proof. The request carries no
client_idand no JWT. The refresh token alone is the credential, so anyone who holds it can use it. - Scopes. Without
scope, a refresh returns every scope that member mode allows for the member. That can be more than the first access token carried, if your assertion asked for fewer scopes than the mode allows. - Rotation. Each refresh token works once. Store the new one before you use the new access token. Access tokens issued earlier keep working until they expire.
- One chain for each exchange. Each member-mode exchange starts its own refresh chain. Earlier chains for that member keep working until their refresh tokens expire or the grant ends.
- Reuse revokes the member's tokens. A client that got no response can send the same refresh token again within 60 seconds. After that, presenting a replaced refresh token revokes the member's grant: every refresh token and access token the issuer minted for that member stops working. Exchange a new assertion to start again.
- Lifetime. Each new refresh token lasts for the issuer's Maximum refresh token lifetime, 30 days at most, and never past the end of the grant. A client that keeps refreshing can continue until the grant expires.
- Checks on every refresh. Grok Build checks again that the issuer is enabled, refresh tokens are still on, and the member still belongs to the owner. It leaves out any scope that member mode no longer allows, and refuses the refresh if none are left. It also applies tenancy restrictions and IP allowlists.
Errors
Errors use the OAuth 2.0 error format:
JSON
{
"error": "invalid_scope",
"error_description": "DESCRIPTION"
}
The wording of error_description can change, so branch on error.
| Status | error | Cause | What to do |
|---|---|---|---|
400 | invalid_request | client_id or assertion is missing, or expires_in isn't a positive whole number. The request also sends a subject_token field, which this endpoint doesn't accept. On a refresh, refresh_token is missing. | Fix the request. Send only client_id, assertion, and an optional expires_in. |
400 | unsupported_grant_type | grant_type isn't one of the two grants. | Fix the request. |
400 | invalid_grant | The assertion has a bad signature, a missing or wrong claim, a lifetime that is too long or has expired, or a reused jti. Or the sub doesn't name a user, team, or key inside the issuer's owner. In team-level and service token modes, also when scopes is empty or asks for more than the mode, the team, or the key allows. On a refresh, the refresh token is invalid, expired, or was already used, or the issuer no longer allows refresh. | Check your claims and clock, then sign a new assertion. Check that the member still belongs to the team or organization. |
400 | invalid_scope | scopes includes a scope the mint mode can't carry, or one that is never available, such as agent:*. Or an issuer that isn't owned by a team asks for cli:session. In member mode, also when scopes is empty or includes a scope an admin didn't select for the mode. On a refresh, scope asks for more than was granted. | Request fewer scopes, or ask an admin to add the scope to the mode. For cli:session, use a team's issuer. |
401 | invalid_client | The client key is unknown, the issuer is disabled or revoked, or it has no registered key. The response carries a WWW-Authenticate: Bearer header. | Check the client key, the issuer's status, and its keys. |
403 | mint_mode_not_enabled | The assertion names a mint mode the issuer doesn't allow. | Ask an admin to allow the mode, or use one the issuer allows. |
403 | access_denied | A team the member belongs to doesn't allow tokens to be minted on behalf of its members. | Ask that team's admin to turn on Allow personal API key creation, or stop exchanging for this member. |
403 | team_ip_allowlist_violation | The request came from an address that isn't on a required IP allowlist. Member mode checks the lists of the member's teams and organization. The other modes check the issuer owner's list. | Call from an address on that list, or ask its admin to add your backend's egress addresses. |
403 | tenant_restriction_violation | Your network adds a tenancy restriction to the request, and it doesn't allow the member's account. | Exchange for an account the restriction allows, or update the restriction. |
429 | Too many requests from one address, for one issuer, or for one subject. | Slow down, then retry with backoff. | |
503 | temporarily_unavailable or team_ip_allowlist_unavailable | Grok Build couldn't complete a check, or the exchange is temporarily unavailable. | Retry with backoff. |
invalid_grant returns the same description for every assertion cause, and invalid_client does the same. Check the assertion rules and the issuer's status when you see them.
Related
Last updated: December 3, 2026