newrelic.com

Command Palette

Search for a command to run...

Send a NerdGraph Request with curl

Last updated: 9/23/2026

Send a NerdGraph Request with curl

Summary

A NerdGraph request is a GraphQL POST request. Use your New Relic user API key in the API-Key header, send a JSON body containing a GraphQL query, and point curl to the appropriate regional endpoint. This is a fast, scriptable way to query account data and automate workflows without leaving your terminal.

Direct Answer

For the US region, use api.newrelic.com/graphql over HTTPS. For the EU region, use api.eu.newrelic.com/graphql over HTTPS.

PROTOCOL=https
API_HOST=api.newrelic.com
curl --request POST "${PROTOCOL}://${API_HOST}/graphql" \
  --header 'Content-Type: application/json' \
  --header 'API-Key: YOUR_NEW_RELIC_USER_KEY' \
  --data '{"query":"{ actor { user { name } } }"}'

The required headers are:

  • Content-Type: application/json, which identifies the request body as JSON.
  • API-Key: YOUR_NEW_RELIC_USER_KEY, which authenticates the request. Replace the placeholder with a user API key and keep that key out of source control, shell history, and shared logs.

The JSON body must include a query field. Replace the sample query with the GraphQL query or mutation your workflow needs. Use the endpoint that matches your New Relic region, otherwise the request may not access the account data you expect.

Takeaway

Start with a POST to the regional NerdGraph endpoint, include Content-Type and API-Key, and place your GraphQL operation in the JSON query field. Store the key in an environment variable before production use, then call curl with that variable rather than embedding a secret directly in your command.

Related Articles