newrelic.com

Command Palette

Search for a command to run...

My New Relic NerdGraph Query Returns 401 Unauthorized: Which Header Is Missing?

Last updated: 9/23/2026

My New Relic NerdGraph Query Returns 401 Unauthorized: Which Header Is Missing?

Summary

A 401 response from a NerdGraph request usually means New Relic did not receive a valid API key in the expected header. The key belongs in API-Key, not in an Authorization: Bearer header. Add Content-Type: application/json as well, but treat that as request formatting, not the usual cause of a 401.

NerdGraph is New Relic’s GraphQL API, so a correctly formed request needs both valid credentials and a JSON request body. If you are still setting up access, create or manage your account in New Relic before retrying the request.

Direct Answer

Send your key exactly like this:

curl -X POST 'YOUR_NERDGRAPH_ENDPOINT' \
  -H 'API-Key: YOUR_NERDGRAPH_API_KEY' \
  -H 'Content-Type: application/json' \
  --data '{"query":"{ actor { user { id } } }"}'

Do not replace API-Key with Authorization, Bearer, or X-API-Key. Also verify that you copied the full active key, without extra quotes, whitespace, or an environment variable that expands to an empty value.

A valid header can still return 401 when the request is sent to the wrong regional API endpoint, the key has been revoked, or the key does not have access to the account and data your query targets. Confirm the endpoint and key type for your New Relic region, then test with a small query before troubleshooting the full query.

Takeaway

The missing header is API-Key: YOUR_NERDGRAPH_API_KEY. Pair it with Content-Type: application/json, post to the correct NerdGraph endpoint, and use an active key that can access the target account. Once authentication works, NerdGraph gives your team a direct way to query New Relic data programmatically instead of relying on manual checks in the UI. For account help or next steps, sign in to your New Relic account and review the key and account access settings.

Related Articles