Why automate App Store Connect
A release touches App Store Connect a dozen times: upload, wait for processing, add the build to TestFlight groups, write What to Test, create the version, paste release notes in every language, attach the build, submit, release. Doing that by hand is slow and it is where typos and wrong builds slip in. The App Store Connect API covers almost all of it, and fastlane and the asc command-line tool wrap the API so you rarely need to write raw HTTP. You still need to understand keys, tokens and the gaps, because that is where automation breaks.
Step 1: create the right kind of key
There are two kinds of API key, and the choice matters.
| Team key | Individual key | |
|---|---|---|
| Created by | A user with the Admin role | Any user granted the Generate Individual API Keys permission |
| Where | Users and Access > Integrations > App Store Connect API > Team Keys | Your user profile > Individual API Key |
| Access | All apps, limited by the role you assign | The apps and role of that user |
| Issuer ID in JWT | Yes (iss) |
No; uses sub: "user" |
| Limits | None beyond the role | No Provisioning endpoints, no Sales and Finance, no notaryTool |
For CI, use a team key with the narrowest role that does the job. The fastlane docs recommend team keys for the same reason: actions that manage certificates and profiles need the Provisioning endpoints that individual keys cannot reach.
Two rules from Apple’s key documentation that catch people out:
- The private key (
AuthKey_<KEYID>.p8) can be downloaded exactly once. Apple does not keep a copy. - Do not store it in a repository or in client-side code. If it leaks, revoke it in App Store Connect immediately.
Store the key ID, issuer ID and the .p8 contents as CI secrets.
Step 2: sign the token
Every request carries a JWT signed with your private key. From Apple’s token documentation:
- Header:
algisES256(required),kidis your key ID,typisJWT. - Payload for team keys:
iss(issuer ID),iat(issued-at, Unix seconds),exp(expiry),audset toappstoreconnect-v1, and an optionalscope. - Payload for individual keys:
subset touserinstead ofiss. - Most requests reject a token whose lifetime (
expminusiat) exceeds 20 minutes. - Send it as
Authorization: Bearer <token>. Reuse a token until it expires; generating one per request is wasted work.
The scope claim is an array of allowed requests such as GET /v1/apps?filter[platform]=IOS. A scoped token is useless for anything else, which limits the damage if it leaks. Scoped tokens that contain only GET requests can live up to six months for a small set of resources, mostly Xcode Cloud ones (workflows, build runs, repositories) and power and performance metrics. Everything else stays at 20 minutes.
Here is a self-contained signer using CryptoKit (macOS 11 and later). It reads the .p8 PEM directly; CryptoKit’s ECDSA signature rawRepresentation is already the 64-byte format JWT expects.
import CryptoKit
import Foundation
struct AppStoreConnectToken {
let keyID: String
let issuerID: String
let key: P256.Signing.PrivateKey
init(keyID: String, issuerID: String, p8: String) throws {
self.keyID = keyID
self.issuerID = issuerID
self.key = try P256.Signing.PrivateKey(pemRepresentation: p8)
}
func make(lifetime: TimeInterval = 20 * 60, now: Date = .now) throws -> String {
struct Header: Encodable {
let alg = "ES256"
let kid: String
let typ = "JWT"
}
struct Claims: Encodable {
let iss: String
let iat: Int
let exp: Int
let aud = "appstoreconnect-v1"
}
let issuedAt = Int(now.timeIntervalSince1970)
let encoder = JSONEncoder()
let header = try encoder.encode(Header(kid: keyID)).base64URL
let claims = try encoder.encode(
Claims(iss: issuerID, iat: issuedAt, exp: issuedAt + Int(lifetime))
).base64URL
let signingInput = "\(header).\(claims)"
let signature = try key.signature(for: Data(signingInput.utf8)).rawRepresentation
return "\(signingInput).\(signature.base64URL)"
}
}
extension Data {
var base64URL: String {
base64EncodedString()
.replacingOccurrences(of: "+", with: "-")
.replacingOccurrences(of: "/", with: "_")
.replacingOccurrences(of: "=", with: "")
}
}
And a request that lists five apps with only the fields it needs:
func listApps(token: String) async throws -> Data {
var components = URLComponents(string: "https://api.appstoreconnect.apple.com/v1/apps")!
components.queryItems = [
URLQueryItem(name: "fields[apps]", value: "name,bundleId"),
URLQueryItem(name: "limit", value: "5"),
]
var request = URLRequest(url: components.url!)
request.setValue("Bearer \(token)", forHTTPHeaderField: "Authorization")
let (data, response) = try await URLSession.shared.data(for: request)
guard let http = response as? HTTPURLResponse, http.statusCode == 200 else {
throw URLError(.badServerResponse)
}
return data
}
You probably should not maintain this yourself. Antoine van der Lee maintains appstoreconnect-swift-sdk, generated from Apple’s OpenAPI specification, which handles the token for you. Pol Piella’s guide on the Runway blog lists alternatives in Swift (Bagbutik, asc-swift), JavaScript and Go, and gives the usage advice that matters most: keep limit low and page with the returned links, use fields[...] to trim responses, and be careful with include, which can slow requests down sharply.
What the API can and cannot do
The API covers most of the release path:
- Builds: read processing state, expiry and encryption, assign to groups, and since API 4.1, upload through the Build Uploads resource.
- TestFlight: groups, testers, What to Test localisations, Beta App Review, feedback (screenshots and crashes).
- App Store versions: create, set
releaseType(MANUAL,AFTER_APPROVALorSCHEDULEDwithearliestReleaseDate), localisations, screenshots and previews, review details, phased release. - Review submissions:
reviewSubmissionsandreviewSubmissionItems, which group a version, in-app events, custom product pages and other items into one submission. - In-app purchases, subscriptions, pricing, availability, customer reviews, analytics and sales reports, webhooks.
The gaps to plan around:
- New app records. Apple’s Apps resource page says not to use the API to create apps; create them on the website.
- Things only the web UI shows. Piella gives the version state history as an example backed by an internal endpoint, not the public API.
- Individual-key restrictions. No provisioning, finance or notarisation.
- Some fastlane tools. The fastlane docs list
produce(which creates apps) andpemas not supporting API keys.
One documentation wrinkle: the Apps page still says the API cannot upload builds and points to Xcode and Transporter. The 4.1 release notes added Build Uploads, matching the WWDC25 announcement, along with webhook events for build upload state. Treat the release notes as the current word.
In the WWDC26 In-App Purchase session, Apple also said the existing in-app purchase, subscription and subscription group submission resources will be deprecated in favour of reviewSubmissions and reviewSubmissionItems. If you submit purchases through the API, move to review submissions now.
Rate limits
Limits apply per API key over a rolling hour. Every response has an X-Rate-Limit header such as user-hour-lim:3500;user-hour-rem:500;, and exceeding it returns HTTP 429 with RATE_LIMIT_EXCEEDED. Apple says actual limits vary. Throttle polling loops (waiting for a build to finish processing is the usual culprit), log 429s and retry later, and prefer webhooks for build upload and feedback events.
fastlane
fastlane is the most common wrapper. Its API key page shows two ways to pass a key:
- The
app_store_connect_api_keyaction withkey_id,issuer_idandkey_filepath, plus an optionaldurationup to 1,200 seconds. Later actions in the lane pick it up from the lane context. - A JSON file with
key_id,issuer_idandkey(the.p8contents), passed asapi_key_path.
API keys work with pilot (TestFlight), deliver (metadata, screenshots, submission), match, cert, sigh, precheck (except in-app purchases), download_dsyms and app_store_build_number.
fastlane run upload_to_testflight \
api_key_path:"fastlane/asc_key.json" \
ipa:"build/MyApp.ipa" \
skip_waiting_for_build_processing:true
deliver takes submit_for_review, automatic_release, phased_release and submission_information, and reads release notes from metadata/<locale>/release_notes.txt and review details from metadata/review_information/. A single lane can push metadata for every locale and submit the version.
The asc CLI
asc is a newer command-line client for the API, written in Go and installed with Homebrew. It is built to be scripted: output defaults to a table in a terminal and JSON when piped. Authenticate once:
asc auth login --name "MyCompany" \
--key-id "$ASC_KEY_ID" \
--issuer-id "$ASC_ISSUER_ID" \
--private-key "$ASC_KEY_PATH"
asc auth status --validate
A release from an uploaded build to review looks like this (IDs come from the list commands):
asc builds wait --app "$APP_ID" --latest
asc versions create --app "$APP_ID" --version "3.2.0" --platform IOS
asc versions attach-build --version-id "$VERSION_ID" --build-id "$BUILD_ID"
asc validate --app "$APP_ID" --version-id "$VERSION_ID"
asc review submissions-create --app "$APP_ID" --platform IOS
asc review items add --submission "$SUBMISSION_ID" \
--item-type appStoreVersions --item-id "$VERSION_ID"
asc review submissions-submit --id "$SUBMISSION_ID" --confirm
The global --read-only flag refuses every POST, PATCH, PUT and DELETE before it is sent. Use it for audits and dashboards so a reporting script can never change anything.
fastlane or asc
The two overlap. fastlane has years of plugins, match for signing and a big install base; it needs Ruby. asc is a single binary that maps closely to API resources, which makes it easier to see exactly which call ran. This article’s recommendation: keep fastlane where you already rely on match and deliver metadata folders, and use asc for new scripts, read-only reporting and the review-submission steps, where its commands mirror the API one to one.
Traps and edge cases
- Lifetime arithmetic. App Store Connect computes the lifetime as
expminusiat. Anything over 1,200 seconds is rejected for most resources, so do not pad the expiry “to be safe”. - Wrong key type. An individual key can read your apps but fails the moment
matchneeds the Provisioning endpoints. - Mangled PEM text. The
.p8is multi-line text, and line breaks are easy to lose when it is pasted into a secret store or a config file. Van der Lee’s SDK article calls out line-break handling for the private key. Test the secret by signing one token in CI before the release job depends on it. - Processing is asynchronous. A successful upload does not mean the build is usable. Wait for the processing state to become valid, or subscribe to the build upload webhook.
- Upload requirements. Since April 28, 2026, uploads must be built with Xcode 26 or later. Automation does not bypass that.
Setup checklist
| Item | Done when |
|---|---|
| Team key with the narrowest workable role | Key ID and issuer ID stored as CI secrets |
.p8 stored once, outside the repository |
Old or leaked keys revoked |
| Tokens at most 20 minutes, reused across requests | No 401s from expired tokens mid-run |
| Polling throttled, 429 handled | X-Rate-Limit logged on long jobs |
| Webhooks for build uploads and feedback | No minute-by-minute polling loops |
| Review submissions used for versions and purchases | No dependency on the deprecated purchase submission resources |
| Reporting scripts run read-only | asc --read-only or GET-only scoped tokens |
Sources and further reading
- Creating API Keys for App Store Connect API Apple Developer Documentation
- Generating Tokens for API Requests Apple Developer Documentation
- Identifying Rate Limits Apple Developer Documentation
- Apps Apple Developer Documentation
- App Store Connect API 4.1 release notes Apple Developer Documentation
- What's new in App Store Connect (WWDC25) Apple Developer
- What's new in Apple In-App Purchase (WWDC26) Apple Developer
- App Store Connect API fastlane docs
- App Store Connect API SDK in Swift: Creating Developer Tools Antoine van der Lee, SwiftLee
- A hitchhiker's guide to the App Store Connect API Pol Piella, Runway
- App-Store-Connect-CLI (asc) rorkai on GitHub