## TL;DR

Re-encrypt the variable after fixing it and re-run the build.

## Steps

1. Download the private API key from App Store Connect in .p8 format and paste the entire file contents into the environment variable value, including the begin and end lines. A truncated or reformatted key is the usual cause. Re-encrypt the variable after fixing it and re-run the build.

## When to use

You are seeing this: Download the private API key from App Store Connect in.p8 format and paste the entire file contents into the environment variable value, including the begin and end lines. Use this skill when you run into "Codemagic: App Store Connect private key value is not valid".

## When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

## Versions

No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.

## Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
