## TL;DR
Marketstack's invalid_access_key means the key is wrong, inactive, or pasted with whitespace, not that the endpoint is broken. Regenerate the key in the dashboard, store it without extra characters, and verify with a minimal request before rerunning the news pull.

## The error
```text
{"error": {"code": "invalid_access_key", "message": "You have not supplied a valid API Access Key."}}
GET /v1/news?access_key [your value]
```

## Fix it
1. Strip whitespace and quotes from the stored key and retry a minimal request. Copy-paste often adds a trailing space or newline.
   Expected: Expected: the minimal request succeeds, proving it was a formatting issue.
2. If it still fails, regenerate the key in the Marketstack dashboard and update the pipeline config; old keys can be revoked without notice.
   Expected: Expected: the fresh key returns 200 on the same request.
3. Verify the key has not hit the monthly request cap; an exhausted free plan can surface as an access error on some endpoints.
   Expected: Expected: the dashboard shows remaining quota above zero.
4. Store the key in the pipeline's secret config with a startup validation call that fails fast on invalid_access_key.
   Expected: Expected: bad keys break the deploy, not the 3am news pull.

## When to use
- Your Marketstack news pull fails with invalid_access_key.
- You need to distinguish a bad key from a quota or plan problem.
- You rotate keys across environments and need a validation step.

## When not to use
- The error code is different (e.g. rate_limit_reached) - follow that error's fix instead.
- The key works for EOD data but not news - check the plan's endpoint entitlements.
- You need historical news beyond the plan's window - that is a plan limit.

## Why it happens
The access_key parameter did not match any active key: typo, stale revoked key, or invisible whitespace. Marketstack validates the key before anything else, so every failure mode in key handling surfaces as this one error.

## Variant phrasings
### marketstack invalid_access_key
Same failure and fix; some searchers phrase the query this way.
### marketstack api key not valid fix
Same failure and fix; some searchers phrase the query this way.

## Edge cases
- Keys are environment-specific in some setups; a key valid in dev may not exist in prod.
- URL-encoding the key is unnecessary and can break validation if the key contains special characters.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_AMO69esiQbq5uERP_Ukw2A
