Skip to contentSkip to navigationSkip to topbar
Page tools
Useful for sharing or LLM
Accelerate development with AI

On this page
Looking for more inspiration?Visit the

Issue Trusted Auth Tokens


(new)

Private Beta

Agent Identity is available as a Private Beta product, and the information contained in this document is subject to change. You acknowledge and agree that your use of Agent Identity is subject to the terms of the Services in Private Beta(link takes you to an external page). Some features are not yet implemented and others may change before the product is declared as Generally Available. Private Beta products are not covered by the Twilio Support Terms or Twilio Service Level Agreement.

The Trusted Auth Token (TaT) flow is how Agent Identity delegates user authentication back to your existing system. Your system authenticates the user, signs a short-lived JWT that describes them, and posts it back to Agent Identity. Agent Identity validates the token, starts a session, and continues the OAuth flow.


The Trusted Auth Token flow

the-trusted-auth-token-flow page anchor
  1. A user tries to complete an action that needs authentication, usually an OAuth authorization request. Agent Identity redirects the user into the TaT flow.
  2. Agent Identity generates a one-time nonce, stores it in a cookie on the user's device, and redirects the user to your Authentication URL with the nonce as a query parameter.
  3. Your system authenticates the user with whatever mechanism you use today.
  4. Your system signs a Trusted Auth Token that includes the required claims, including the nonce.
  5. Your system redirects the user back to the Agent Identity callback URL using a form post, with the token in the request body.
  6. Agent Identity validates the token, issues a short-lived session cookie, and returns the user to the flow they started.

Trusted Auth Token schema

trusted-auth-token-schema page anchor

Claims

claims page anchor

The following claims are required:

ClaimTypeDescription
issstringMust match the Issuer you set in the Console.
audstringMust match the Audience shown in the Console. Must be a string value.
substringA unique, stable identifier for the user in your system.
expnumberExpiration time, in Unix seconds.
iatnumberIssued-at time, in Unix seconds.
noncestringThe value Agent Identity passed to your Authentication URL.

Beyond these required claims, the following user data claims are optional. In the JWT, prefix each optional claim name with https://ciam.twilio.com/ (for example, https://ciam.twilio.com/scopes). See the sample token below.

ClaimTypeDescription
user_display_namestringA human-readable display name for the user, shown on the consent screen.
scopesstringA space-delimited list of scopes this user is allowed to grant. A user can grant a client only the scopes present here. If omitted, the user can only grant the built-in OIDC scopes.
authorization_details_typesstringA space-delimited list of Rich Authorization Request types this user may grant.
access_token_claimsobjectThe custom claims added to every access token issued for this user.
id_token_claimsobjectThe custom claims added to every ID token issued for this user.
userinfo_claimsobjectThe custom claims returned from the UserInfo endpoint for this user.
(information)

Info

Reserved claims (sub, iss, aud, exp, iat, nbf, jti, and other standard OIDC claims) are set automatically by Agent Identity and can't be overridden. If you include a reserved claim name in your custom data, the system-assigned value takes precedence and your value is ignored.

Sign the token with RS256.

Header

1
{
2
"alg": "RS256"
3
}

Body

1
{
2
"iss": "https://ciam.example.com",
3
"aud": "https://auth.example.com",
4
"sub": "USER_12345",
5
"exp": 1735689600,
6
"iat": 1735689300,
7
"nonce": "NONCE_FROM_QUERY_PARAM",
8
9
"https://ciam.twilio.com/user_display_name": "Jo Smith",
10
"https://ciam.twilio.com/scopes": "openid offline_access orders:read",
11
"https://ciam.twilio.com/authorization_details_types": "purchase refund",
12
13
"https://ciam.twilio.com/access_token_claims": {
14
"email": "jo@example.com"
15
},
16
"https://ciam.twilio.com/id_token_claims": {
17
"email": "jo@example.com"
18
},
19
"https://ciam.twilio.com/userinfo_claims": {
20
"https://example.com/claims/tier": "gold"
21
}
22
}

How Agent Identity validates the token

how-agent-identity-validates-the-token page anchor

Agent Identity accepts the token only when all of the following hold:

  • The iss claim matches your configured Issuer.
  • The aud claim matches your instance's Audience.
  • The exp claim is in the future (the token hasn't expired).
  • The nonce matches the value stored in the user's cookie and hasn't been used before.

When validation succeeds, Agent Identity extracts the user's sub and other claims and stores them on the user record. A later sign-in that carries new values (for example, an updated email) updates the stored record.