App Store Connect API Key: Setup and Rotation
An App Store Connect API key is a private signing key that lets scripts, build servers and tools act on your Apple developer account without a person typing a password or a 2FA code. Apple lets an Admin generate it once, you can download the private half a single time, and anyone who holds that file can act on your account until someone revokes it. On a new project that’s a five-minute setup, but on an app you inherited the real questions are who owns the key, where the file lives and how you replace it without breaking the release pipeline.

The pages that rank for this term mostly explain how to call the API. One is a well-known guide that covers OpenAPI code generation and pagination, another is a 2020 Bitrise post about moving off Apple ID sessions, and the rest are setup instructions from CI vendors. None of the ones I read cover what happens when the person who generated the key has left, how to rotate a key that a pipeline still uses, or how to tell which keys on an account are actually in use. That’s the gap this article fills, from the point of view of a team that takes over apps for a living.
What is an App Store Connect API key, and what can it do?
It’s one half of a key pair, where Apple keeps the public portion and you download the private portion, and you use the private key to sign short-lived tokens that authorize requests to App Store Connect and the Apple Developer website. Apple’s documentation says these keys are unique to the App Store Connect API, so you can’t reuse them for other Apple services.
The role you pick when you generate the key decides what the key can do. Apple notes that a key with the Admin role has broad permissions, such as creating and deleting users, while the roles that apply to keys are the same roles that apply to people on your team. A key for uploading builds to TestFlight doesn’t need the same power as a key that manages certificates, and giving every pipeline an Admin key is the most common mistake we see when we audit an inherited release process.
In practice, a key sits behind three jobs. Build servers use it to upload builds and to create or fetch signing assets, release scripts use it to submit versions and edit metadata, and monitoring tools use it to read reviews, sales or build status. If you’re rescuing an app, the quickest way to learn how it ships is to find out which of these jobs currently depends on a key.
Should you use a team key or an individual key?
Use a team key for anything automated, because it doesn’t disappear when a person’s account changes. Apple describes two types: a team key has access to all apps with levels set by the role you choose, and an individual key has the access and roles of the associated user.
An individual key looks convenient, since a developer can generate one from their own profile without asking an Admin. The cost shows up later, because Apple states that individual keys aren’t able to use the provisioning endpoints, and their access follows the permissions of one user, so if that person is removed from the team or changes role, the pipeline that relied on the key can break with no change to your code. We also find that nobody remembers which developer’s profile owns the key, which turns a five-minute question into an afternoon of searching.
There’s one more difference worth knowing before you write any script. A team key payload carries an issuer ID, while an individual key payload doesn’t use the issuer ID and requires a subject claim instead. Pasting the wrong shape into a CI variable produces an authentication error that says very little about the cause, so check which kind of key you hold before you debug anything else.
How do you create a team key and keep the private file?
You need an Admin account, and the steps are short. Apple’s documented route is Users and Access, then the Integrations tab, then App Store Connect API, with the Team Keys tab selected, then Generate API Key or the Add button. You name the key, choose a role under Access and click Generate.

