Customer Account API making requests via API

Topic summary

A developer is encountering a “Not a valid access token” error when attempting to make requests to Shopify’s Customer Account API using GraphQL.

Key Issues Identified:

  • The official documentation contains errors in the example code, particularly in the request structure
  • The developer has an authenticated user’s access token but cannot successfully authenticate API requests
  • Headers are being set with Authorization containing the access token in format 'atka_****_****_****'

Solution Provided:

Another user suggests replacing the Authorization header with X-Shopify-Access-Token instead. This appears to be the correct header format for Customer Account API requests, differing from what’s shown in the documentation example.

The discussion highlights a discrepancy between the official documentation and the actual API requirements for authentication headers.

Summarized with AI on November 6. AI used: claude-sonnet-4-5-20250929.

I am using Customer Account API to use customer account in my application.

Considering the docs, it says I should use Access Token to make requests to gql, but I am always have this error:

“Not a valid access token”.

They also have the mistake in the example:

const response = await fetch(
'https://shopify.com/<shop-id>/account/customer/api/2024-07/graphql',
  {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      Authorization: {access_token},
    },
    body: JSON.stringify({
      operationName: 'SomeQuery',
      'query { customer { emailAddress { emailAddress }}}',
      variables: {},
    }),
  },

This code will never work, what is happening in the request body..??

This is how I try to make requests:

	query(query) {
		if (!query) return;
		const headers = {
			'Content-Type': 'application/json',
			Authorization: `${this.cookies.get('auth-token')}`,
		};

		console.debug(headers);

		return this.fetch(this.baseUrl, {
			method: 'POST',
			headers,
			body: JSON.stringify({ query }),
		});
	}

And my headers contain:

{
  'Content-Type': 'application/json',
  Authorization: 'atkn_****_****_****'
}

API response in this case:

{ errors: [ { message: 'Not a valid access token' } ] }

I also have access token of authenticated user, and other stuff that docs described before “Endpoint and queries” section.

So how to make authenticated request to get my authenticated customer data?

Hi @Kkkkk3

Use ‘X-Shopify Access Token’ instead of ‘Authorization’

const response = await fetch(
'https://shopify.com/