The JWT aud claim (short for "audience") names the service or services a token is meant for. A service that receives the token must find its own identifier in aud, and if it doesn't, it must reject the token. That rule stops a token issued for one app from being replayed against another.
What the JWT aud claim means
The aud claim is the address line on a token: it lists the recipients the JWT is intended for. RFC 7519 defines it as a registered claim and puts the burden on the receiver. Each service meant to process the token must identify itself with a value in the audience claim.
If aud is present and the service processing the token doesn't find itself in it, the JWT must be rejected.
Two more details from the same section matter in practice:
- The values are application specific. An audience can be a URL like
https://api.example.com, a client ID, or a URN. The spec doesn't care which, as long as both sides agree. - The claim is optional in the base spec. Plenty of tokens skip it. The profiles most people use make it mandatory.
A decoded payload with an audience looks like this:
{
"iss": "https://auth.example.com/",
"sub": "user_8213",
"aud": "https://api.example.com"
}
String or array: the two shapes of aud
The aud value comes in two shapes, and code that handles only one of them breaks on the other. According to RFC 7519, the general form is an array of case-sensitive strings. When a token has exactly one audience, aud may be a single string instead.
So both of these are valid:
"aud": "https://api.example.com"
"aud": ["https://api.example.com", "https://reports.example.com"]
The token is acceptable if your service's identifier equals any one of the values. Matching is exact and case-sensitive. https://api.example.com and https://api.example.com/ are different strings, and so are Orders-API and orders-api.
If you write your own check, normalise first: turn a string into a one-item list, then test membership. Better still, let your JWT library do it.
How the aud claim protects you
The audience check exists to block substitution, where a valid token meant for one service gets used at another. RFC 8725, the JWT best practices document, calls this cross-JWT confusion: a token issued for one purpose being subverted and used for another.
Picture one login server that issues tokens for two internal APIs, billing and support. Both trust the same signing key. Without an audience check, a token a support agent received for the support API also passes signature checks at the billing API. With aud set and checked, billing sees "aud": "support-api" and refuses it.
RFC 8725 turns this into a rule. If one issuer can issue JWTs for more than one relying party, the JWT must contain aud. The receiver must validate it and reject the token if the audience is missing or not its own. The same document also advises using different aud values for different uses of JWTs from the same issuer.
What aud should contain for each token type
The right aud value depends on which kind of token you're looking at. The base spec leaves it open, but the two big profiles pin it down.
| Token type | Is aud required? | What aud holds | Who checks it |
|---|---|---|---|
| OpenID Connect ID token | Yes | The client_id of the app that asked for the login | The client app |
| OAuth 2.0 JWT access token | Yes | An identifier for the API (resource server) | The API |
| Internal service-to-service token | Optional in the spec | A name you choose per receiving service | The receiving service |
For ID tokens, OpenID Connect Core says aud is required and must contain the client_id of the relying party. It may contain other audiences too. The client must reject the token if it isn't listed, or if the token contains additional audiences the client doesn't trust. That second rule is easy to miss: finding yourself in the list is not enough under OpenID Connect.
For access tokens, RFC 9068 makes aud required as well. The API must check that aud contains an identifier it expects for itself, and reject the token otherwise. When the client asks for a specific resource, the resulting aud should match that resource value.
This is why sending an ID token to your API is a classic bug. The ID token's audience is your front-end's client ID, not the API, so a correct API rejects it.
aud vs iss vs azp
aud names the receiver, iss names the issuer, and azp names the party a token was issued to.
- iss (issuer): who created and signed the token, such as your login server.
- aud (audience): who should accept the token, such as your API.
- azp (authorized party): an OpenID Connect claim for the party the ID token was issued to. The spec marks it optional and encourages implementations not using extensions to ignore it.
A verifier normally checks iss and aud together. The first proves where the token came from. The second proves it was meant for you. The three parts of a JWT shows where each claim sits.
Debugging a "jwt audience invalid" error
An audience error means the value your code expects doesn't exactly match anything in the token's aud. The fastest fix is to read the token's real aud and compare it character by character with your configured value.
A Node.js API verifies tokens with the jsonwebtoken package and passes audience: "https://api.example.com/". Requests fail with the error the package's README documents:
JsonWebTokenError: jwt audience invalid. expected: https://api.example.com/
Work through it in order:
- Decode the failing token and read
aud. Here it says"https://api.example.com", with no trailing slash. - Compare exactly. The only difference is the slash, and matching is exact, so the check fails.
- Fix the config, not the check. Set the expected audience to the value the issuer really uses, or register the API identifier consistently on the login server.
- If several audiences are valid, pass a list. The jsonwebtoken
audienceoption accepts a string, a regular expression, or a list of strings and regular expressions.
Python gives the same signal with different words. In PyJWT, a wrong audience raises jwt.InvalidAudienceError. The audience argument to jwt.decode can also be an iterable when you accept more than one. A token with "aud": ["urn:foo", "urn:bar"] decodes with either urn:foo or urn:bar as the expected value.
If the slash isn't the problem, check these:
- The login flow never asked for your API, so
audholds the client ID. - Your front-end sent the ID token instead of the access token.
- A staging token hit production, where the API identifier differs.
Common mistakes with the aud claim
Most audience problems come from treating aud as something it isn't. These are the ones I see most often in reviews.
- Skipping the check entirely. A valid signature only proves who signed the token, not who it was for. Always pass an expected audience to your library's verify call.
- Putting roles in aud.
auddecides which service accepts the token. Permissions inside that service belong in scopes or role claims you check afterwards. - One audience for everything. If every service accepts
"aud": "internal", the check protects nothing. Give each receiver its own value. - Handling only strings. A hand-written
payload.aud === expectedfails silently as soon as a token arrives with an array. - Trusting a decoded aud. Reading
audin a decoder is fine for debugging, but the value means nothing until the signature is verified. Decoding vs verifying a JWT covers why.
My take: set aud on every token you issue, even with only one API today. It costs one line now and saves a painful migration the day a second service trusts the same key.
Checking the aud claim in a token you have
To see a token's audience, decode its payload; you don't need the signing key for that. Paste it into the JWT decoder, which shows the header, payload and signature, and flags whether iat and exp make it expired. It runs in your browser.
The limitation: that decoder only reads the token. It does not verify the signature, and it won't tell you whether aud matches your service. Use it to spot the mismatch, then do the real check in your server code. Related reading: decoding a JWT without the secret and the iat claim.
FAQ
Is the aud claim required in a JWT?
Not by the base JWT specification, which makes aud optional. Profiles built on it are stricter: OpenID Connect requires aud in ID tokens, and the JWT profile for OAuth 2.0 access tokens requires it too.
Can aud be an array?
Yes. In the general case aud is an array of case-sensitive strings. When a token has exactly one audience, aud may be a single string instead, so your code has to accept both forms.
What is the difference between aud and iss?
iss names who created and signed the token. aud names who the token is meant for. A verifier usually checks both: the token must come from a trusted issuer and be addressed to this service.
Why do I get 'jwt audience invalid'?
The value your verifier expects doesn't exactly match any value in the token's aud. Common causes are a token issued for a different API, an ID token sent where an access token was expected, or a small mismatch such as a trailing slash or different case.
Should I put roles or permissions in aud?
No. aud says which service may accept the token. Who may do what inside that service belongs in other claims, such as scopes or roles that your service checks after it accepts the audience.