Name the key after the job it does, for example the build server that uses it, because Apple says the name is for your reference only and isn’t part of the key itself. A name like “CI uploads” will save the next engineer from guessing which of four keys is safe to revoke. Pick the lowest role that still lets the job work, and generate a separate key for each tool so you can revoke one without stopping the others.
Download the private key immediately, since Apple’s documentation says it’s available a single time, the download link only appears if you haven’t downloaded it yet, and Apple doesn’t keep a copy. Fastlane users will see the file called AuthKey_ followed by the key ID, and you should store it in your password manager or secret store the same minute, before you close the tab.
You’ll need three values to use the key: the key ID, which Apple shows in a column under the Active heading, the issuer ID near the top of the Integrations page, and the .p8 private key file itself. Treat the first two as identifiers and the third as a password, because the file is the only one of the three that can sign a token.
How does the key turn into a token your tools can use?
Your tool signs a short JSON Web Token with the private key and sends it in the authorization header of every request. Apple’s documentation says all of these tokens must be signed with ES256, the header carries your key ID, and the payload for a team key carries the issuer ID, an issued-at time, an expiration time and the audience.
Expiry is the detail that matters for pipelines. Apple states that tokens expiring more than 20 minutes into the future aren’t valid, apart from a short list of resources it documents separately. The fastlane documentation mirrors that limit, since its duration option for the API key action has a maximum of 1200 seconds. A script should therefore create a new token on every run instead of caching one in a variable, and a token that “worked yesterday” in a CI log is a sign someone stored it.
Apple also supports an optional scope claim, which is a list of the specific requests a token may make. If a token leaks, a narrow scope limits what the person holding it can do, so it’s a cheap hardening step for a script that only reads build status.
You rarely write this by hand. Fastlane’s app_store_connect_api_key action takes a key ID, an issuer ID and the key file and builds the authorization for you, and its documentation recommends this over an Apple ID because there’s no 2FA to satisfy, plus better performance and increased reliability. That last point matters on a server, where a 2FA prompt has nobody to answer it.
Where should the key live, and where must it never go?
Keep it in a secret manager or in your CI provider’s encrypted secrets, and never in the repository. Apple’s own guidance is to treat the private key like any other credential, and it explicitly says not to share keys, store them in a code repository or include them in client-side code.
The practical problem is that a .p8 file is multi-line text, which some CI variable fields handle badly. GitHub’s documentation describes storing small binary blobs as secrets by encoding them to Base64 and decoding them on the runner with the base64 —decode command, and the same approach works for a key file on most services. Fastlane also accepts a JSON file that holds the key ID, the issuer ID and the key contents, with duration and in_house as optional extras, which keeps the three values together in one secret.

On an inherited app, search before you trust the answer you’re given. Look through the repository history, the CI variables, old build scripts and the machine of the previous developer for any .p8 file or an AuthKey_ filename, because a key committed to history stays valid until someone revokes it. If you find one, treat it as exposed, generate a replacement and revoke the old key as soon as the new pipeline is verified.
What should you check on an inherited app before you trust its keys?
Start with who holds the Admin role on the account, because only an Admin can generate or revoke a team key. If the Account Holder is a former employee or an agency you no longer work with, you can’t fix anything else until that’s sorted, and our notes on transferring an app between Apple accounts cover the ownership side of it.
Then list the Active keys on the Integrations page and compare them to the jobs you can find. For each key, write down its name, its role and which pipeline you believe uses it. A key whose name tells you nothing, with a role of Admin, and no matching job in CI is the one to question first, since it’s either abandoned or used by something nobody documented.
Be careful with revocation until you know what depends on the key. Apple says a revoked key can’t be reinstated, so revoking an unknown key can silently stop a nightly upload or a review-monitoring script. Rotate in the safe order described in the next section, and keep the old key alive until the new one is proven.
This audit is part of the first week on any app we take over, and it sits alongside the signing checks in our iOS distribution certificate notes. If you want an engineer to run it for you, that’s what the app takeover service covers, but the steps here are enough to do it yourself.
How do you rotate a key without breaking the release pipeline?
Create the new key first, switch the pipeline to it, confirm a real release step succeeds, and only then revoke the old one. The order is the whole trick, because Apple doesn’t let you undo a revocation.

