- App Store
- Mobile apps
- Node.js
- Backend
App Store Connect API key: setup, roles and 401 fixes
Create an App Store Connect API key, pick the right role, find the issuer ID and key ID, and fix 401 NOT_AUTHORIZED with a local token check script.
- Author
- Extenify Team
- Published
- Reading time
- 14 min read

On this page
An App Store Connect API key is what lets a script read your app's reviews, download analytics and sales reports, watch a phased release or receive webhooks without anyone logging in. Creating one takes two minutes. Getting the first request to succeed can take an afternoon, because Apple answers almost every mistake with the same error: 401 NOT_AUTHORIZED, "Authentication credentials are missing or invalid."
We confirmed that in November 2026 by sending seven different broken tokens to the API. A token with an unknown key, one that lived too long, one already expired, one with the wrong audience, one with the wrong signature encoding, a garbage string and no token at all all came back with the identical 401 body. The error tells you that something is wrong, never what. This guide covers how to request access, which kind of key and role to create, where the issuer ID and key ID live, how to sign a token, and a Node.js script that checks everything Apple will not tell you before it makes one real call.
Key takeaways
- The Account Holder must first request API access under Users and Access > Integrations. Apple reviews requests "on a case-by-case basis."
- Team keys need an Admin to create and cover all apps; their role cannot be changed later. Individual keys follow one user's access and cannot reach sales and finance reports.
- The
.p8private key downloads once. "Apple doesn't keep a copy."- Tokens use ES256,
aud: "appstoreconnect-v1", and must not live more than 20 minutes for most requests. Individual keys usesub: "user"instead ofiss.- A 401 means Apple did not accept the key ID, issuer ID and private key together. A 403 means the key is known but revoked or its role does not allow the request.
Team key or individual key?
Apple's guide to creating API keys defines two kinds:
| Team key | Individual key | |
|---|---|---|
| Access | All apps, limited by the key's role | The apps and permissions of one user |
| Who creates it | Account Holder or Admin | Any user with the Generate Individual API Keys permission |
| JWT identity claim | iss: your issuer ID |
sub: "user" |
| Sales and finance reports | Yes, with a suitable role | No |
| How many | As many as you need | One active key per user |
Use a team key for anything that runs on a server: review alerts, analytics downloads, release checks. Apple's App Store Connect help notes that "team API keys are applied across all apps, so app access can't be limited for an API key." If you need a key that only sees one app, the only route is an individual key belonging to a user who only has access to that app.
Step 1: Request API access
Nothing appears until the Account Holder has asked for access. In App Store Connect, the Account Holder opens Users and Access, clicks Integrations, clicks Request Access, agrees to the terms and submits. Apple says requests are "reviewed and approved on a case-by-case basis."
This is the usual reason people report that the keys tab is missing. If you are an Admin and see a request button instead of a key list, the Account Holder has not requested access yet. If you are not an Admin, you will not be able to generate team keys at all, and the individual Generate API Key button "won't show on your profile" unless an Admin has given you the Generate Individual API Keys permission.
Step 2: Generate an App Store Connect API key and pick its role
- Open Users and Access > Integrations > App Store Connect API, then Team Keys.
- Click Generate API Key (or + if you already have keys).
- Enter a name. It is "for your reference only and isn't part of the key."
- Under Access, choose a role.
- Click Generate.
The role is permanent: "Once you generate an API key, you can't edit its name or access level. If you need to make changes, revoke the key and generate a new one." Apple says key roles are "the same roles that apply to users on your team", and points out that keys with the Admin role "have broad permissions and can do things like create new users and delete users." That is a lot of power for a script that only reads reviews.
Choose the narrowest role for each job, and use one key per job so you can revoke one without breaking the others:
| Job | Role to start with | Source |
|---|---|---|
| Download analytics reports | Admin once to create the report request, then Sales and Reports for daily downloads | Apple's analytics reports guide |
| Download sales reports | Sales and Reports (it cannot read finance reports) | Same guide |
| Download finance reports | Finance | Same guide |
| Read and answer customer reviews | Customer Support, which Apple describes as the role that "analyzes and responds to customer reviews" | Role descriptions |
| Manage releases, phased release, builds | App Manager or Developer | Same page |
Our App Store Connect analytics API guide walks through the Admin-then-Sales-and-Reports split in detail.
Step 3: Save the issuer ID, key ID and private key
You need three values, all from the same page:
- Issuer ID. A UUID such as
57246542-96fe-1a63-e053-0824d011072a, shown "near the top of the page" under Integrations, with a Copy button. It is the same for every team key, and it is not your Team ID. - Key ID. Shown next to each active key, such as
2X9R4HXF34. Hover next to it for Copy Key ID. - Private key. Click Download API Key. "The download link only appears if you haven't downloaded the private key. Apple doesn't keep a copy of the private key." The file is named after the key ID,
AuthKey_2X9R4HXF34.p8.
Put the .p8 straight into your secrets manager. Apple's guidance is blunt: "Don't share your keys, store keys in a code repository, or include keys in client-side code." If you lose it, revoke the key and create a new one.
Step 4: Sign a token
Apple's token guide lists every field:
| Part | Field | Value |
|---|---|---|
| Header | alg |
ES256, always |
| Header | kid |
Your key ID |
| Header | typ |
JWT |
| Payload | iss |
Issuer ID (team keys only) |
| Payload | sub |
"user" (individual keys only, instead of iss) |
| Payload | iat |
Now, in Unix seconds |
| Payload | exp |
No more than 20 minutes after iat for most requests |
| Payload | aud |
appstoreconnect-v1 |
| Payload | scope |
Optional list of allowed requests, such as GET /v1/apps?filter[platform]=IOS |
Two rules cause most trouble. First, the lifetime: Apple calculates it as exp minus iat and "rejects a token with a lifetime greater than 20 minutes" for most requests. Longer tokens, up to six months, are only accepted when the token has a scope, the scope contains only GET requests, and every resource in it allows long-lived tokens, which mostly means Xcode Cloud and performance metrics resources. Second, the signature: an ES256 JWT carries the raw 64-byte r||s signature, while many crypto libraries return DER by default. A developer on the Apple Developer Forums traced a stubborn 401 to exactly that: "I was using DER-encoded bytes in the JWT signature, not raw bytes."
A JWT library handles the encoding for you. With jose in Node.js:
// asc-token.mjs: sign a 15-minute App Store Connect API token with jose.
import { readFile } from 'node:fs/promises';
import { SignJWT, importPKCS8 } from 'jose';
export async function ascToken({ keyId, issuerId, keyPath }) {
const key = await importPKCS8(await readFile(keyPath, 'utf8'), 'ES256');
const claims = issuerId ? { iss: issuerId } : { sub: 'user' };
return new SignJWT(claims)
.setProtectedHeader({ alg: 'ES256', kid: keyId, typ: 'JWT' })
.setIssuedAt()
.setExpirationTime('15m')
.setAudience('appstoreconnect-v1')
.sign(key);
}
Apple also says you "don't need to generate a new token for every API request". Reuse one until shortly before it expires, then sign a new one.
What every mistake looks like: the same 401
Here is the response we got for each of the seven broken tokens, all sent to GET /v1/apps?limit=1 with a freshly generated P-256 key that Apple had never seen:
{
"errors": [{
"status": "401",
"code": "NOT_AUTHORIZED",
"title": "Authentication credentials are missing or invalid.",
"detail": "Provide a properly configured and signed bearer token, and make sure that it has not expired. Learn more about Generating Tokens for API Requests https://developer.apple.com/go/?id=api-generating-tokens"
}]
}
| Token we sent | Status |
|---|---|
| Correct format, unknown key | 401 NOT_AUTHORIZED |
| Lifetime of 60 minutes | 401 NOT_AUTHORIZED |
| Expired 30 minutes ago | 401 NOT_AUTHORIZED |
Audience appstoreconnect instead of appstoreconnect-v1 |
401 NOT_AUTHORIZED |
| DER-encoded signature | 401 NOT_AUTHORIZED |
abc.def.ghi |
401 NOT_AUTHORIZED |
No Authorization header |
401 NOT_AUTHORIZED |
Because the response is identical, you cannot debug a 401 by reading it. You have to check each ingredient yourself, which is what the next script does.
Check your key before Apple does
The script below needs Node.js 18 or newer and no packages. It checks the key file, the IDs, the signature encoding and your clock, then makes one real call and explains the status. Run it whenever a new key fails, and keep it in your repository for the next person.
// asc-key-check.mjs: check an App Store Connect API key locally, then make one test call.
// Usage: ASC_KEY_ID=2X9R4HXF34 ASC_ISSUER_ID=<uuid> ASC_KEY_PATH=./AuthKey_2X9R4HXF34.p8 node asc-key-check.mjs
// Leave ASC_ISSUER_ID unset for an individual key.
import { readFile } from 'node:fs/promises';
import { basename } from 'node:path';
import { createPrivateKey, createPublicKey, createSign, createVerify } from 'node:crypto';
const { ASC_KEY_ID = '', ASC_ISSUER_ID = '', ASC_KEY_PATH = '' } = process.env;
const ok = (msg) => console.log(`ok ${msg}`);
const fail = (msg) => {
console.log(`FAIL ${msg}`);
process.exitCode = 1;
};
const b64 = (value) => Buffer.from(JSON.stringify(value)).toString('base64url');
// 1. The key file: a PKCS#8 PEM holding a P-256 private key.
const pem = await readFile(ASC_KEY_PATH, 'utf8');
if (!pem.includes('-----BEGIN PRIVATE KEY-----')) fail('key file is not a PKCS#8 PEM (.p8) file');
const key = createPrivateKey(pem);
const curve = key.asymmetricKeyDetails?.namedCurve;
if (curve === 'prime256v1') ok('key is an EC P-256 key (ES256)');
else fail(`key curve is ${curve}, expected prime256v1`);
// 2. The IDs: the key ID should match the file name of the download.
if (/^[A-Z0-9]{10}$/.test(ASC_KEY_ID)) ok(`key ID ${ASC_KEY_ID} looks right`);
else fail(`key ID "${ASC_KEY_ID}" should be 10 capital letters and digits`);
const file = basename(ASC_KEY_PATH);
if (file.startsWith('AuthKey_')) {
if (file === `AuthKey_${ASC_KEY_ID}.p8`) ok('file name matches the key ID');
else fail(`file ${file} belongs to another key ID`);
}
const team = ASC_ISSUER_ID !== '';
if (!team) ok('no issuer ID: building an individual key token with sub "user"');
else if (/^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$/i.test(ASC_ISSUER_ID)) ok('issuer ID is a UUID (team key)');
else fail('issuer ID should be the UUID from the Integrations page, not your team ID');
// 3. The token: 15-minute lifetime, raw r||s signature, verified locally.
const now = Math.floor(Date.now() / 1000);
const header = { alg: 'ES256', kid: ASC_KEY_ID, typ: 'JWT' };
const claims = team ? { iss: ASC_ISSUER_ID } : { sub: 'user' };
const payload = { ...claims, iat: now, exp: now + 900, aud: 'appstoreconnect-v1' };
const input = `${b64(header)}.${b64(payload)}`;
const signature = createSign('SHA256').update(input).sign({ key, dsaEncoding: 'ieee-p1363' });
if (signature.length === 64) ok('signature is 64 raw bytes, not DER');
else fail(`signature is ${signature.length} bytes`);
const publicKey = createPublicKey(key);
const verified = createVerify('SHA256').update(input).verify({ key: publicKey, dsaEncoding: 'ieee-p1363' }, signature);
if (verified) ok('signature verifies with the public half of this key');
else fail('signature does not verify');
const token = `${input}.${signature.toString('base64url')}`;
// 4. One real call, plus a clock check against Apple's Date header.
const res = await fetch('https://api.appstoreconnect.apple.com/v1/apps?limit=1', {
headers: { Authorization: `Bearer ${token}` },
});
const skew = Math.round((Date.parse(res.headers.get('date') ?? '') - Date.now()) / 1000);
if (Math.abs(skew) < 60) ok(`clock is within a minute of Apple's (${skew} s)`);
else fail(`clock is ${skew} s off Apple's time: fix NTP before anything else`);
const body = await res.json().catch(() => ({}));
const code = body.errors?.[0]?.code ?? '';
if (res.ok) ok(`GET /v1/apps returned ${res.status}: the key works (${res.headers.get('x-rate-limit')})`);
else if (res.status === 401) fail('401 NOT_AUTHORIZED: Apple does not accept this key ID, issuer ID and private key together');
else if (res.status === 403) fail(`403 ${code}: the key is known, but revoked or its role does not allow this request`);
else fail(`${res.status} ${code}`);
Here is its output for a throwaway key Apple has never issued, with a key ID that does not match the file and a team ID pasted where the issuer ID belongs:
ok key is an EC P-256 key (ES256)
ok key ID ZZZZZ12345 looks right
FAIL file AuthKey_ABCDE12345.p8 belongs to another key ID
FAIL issuer ID should be the UUID from the Integrations page, not your team ID
ok signature is 64 raw bytes, not DER
ok signature verifies with the public half of this key
ok clock is within a minute of Apple's (0 s)
FAIL 401 NOT_AUTHORIZED: Apple does not accept this key ID, issuer ID and private key together
When every local check passes and Apple still returns 401, the problem is the pairing Apple holds on its side: a key ID that belongs to a different .p8, an issuer ID from another team, a team key used with sub instead of iss, or an account whose API access is not approved yet. The key ID check assumes the 10-character format of Apple's examples; relax it if your IDs differ.
401, 403 and 429: what each status means
| Status | Code | Meaning | Fix |
|---|---|---|---|
| 401 | NOT_AUTHORIZED |
The token was not accepted: wrong key ID, issuer ID or private key, bad signature, too long a lifetime, expired, or missing | Run the check script; sign a fresh 15-minute token |
| 403 | FORBIDDEN_ERROR |
The request reached your account but is not allowed. Apple lists "your API key is revoked, your token is incorrectly formatted, or if the requested operation is not allowed" | Check the key is still active and its role covers the endpoint |
| 404 | NOT_FOUND |
The app or resource ID does not exist for this account | Use the numeric App Store Connect app ID, not the bundle ID |
| 429 | RATE_LIMIT_EXCEEDED |
Over the hourly request limit for this key | Read the X-Rate-Limit header and back off |
The 403 wording comes from Apple's status code reference. The rate limit rules are in Apple's rate limit guide: every response carries a header like user-hour-lim:3500;user-hour-rem:500;, the window is a "rolling hour", and the limit applies per API key. Apple's error guide also advises matching error codes by prefix, because codes such as ENTITY_ERROR.ATTRIBUTE.INVALID can grow more levels.
Some 401 reports never get resolved from the client side. One developer on the Apple Developer Forums described a 401 on every endpoint as Account Holder, with a raw signature and keys regenerated several times, and received no answer. If your local checks pass and a brand new key still fails, contact Apple Developer Support rather than rewriting your token code again.
Keep the key safe and replaceable
- One key per job. A review alert job and a CI upload job should not share a key. Revoking one should not stop the other.
- Revoke, do not reuse. "Once you revoke an API key, you can't reinstate it." Revoked keys stay visible for 30 days under the Revoked heading.
- Scope tokens you hand to other systems. A
scopesuch asGET /v1/apps/123/customerReviewslimits what a leaked token can do, and Apple ignoreslimit,cursorandsortwhen matching it. - Short lifetimes. Apple suggests two minutes for a one-off request and 20 minutes for a long-running job, with fresh tokens during the job rather than longer ones.
- Prefer team keys for servers. An individual key stops working with its owner's access, which is what you want for a person and not for a production job.
What the key can and cannot show you
An App Store Connect API key only opens your own apps. With it you can build App Store review alerts, read App Store review summaries per storefront, check a phased release, or receive App Store Connect webhooks when a build changes state.
It shows nothing about competitors, and it does not cover Google Play or browser extension stores, which need their own credentials, such as a Google Play service account, which is also what a script needs to watch a Google Play staged rollout. For the public side of every store, Extenify records store listing data daily with no API key at all: ratings, rating counts, installs, versions and new reviews for your apps and any competitor's, on the App Store, Google Play, Chrome, Edge and Firefox. It is an app analytics dashboard with change alerts to email, Slack, Telegram, Discord or Teams, and every plan starts with a 7-day free trial, no credit card required; see pricing.
Frequently asked questions
Where do I find my App Store Connect issuer ID?
In App Store Connect, open Users and Access, then Integrations. The issuer ID is near the top of the App Store Connect API page, with a Copy button. It is a UUID and is shared by all team keys in your account. Individual keys do not use it.
Why can't I see Generate API Key in App Store Connect?
Either the Account Holder has not requested API access yet, you are not an Admin (needed for team keys), or an Admin removed your Generate Individual API Keys permission (needed for individual keys).
Can I download my .p8 key again?
No. The private key downloads once and Apple keeps no copy. Revoke the key and generate a new one.
How long can an App Store Connect API token last?
Twenty minutes for most requests, measured as exp minus iat. Tokens for some read-only resources can last up to six months, but only with a scope that lists GET requests on those resources.
Can I limit a team key to one app?
No. Team keys apply to all apps in the account; the role only limits what they can do. For a single app, use an individual key from a user who only has access to that app.
Why do I get a 401 when my token decodes fine on jwt.io?
Decoding only shows the header and payload. A 401 with a valid-looking token usually means the signature is DER-encoded instead of raw, the key ID does not belong to that private key, the issuer ID is from another account, or the lifetime is over 20 minutes.
Summary
An App Store Connect API key needs three things to line up: approved API access, the right kind of key with the right role, and a token signed exactly the way Apple expects. Apple answers almost every mistake with the same 401, so check the ingredients yourself: the .p8 is a P-256 key, the key ID matches it, the issuer ID is the UUID from Integrations, the signature is raw, the lifetime is under 20 minutes and your clock is right. Then use one narrowly scoped key per job, store it in a secrets manager, and revoke it the moment it leaks.
Image credits
- Cover photo: A decorative wall-mounted key holder with keys on its hooks by Carlos Moreno on the WordPress Photo Directory, CC0.


