Skip to content
Latchkey

Cypress "Record Key is not valid" - cypress run --record Fails in CI

Recording a run to Cypress Cloud needs a valid Record Key tied to the project. The run fails when --record is passed without a key, the key is wrong/rotated, or the projectId does not match the key’s project.

What this error means

cypress run --record aborts with "Your Record Key ... is not valid with this projectId" or "You passed the --record flag but did not provide a Record Key." Non-recording runs work; only the Cloud-recording path fails.

Cypress output
You passed the --record flag but did not provide a Record Key.

# or
Your Record Key <...> is not valid with this projectId: abc123
Please log into the Dashboard to verify.

Common causes

Record Key missing from the CI environment

The CYPRESS_RECORD_KEY secret is not set in the job (or not exposed to forks), so --record has no key to authenticate with.

Key/projectId mismatch or rotated key

The key belongs to a different project than the configured projectId, or it was rotated in the Cloud dashboard and the CI secret still holds the old value.

How to fix it

Provide the key via a CI secret

Set the record key as an environment secret and reference it - do not hard-code it.

.github/workflows/ci.yml
# .github/workflows/ci.yml
- run: npx cypress run --record
  env:
    CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}

Align the key, projectId, and rotation

  1. Confirm projectId in cypress.config matches the project the key belongs to.
  2. Re-copy the key from the Cloud dashboard if it was rotated, and update the CI secret.
  3. Remember forked-PR builds do not get secrets - skip recording or use a dedicated flow there.

How to prevent it

  • Store the record key only as a CI secret.
  • Keep projectId and the key’s project in sync.
  • Rotate the CI secret whenever the Cloud key is rotated.

Frequently asked questions

What causes ""Record Key ... not valid""?
The CYPRESS_RECORD_KEY secret is not set in the job (or not exposed to forks), so --record has no key to authenticate with.
How do I fix "Record Key ... not valid"?
Set the record key as an environment secret and reference it - do not hard-code it.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card