- Generate a new team key with the lowest role that works, named after the job, and download the private file immediately.
- Store the new key ID, issuer ID and private key in your secret store next to the old values, without deleting them yet.
- Point the pipeline at the new values and run a step that exercises the key, such as a TestFlight upload or a metadata fetch.
- Wait for one full normal release cycle, so any scheduled job that uses the key has run at least once.
- Revoke the old key from the Keys tab by clicking Edit, selecting it and confirming with Revoke Key.
Apple says revoked keys remain visible on the API Keys page under the Revoked heading for 30 days, which gives you a record of what you removed and when. Take a screenshot or note the key names in your handover document so the history isn’t lost when the 30 days pass.
If a key has leaked, compress the schedule. Revoke it right away, accept that one pipeline will fail, and bring up the replacement straight afterwards, because an exposed Admin key is worse than a broken nightly upload. Apple’s guidance is the same: if you suspect a private key is compromised, revoke it immediately.
What breaks most often after you switch to a key?
The common failures are small and repetitive, and most of them are a wrong value in the wrong field. A mixed-up key ID and issuer ID gives an authentication failure, a team key used with individual-key settings fails the same way, and a token built with a long expiry is rejected because of the 20-minute rule. A role that’s too low shows up as a permission error on one specific action while others keep working, such as an upload that succeeds and a certificate fetch that doesn’t.
Signing is the other trap, so if your lanes use fastlane’s match with the key, the account behind it needs a role that can manage certificates, and an Individual key can’t reach the provisioning endpoints at all. When a pipeline only partly works after the switch, compare the role on the key with the role the failing step needs before you touch the code.
Finally, watch the older tools, because the Bitrise post that ranks for this term dates from 2020 and says its Fastlane and Deliver steps still used session-based authentication at the time, so a CI service’s documentation from that era may describe a different login method than the one you should use now. Read the current docs for your provider, and test one step end to end before you retire the Apple ID the old setup depended on.
What should the handover note say about your keys?
It should name every active key, the job it belongs to, its role, where the private file is stored and who can rotate it. That’s five facts per key, and a note with those facts turns a mystery into a routine task for whoever inherits the app next.
Add the Account Holder and the Admins on the account, the date each key was generated, and the date you last verified that the pipeline works with it. If you work with an outside team, say who is allowed to generate keys and remind them that the Generate Individual API Keys permission exists, because Apple says an Admin can remove that permission from a user to stop them creating individual keys.
A key is a small thing that quietly holds up your whole release process. Knowing who owns it, where it’s stored and how to replace it is the difference between a smooth release and an emergency on submission day. If you’re sorting this out on an app you didn’t build, our mobile app maintenance work includes keeping this kind of release plumbing documented and working, and RapidLabs can walk through your current setup with you.
Frequently asked questions
How do I get an App Store Connect API key?
Sign in to App Store Connect with an Admin account, open Users and Access, choose the Integrations tab, select App Store Connect API and make sure the Team Keys tab is active. Click Generate API Key or the Add button, give the key a name for your own reference, pick a role under Access and click Generate. Apple then shows the key name, the key ID and a download link for the private key.
Can I download an App Store Connect API key again?
No. Apple's documentation says the private key is available for download a single time and that Apple doesn't keep a copy. The download link only appears if the private key hasn't been downloaded yet, so a lost file means revoking that key and generating a new one.
What is the difference between a team key and an individual key?
A team key has access to all apps, with the level of access set by the role you choose, and an Admin has to generate it. An individual key carries the access and roles of the one user it belongs to, and Apple states that individual keys can't use the provisioning endpoints. A team key is the better fit for a build server because it doesn't depend on one person's account.
How long is an App Store Connect API token valid?
Tokens that expire more than 20 minutes into the future aren't valid, except for a short list of resources that Apple documents separately. That is why fastlane caps its duration option at 1200 seconds, and why a build script should create a fresh token for each run instead of storing one.
How do I revoke an App Store Connect API key?
An Admin opens Users and Access, selects the Keys tab, clicks Edit next to the list of Active keys, selects the keys to revoke and confirms with Revoke Key. Apple says a revoked key can't be reinstated, and that revoked keys stay visible on the API Keys page under the Revoked heading for 30 days.
Do I need an App Store Connect API key to use fastlane?
No, fastlane can also sign in with an Apple ID, but the fastlane documentation recommends the API key and lists no 2FA needed, better performance and increased reliability as the benefits. The Apple ID route relies on a cookie-based web session, while the key route uses Apple's documented API.
Stuck on a release, a crash, or an app nobody owns?
RapidLabs maintains, stabilizes and takes over existing iOS and Android apps. Send the app link, the stack, and what is going wrong, and you will get a plain answer on whether you need help at all.
Talk to a senior engineer about your app