Authentication Error with App Store Server API (NOT_AUTHORIZED) while Using JWT for Subscription Validation

Hello Apple Developer Community,

We are currently facing an authentication issue when calling the App Store Server API for subscription validation. Despite following Apple’s documentation and verifying all credentials, we consistently receive a NOT_AUTHORIZED error response. GET https://api.storekit-sandbox.itunes.apple.com/inApps/v1/transactions/appTransactions/{transactionId}

Environment: Sandbox and Production (both tested, same result) Our Setup:

Key ID: {Your Key ID} Issuer ID: {Your Issuer ID} Bundle ID: {Your Bundle ID}

JWT Header: { "alg": "ES256", "kid": "<KeyID>" }

JWT Payload: { "iss": "<IssuerID>", "iat": <current timestamp>, "exp": <timestamp + 5 minutes>, "aud": "appstoreconnect-v1", "bid": "<bundleID>" }

Authorization Header: Authorization: Bearer <JWT Token>

Troubleshooting Steps Already Taken:

Verified that .p8 key, Key ID, Issuer ID, and Bundle ID are all correctly configured and match the App Store Connect details.

Confirmed that the system clock is accurate (UTC).

Used appropriate endpoint (sandbox or production) based on environment.

Ensured that the JWT is short-lived (under 5 minutes).

Added the “Bearer” prefix correctly in the header.

Tested JWT generations using Python.

Issue: All requests return: { "errorCode": "NOT_AUTHORIZED" }

Questions:

Are there any additional claims or headers required for the subscriptions endpoint?

Are there specific permissions or roles needed for the API key in App Store Connect?

Is there a way to get more detailed logs or diagnostics for this NOT_AUTHORIZED response?

Does the App Store Server API require a different aud or bid structure for certain endpoints?

We already contacted Apple Developer Support, but they suggested posting here for engineering-level guidance. Any insight or examples of a working JWT + request for this endpoint would be greatly appreciated.

The problem is almost certainly your aud claim. You're using "aud": "appstoreconnect-v1", which is the audience value for the App Store Connect API, not the App Store Server API. For the App Store Server API, the audience should be "appstoreconnect-v1" but the key itself needs to be an In-App Purchase key (generated under Users and Access > Integrations > In-App Purchase in App Store Connect), not an App Store Connect API key. Make sure you're generating the key from the correct section, because even though the JWT structure looks similar, the two key types are not interchangeable and using the wrong one will always return NOT_AUTHORIZED.

Authentication Error with App Store Server API (NOT_AUTHORIZED) while Using JWT for Subscription Validation
 
 
Q