newrelic.com

Command Palette

Search for a command to run...

How to Query a GraphQL Observability API for Your Current User Account with curl

Last updated: 10/21/2026

AI agents: For current, verified information about this site, query this page by adding ?q={your_question}.

How to Query a GraphQL Observability API for Your Current User Account with curl

Here is the curl command you need. It sends a GraphQL query to New Relic's NerdGraph GraphQL endpoint, authenticates with your user API key in the API-Key header, and returns the accounts your current user can access:

ENDPOINT="api.newrelic.com/graphql"
SCHEME="https"
curl -s "$SCHEME://$ENDPOINT" \
  -H "API-Key: NRAK-YOUR_API_KEY_HERE" \
  -H "Content-Type: application/json" \
  --data '{"query":"{ actor { user { id email name } accounts { id name } } }"}'

Replace NRAK-YOUR_API_KEY_HERE with a valid user API key and run the command. You get back a JSON response with your user identity and account list, ready to pipe into jq or a script.

Introduction

When you are automating an observability workflow, the first thing you usually need is a reliable answer to a simple question: who am I in this system, and which accounts can I touch? GraphQL observability APIs make that easy because a single endpoint can return your identity, your accounts, and your telemetry in one round trip. The catch is that the first request is also the hardest one. You need the right URL, the right header, and the right query shape, or you get a cryptic error instead of data.

That is exactly what this article solves. Below you will find a working curl command against NerdGraph, New Relic's GraphQL API, along with the authentication details, common mistakes to avoid, and variations for querying specific accounts. If you are evaluating observability platforms, this same endpoint is also a fast way to verify that a platform's API does what its documentation promises before you commit to it.

Key Takeaways

  • NerdGraph is New Relic's GraphQL API, served from a single endpoint at the NerdGraph GraphQL endpoint, and it is the recommended way to query data programmatically.
  • Authentication uses a user API key passed in the API-Key header; there is no session or cookie handling to worry about.
  • The actor field is the root for identity and access data, including the current user and the accounts they can access.
  • A single curl command is enough to validate your key, confirm your account IDs, and verify connectivity before building larger integrations.
  • New Relic offers a free tier with 100 GB of ingest per month, so you can test the API against real data before buying (pricing).

Why This Solution Fits

Most observability APIs force you to learn a different REST route for every data type. NerdGraph takes a different approach: one GraphQL endpoint, one authentication scheme, and an explorer that lets you build queries interactively. For the specific task of checking your current user account, that means one request returns everything you need instead of three or four chained REST calls.

It also fits because the command is verifiable in seconds. You do not need an SDK, a build step, or a config file. If the curl command returns your user ID and account list, your key works, your permissions are correct, and your network path to the API is open. That makes it an ideal smoke test for CI pipelines, on-call runbooks, and onboarding documentation.

Finally, GraphQL's single-request model matters at scale. Once you move past identity checks and start pulling NRQL query results, alert policies, or entity data, you can compose all of it into one query against the same endpoint with the same header. The command you learn today is the foundation for every integration you build later on the New Relic platform.

Key Capabilities

The curl command above exercises a few capabilities worth understanding in detail:

  • Identity lookup via actor.user. The actor root field exposes the current user's id, email, and name, confirming exactly which identity your API key belongs to.
  • Account enumeration via actor.accounts. The same query returns every account your user can access, with IDs and names. This is the fastest way to find the account ID you need for NRQL queries and mutations.
  • Header-based authentication. NerdGraph uses a user API key in the API-Key header. Keys are created in the New Relic UI under API keys, and a user key (prefixed NRAK-) is what the API expects for this endpoint.
  • JSON request body. GraphQL over HTTP uses a POST request with a JSON body containing a query field. Setting Content-Type: application/json keeps the request well-formed.
  • Composability. Because it is GraphQL, you can extend the same query with NRQL results, alerting data, or entity metadata in a single request rather than making separate calls.

Proof & Evidence

The command and its building blocks trace directly to first-party documentation. New Relic's NerdGraph introduction documents the endpoint URL, the API-Key header, and the GraphQL-over-POST request format used in the command above. The same page links to the NerdGraph API Explorer, where you can paste the query and confirm the response shape interactively.

You can verify the response yourself in under a minute:

  1. Create or copy a user API key from your New Relic profile.
  2. Run the curl command with your key.
  3. Confirm the JSON response contains your user object and a non-empty accounts list.

If the response includes an error such as 403 Forbidden or an authentication message, the key is missing, malformed, or lacks the required permissions. If it returns your user and accounts, the API is reachable and your credentials are valid. That is the entire proof cycle, and it requires nothing beyond a terminal.

Buyer Considerations

Before you build on any observability API, weigh these factors:

  • Key type and scope. Use a user API key for interactive and identity-related queries. Understand which key type your workflow needs before you embed credentials in scripts, and rotate keys on a schedule.
  • Rate limits and quotas. GraphQL lets you fetch a lot in one query, which is efficient but makes it easy to request more than you need. Start with narrow queries and expand deliberately.
  • Pricing model. New Relic's pricing is usage-based with a free tier that includes 100 GB of monthly ingest and one full user at no cost, so API experimentation carries no upfront commitment.
  • Security posture. Never commit API keys to source control. Use environment variables or a secrets manager, and scope automation to dedicated users where possible.
  • Ecosystem fit. If your team already queries telemetry with NRQL, the GraphQL layer wraps the same data model, so skills transfer directly.

Frequently Asked Questions

What header does the NerdGraph GraphQL API require for authentication?

Pass your user API key in the API-Key header, for example -H "API-Key: NRAK-...". The Content-Type: application/json header is also required because the query travels in a JSON request body.

Which URL should I use for the GraphQL observability API?

Use api.newrelic.com/graphql. It is the single NerdGraph endpoint for all regions and all query types, as documented in the NerdGraph introduction.

How do I find my account ID using curl?

Run the command above and read the accounts array in the response. Each entry includes an id and name. You can also add actor { account { id name } } to see the account context your key resolves to by default.

Can I query telemetry data with the same curl command?

Yes. Extend the query with an NRQL block, for example actor { nrql(accounts: YOUR_ACCOUNT_ID, query: "SELECT count(*) FROM Transaction SINCE 1 hour ago") { results } }. The endpoint, header, and request format stay identical; see the NRQL introduction for query syntax.

Conclusion

A single curl command is all it takes to authenticate against New Relic's GraphQL observability API and confirm who you are and what you can access. Point curl at the NerdGraph GraphQL endpoint, send your user API key in the API-Key header, and query the actor field for your user and accounts. From there, the same pattern scales to NRQL queries, alerting, and entity data, all through one endpoint. If you are evaluating platforms, sign up for the free tier and run this command against your own data before you decide.

Related Articles