Launch offer for the first 500 accounts: $10K MTR free for 24 months + $100 credit →
    .io
    All Store server notifications and APIs fixes
    Store server notifications and APIs
    November 12, 2026
    3 min read

    App Store Server API returns 401 Unauthenticated

    A 401 from the App Store Server API means Apple rejected your JWT, not your request. The header needs alg ES256 and kid set to your In-App Purchase key ID. The payload needs iss (your issuer ID), aud appstoreconnect-v1, bid (the app's exact bundle ID), iat set to now, and exp no more than 60 minutes later. Decode the token and compare each field.

    Symptom

    • Every request returns 401 Unauthenticated, often with an empty body.
    • It worked once, then started failing after an hour.
    • It works for one app and not another in the same account.

    Why it happens

    Apple validates every request's bearer token. Any wrong field gives the same 401:

    Cause How to tell
    Wrong key type: an App Store Connect API key instead of an In-App Purchase key kid belongs to a key listed under App Store Connect API, not In-App Purchase
    bid missing or not the app's bundle ID Decoded payload has no bid, or a different bundle ID
    aud isn't appstoreconnect-v1 Decoded payload shows another value
    exp more than 60 minutes after iat, or the token expired It fails after an hour, or every time with a long lifetime
    Server clock wrong iat is in the future or far in the past
    Signed with the wrong .p8, or not ES256 Header alg isn't ES256, or the key doesn't match kid
    Key revoked The key shows as revoked in App Store Connect

    Confirm it

    1. Decode the token you're sending (it's three base64url parts):
    echo "$JWT" | cut -d. -f1 | base64 -d 2>/dev/null; echo
    echo "$JWT" | cut -d. -f2 | base64 -d 2>/dev/null; echo
    
    1. Check the header: alg: ES256, kid: <In-App Purchase key ID>, typ: JWT.
    2. Check the payload: iss (Issuer ID from Users and Access → Integrations), iat, exp, aud: appstoreconnect-v1 and bid: <bundle ID>.
    3. Compare iat with the current Unix time (date +%s).
    4. In App Store Connect, open Users and Access → Integrations → In-App Purchase and check the key ID exists and isn't revoked.

    Fix

    1. Create or use an In-App Purchase key, and sign with its .p8 using ES256.
    2. Put the right values in the token: kid in the header; iss, iat, exp, aud: appstoreconnect-v1 and bid in the payload.
    3. Keep the lifetime at 60 minutes or less, and make a new token before the old one expires.
    4. Sync the server clock with NTP.
    5. If the key was revoked or leaked, generate a new one and update every server that uses it.

    Stop it coming back

    • Build tokens in one function with a unit test that decodes the result and checks each claim.
    • Log the decoded header and payload (never the key) when a 401 happens.

    If you use BillDog

    BillDog builds and signs these tokens for you from the In-App Purchase key you save in Project Settings → Store → Apple App Store (step 5.2 in the setup guide), so you don't write JWT code. If verification fails there, BillDog's guide lists the same checks:

    • The In-App Purchase key is saved, not only the App Store Connect API key.
    • The .p8 contents are complete, including the BEGIN and END lines.
    • The Issuer ID, Key ID, Bundle ID and Apple ID match exactly.
    • The key isn't revoked.

    See App Store Connect setup.

    Related

    Sources

    Did this fix it?

    Frequently asked questions

    Can I use my App Store Connect API key for the App Store Server API?

    Use the In-App Purchase key for the App Store Server API. It's a different key, created under Users and Access → Integrations → In-App Purchase, and its token needs the bid claim with your app's bundle ID.

    How long can the token live?

    Apple rejects tokens whose exp is more than 60 minutes after iat. Generate a new token at least hourly, and keep your server's clock in sync.

    Does a 401 mean I hit the wrong environment?

    Not usually. A transaction looked up in the wrong environment comes back as not found, not 401. A 401 is about the token itself.

    Related Articles

    Store server notifications and APIs
    3 min read

    App Store Server Notifications v2 aren't arriving

    November 11, 2026
    November 14, 2026

    We use cookies and process your data to provide our services. By continuing, you agree to our Terms and Privacy Policy.