Skip to content
Latchkey

datadog-ci "Missing DATADOG_API_KEY" in CI

datadog-ci reads the API key from the environment, and when DATADOG_API_KEY (or DD_API_KEY) is empty it stops immediately with "Missing DATADOG_API_KEY in your environment." No request reaches Datadog.

What this error means

A datadog-ci subcommand (sourcemaps, junit, synthetics) exits non-zero with "Missing DATADOG_API_KEY in your environment." before uploading anything.

datadog-ci
[ERROR] Missing DATADOG_API_KEY in your environment.

Common causes

The API key secret is not exposed to the step

The workflow never set DATADOG_API_KEY, or used a different name, so datadog-ci finds nothing to authenticate with.

The run is on a fork without secrets

Pull requests from forks do not receive repository secrets, so the key resolves to empty in that context.

How to fix it

Export DATADOG_API_KEY from a secret

  1. Store the Datadog API key as a CI secret.
  2. Expose it as DATADOG_API_KEY in the step env.
  3. Re-run the datadog-ci command.
.github/workflows/ci.yml
env:
  DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
run: datadog-ci junit upload --service web ./reports

Guard against an empty key

Fail fast with a clear message if the variable is missing, instead of a deep error later.

Terminal
test -n "$DATADOG_API_KEY" || { echo "DATADOG_API_KEY is empty"; exit 1; }

How to prevent it

  • Set the API key from a secret at the job level.
  • Use the exact env name datadog-ci expects (DATADOG_API_KEY).
  • Skip Datadog uploads on fork-triggered runs where secrets are absent.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →