Symptom → fastest fix: fastlane API Key authentication fails → verify the key type, .p8 file, Key ID, and Issuer ID first; then check the key’s role and the configuration fastlane actually loads.
Use this order when a fastlane call to the App Store Connect API fails. If the private key is missing or may have leaked, revoke it and create a replacement instead of repeatedly retrying the old credential.
This guide is for developers using fastlane to automate iOS builds, tests, or releases, especially when configuring an API key for the first time. Small teams can use the checks to separate a credential problem from a role or configuration problem. If you plan to run fastlane on a remote Mac, use the environment checks to confirm the task’s account can access the credential safely.
Identify the failing stage before changing credentials
An error reported during an automated release does not, by itself, prove that API authentication failed. First identify the exact command and action that stopped, then compare its output with the last operation that completed.
Use these observable distinctions:
- Credential-loading failure: fastlane cannot read the key file, cannot decode supplied key content, or fails before making the intended API request. Check the file path, file permissions, and the values passed to the API-key action.
- Authorization or API rejection: fastlane has loaded the credential and receives an error from an App Store Connect API request. Check the key type, identifiers, role, and whether the requested operation is supported for that key.
- Later workflow failure: authentication or an API request has succeeded, but a build, signing, upload, processing, or other subsequent operation fails. Follow the error from that action rather than replacing the API key without evidence.
| Observable evidence | Most likely branch | First check | Diagnostic score |
|---|---|---|---|
| Failure occurs before the API call and mentions a file, path, or key content | Key-loading or configuration | Confirm the executing account can read the configured .p8 file | High |
| Request reaches App Store Connect, but the response indicates an authorization or access problem | Key identity or role | Match the Key ID and Issuer ID to the intended key; check its role | High |
| API call completes, then a build or delivery step fails | Downstream workflow | Identify the failing action and inspect its own requirements | High |
| Works locally but fails in CI or on a remote Mac | Environment difference | Compare account, working directory, environment variables, and file access | Medium |
**Do not rotate a working key just because a later upload step failed.** First establish whether fastlane reached the API request and whether that request succeeded.
Check the key type and matching identifiers
When fastlane says an App Store Connect API key is invalid, start by checking whether the credentials belong together. The .p8 private key, Key ID, and—when required—the Issuer ID are not interchangeable values. They identify or authorize a particular API key setup.
Apple distinguishes Team API Keys from Individual API Keys. Choose the type that matches how the automation should be authorized. A Team Key is associated with the App Store Connect team and its assigned role. An Individual Key is associated with a user, so its access follows that user’s permissions. Do not treat a Team Key as isolated to one app unless the documented access controls for your setup establish that limitation. Apple’s API key creation and storage guidance describes the key types and their handling.
How should you choose between an Individual Key and a Team Key?
Choose an Individual Key when the workflow should use a specific user’s permissions and you can manage that user’s access appropriately. Choose a Team Key when the automation should use a team-managed key with an explicitly selected role. In either case, verify the access scope before putting the key into a release workflow.
If you have a Team Key, confirm that the Issuer ID belongs to the same team as the Key ID and private key. If you have an Individual Key, check the configuration instructions for that key type rather than copying a team-key example unchanged. fastlane documents the parameters accepted by app_store_connect_api_key; use the documented options that match your key.
What happens if the Key ID and Issuer ID do not match?
The request can fail because the identifiers do not describe the key and account context you intended to use. Do not try Issuer IDs from other teams or swap values at random. Compare the Key ID and Issuer ID with the App Store Connect account where the key was created, then check that the .p8 file is the corresponding private key.
Apple’s token-generation documentation describes the token fields and signing process. For example, Apple documents iss as the issuer claim for a team key and kid as the key identifier in the token header. These values must be generated from the intended key setup; they are not substitutes for one another.
A useful branch is:
- If the key file cannot be read or parsed, fix file access or the configured content before changing roles.
- If the file loads but the request is rejected, verify the key type and the matching identifiers before changing the Fastfile.
- If the key is valid but the operation is denied, check role permissions and action support next.
Match the role to the operation
A readable private key can still be unable to perform the requested operation. API Key permissions depend on the key type and its assigned access. A role suitable for one task may not grant another task’s access.
Start with the operation that failed. Is the lane reading app information, managing a release-related resource, or performing another App Store Connect operation? Then compare that operation with the role assigned to the key. Apple’s App Store Connect role descriptions explain the available roles and their permissions.
Do not grant a broader role as the default troubleshooting step. Instead:
- Identify the exact API operation or fastlane action that was denied.
- Confirm which key fastlane loaded and what role is assigned to it.
- Check whether the action supports API-key authentication for that operation.
- Increase access only if the documented task requires it and your team approves the change.
.p8 path will not add permission. If the key cannot be loaded at all, changing its role will not fix file access.
Verify what fastlane actually reads
When credentials look correct in a dashboard but authentication still fails, inspect the values and files used by the running lane. The relevant configuration is the one the process loaded—not the one you intended it to load.
In the Fastfile, check the app_store_connect_api_key call and its documented parameters. Confirm that the configured Key ID, Issuer ID where applicable, and key file or key content refer to the same key. Then check how the next action receives that API-key context. The app_store_connect_api_key documentation describes supported parameters and usage; the fastlane API authentication guide explains that support can depend on the action.
For a controlled diagnosis, verify these items without printing the private key:
- The lane loads the intended Fastfile and configuration.
- The key path resolves from the task’s actual working directory.
- The process uses the expected environment variables and does not silently fall back to stale values.
- The following action uses the API-key object or configuration you just checked.
- The error belongs to that action, not to a later build or upload step.
Compare local, CI, and remote Mac execution
A local run can succeed while a CI job or remote Mac run fails because the process may use a different account, directory, environment, or secret store. Treat the execution context as a separate part of the credential configuration.
Check the job’s runtime identity first. The user launching fastlane must be able to read the key file. A path that exists in your interactive shell may not exist for a background runner or a different macOS account. Next, check the working directory: relative paths are resolved from the process context, not necessarily from the directory where you opened the project.
Then compare the environment:
- Are the expected variables available to the actual job, rather than only to your login shell?
- Does the job receive the intended secret version?
- Is the key file created or mounted before fastlane starts?
- Can the task account read the file without making it broadly accessible?
- Does the lane load the same configuration locally and remotely?
**Never commit a
.p8private key to a source repository, embed it in a client app, or print it to CI logs.** Apple’s key guidance explains private-key handling; keep the secret in an approved secure store and expose it only to the task that needs it.
Recover the credential and verify the release path
Use this decision list to choose the next action. Fix only the branch supported by your evidence.
- If the
.p8file is present but unreadable, correct the path, account access, or configured key content. Retest the credential-loading step before changing the role. - If the file loads but the API request is rejected, match the key type, Key ID, and Issuer ID, then verify the role and operation support.
- If local execution succeeds but remote execution fails, compare the job account, working directory, variables, and secret delivery. Do not create a new key until you know the remote process is using the intended one.
- If the private key is lost, create a replacement key and update the secure configuration. Apple’s single-download rule means the original private key cannot simply be downloaded again.
- If the key may have leaked, revoke it and create a replacement instead of retrying the exposed credential. Follow Apple’s API key revocation procedure, then remove or replace the old secret wherever your workflow stored it.
aud value as appstoreconnect-v1 and its signing algorithm as ES256. These are useful checks when you are diagnosing custom token generation; when fastlane generates the token, use the documented fastlane configuration rather than hand-building a token without a specific reason.
After the credential or access issue is corrected, verify the workflow in stages:
- Run a fastlane operation that exercises the intended API authentication and is supported by the key.
- Confirm the response corresponds to the expected team or account context.
- Run the actual lane and record which action succeeds or fails.
- Verify build, signing, archive, and upload outcomes separately from API authentication.
- Keep a record of the credential owner, role, storage location, and replacement process without recording the private key itself.
pilot action documentation](https://docs.fastlane.tools/actions/pilot/) describes that action’s role in TestFlight workflows; do not use an upload or processing error as proof that the API key itself is invalid.
If the failure is confined to the execution environment, review the workflow’s requirements before moving it. A remote Mac can avoid buying and maintaining a dedicated machine, but it adds secret-delivery and account-access checks; a local Mac gives you direct control but requires you to provide and maintain the hardware. If you want to compare a listed option, check the MACGPU M4 Mac rental details against your actual toolchain, access, and credential-management needs. Keep the private key in your approved secret store, and choose a rented environment only when its operating model fits your release process.