--- title: customerByIdentifier - GraphQL Admin description: Return a customer by an identifier. api_version: 2025-10 api_name: admin type: query api_type: graphql source_url: html: https://shopify.dev/docs/api/admin-graphql/latest/queries/customerByIdentifier md: https://shopify.dev/docs/api/admin-graphql/latest/queries/customerByIdentifier.md --- # customer​By​Identifier query Requires `read_customers` access scope. Return a customer by an identifier. ## Arguments * identifier [Customer​Identifier​Input!](https://shopify.dev/docs/api/admin-graphql/latest/input-objects/CustomerIdentifierInput) required The identifier of the customer. *** ## Possible returns * Customer [Customer](https://shopify.dev/docs/api/admin-graphql/latest/objects/Customer) Represents information about a customer of the shop, such as the customer's contact details, their order history, and whether they've agreed to receive marketing material by email. **Caution:** Only use this data if it's required for your app's functionality. Shopify will restrict [access to scopes](https://shopify.dev/api/usage/access-scopes) for apps that don't have a legitimate use for the associated data. *** ## Examples * ### Find a customer by custom id #### Query ```graphql query($identifier: CustomerIdentifierInput!) { customer: customerByIdentifier(identifier: $identifier) { id amountSpent { amount currencyCode } } } ``` #### Variables ```json { "identifier": { "customId": { "namespace": "custom", "key": "id", "value": "16a3a6dd" } } } ``` #### cURL ```bash curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-10/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "query($identifier: CustomerIdentifierInput!) { customer: customerByIdentifier(identifier: $identifier) { id amountSpent { amount currencyCode } } }", "variables": { "identifier": { "customId": { "namespace": "custom", "key": "id", "value": "16a3a6dd" } } } }' ``` #### React Router ```javascript import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql query($identifier: CustomerIdentifierInput!) { customer: customerByIdentifier(identifier: $identifier) { id amountSpent { amount currencyCode } } }`, { variables: { "identifier": { "customId": { "namespace": "custom", "key": "id", "value": "16a3a6dd" } } }, }, ); const json = await response.json(); return json.data; } ``` #### Ruby ```ruby session = ShopifyAPI::Auth::Session.new( shop: "your-development-store.myshopify.com", access_token: access_token ) client = ShopifyAPI::Clients::Graphql::Admin.new( session: session ) query = <<~QUERY query($identifier: CustomerIdentifierInput!) { customer: customerByIdentifier(identifier: $identifier) { id amountSpent { amount currencyCode } } } QUERY variables = { "identifier": { "customId": { "namespace": "custom", "key": "id", "value": "16a3a6dd" } } } response = client.query(query: query, variables: variables) ``` #### Node.js ```javascript const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `query($identifier: CustomerIdentifierInput!) { customer: customerByIdentifier(identifier: $identifier) { id amountSpent { amount currencyCode } } }`, "variables": { "identifier": { "customId": { "namespace": "custom", "key": "id", "value": "16a3a6dd" } } }, }, }); ``` #### Response ```json { "customer": { "id": "gid://shopify/Customer/544365967", "amountSpent": { "amount": "8305.6", "currencyCode": "USD" } } } ``` * ### Find a customer by email address #### Query ```graphql query($identifier: CustomerIdentifierInput!) { customer: customerByIdentifier(identifier: $identifier) { id amountSpent { amount currencyCode } } } ``` #### Variables ```json { "identifier": { "emailAddress": "bob@example.com" } } ``` #### cURL ```bash curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-10/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "query($identifier: CustomerIdentifierInput!) { customer: customerByIdentifier(identifier: $identifier) { id amountSpent { amount currencyCode } } }", "variables": { "identifier": { "emailAddress": "bob@example.com" } } }' ``` #### React Router ```javascript import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql query($identifier: CustomerIdentifierInput!) { customer: customerByIdentifier(identifier: $identifier) { id amountSpent { amount currencyCode } } }`, { variables: { "identifier": { "emailAddress": "bob@example.com" } }, }, ); const json = await response.json(); return json.data; } ``` #### Ruby ```ruby session = ShopifyAPI::Auth::Session.new( shop: "your-development-store.myshopify.com", access_token: access_token ) client = ShopifyAPI::Clients::Graphql::Admin.new( session: session ) query = <<~QUERY query($identifier: CustomerIdentifierInput!) { customer: customerByIdentifier(identifier: $identifier) { id amountSpent { amount currencyCode } } } QUERY variables = { "identifier": { "emailAddress": "bob@example.com" } } response = client.query(query: query, variables: variables) ``` #### Node.js ```javascript const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `query($identifier: CustomerIdentifierInput!) { customer: customerByIdentifier(identifier: $identifier) { id amountSpent { amount currencyCode } } }`, "variables": { "identifier": { "emailAddress": "bob@example.com" } }, }, }); ``` #### Response ```json { "customer": { "id": "gid://shopify/Customer/544365967", "amountSpent": { "amount": "8305.6", "currencyCode": "USD" } } } ``` * ### Find a customer by phone number #### Query ```graphql query($identifier: CustomerIdentifierInput!) { customer: customerByIdentifier(identifier: $identifier) { id amountSpent { amount currencyCode } } } ``` #### Variables ```json { "identifier": { "phoneNumber": "+13125551212" } } ``` #### cURL ```bash curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-10/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "query($identifier: CustomerIdentifierInput!) { customer: customerByIdentifier(identifier: $identifier) { id amountSpent { amount currencyCode } } }", "variables": { "identifier": { "phoneNumber": "+13125551212" } } }' ``` #### React Router ```javascript import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql query($identifier: CustomerIdentifierInput!) { customer: customerByIdentifier(identifier: $identifier) { id amountSpent { amount currencyCode } } }`, { variables: { "identifier": { "phoneNumber": "+13125551212" } }, }, ); const json = await response.json(); return json.data; } ``` #### Ruby ```ruby session = ShopifyAPI::Auth::Session.new( shop: "your-development-store.myshopify.com", access_token: access_token ) client = ShopifyAPI::Clients::Graphql::Admin.new( session: session ) query = <<~QUERY query($identifier: CustomerIdentifierInput!) { customer: customerByIdentifier(identifier: $identifier) { id amountSpent { amount currencyCode } } } QUERY variables = { "identifier": { "phoneNumber": "+13125551212" } } response = client.query(query: query, variables: variables) ``` #### Node.js ```javascript const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `query($identifier: CustomerIdentifierInput!) { customer: customerByIdentifier(identifier: $identifier) { id amountSpent { amount currencyCode } } }`, "variables": { "identifier": { "phoneNumber": "+13125551212" } }, }, }); ``` #### Response ```json { "customer": { "id": "gid://shopify/Customer/544365967", "amountSpent": { "amount": "8305.6", "currencyCode": "USD" } } } ``` [Open in GraphiQL](http://localhost:3457/graphiql?query=query\(%24identifier%3A%20CustomerIdentifierInput!\)%20%7B%0A%20%20customer%3A%20customerByIdentifier\(identifier%3A%20%24identifier\)%20%7B%0A%20%20%20%20id%0A%20%20%20%20amountSpent%20%7B%0A%20%20%20%20%20%20amount%0A%20%20%20%20%20%20currencyCode%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D\&variables=%7B%0A%20%20%22identifier%22%3A%20%7B%0A%20%20%20%20%22customId%22%3A%20%7B%0A%20%20%20%20%20%20%22namespace%22%3A%20%22custom%22%2C%0A%20%20%20%20%20%20%22key%22%3A%20%22id%22%2C%0A%20%20%20%20%20%20%22value%22%3A%20%2216a3a6dd%22%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D) ```javascript import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql query($identifier: CustomerIdentifierInput!) { customer: customerByIdentifier(identifier: $identifier) { id amountSpent { amount currencyCode } } }`, { variables: { "identifier": { "customId": { "namespace": "custom", "key": "id", "value": "16a3a6dd" } } }, }, ); const json = await response.json(); return json.data; } ``` ##### GQL ``` query($identifier: CustomerIdentifierInput!) { customer: customerByIdentifier(identifier: $identifier) { id amountSpent { amount currencyCode } } } ``` ##### cURL ``` curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-10/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "query($identifier: CustomerIdentifierInput!) { customer: customerByIdentifier(identifier: $identifier) { id amountSpent { amount currencyCode } } }", "variables": { "identifier": { "customId": { "namespace": "custom", "key": "id", "value": "16a3a6dd" } } } }' ``` ##### React Router ``` import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql query($identifier: CustomerIdentifierInput!) { customer: customerByIdentifier(identifier: $identifier) { id amountSpent { amount currencyCode } } }`, { variables: { "identifier": { "customId": { "namespace": "custom", "key": "id", "value": "16a3a6dd" } } }, }, ); const json = await response.json(); return json.data; } ``` ##### Node.js ``` const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `query($identifier: CustomerIdentifierInput!) { customer: customerByIdentifier(identifier: $identifier) { id amountSpent { amount currencyCode } } }`, "variables": { "identifier": { "customId": { "namespace": "custom", "key": "id", "value": "16a3a6dd" } } }, }, }); ``` ##### Ruby ``` session = ShopifyAPI::Auth::Session.new( shop: "your-development-store.myshopify.com", access_token: access_token ) client = ShopifyAPI::Clients::Graphql::Admin.new( session: session ) query = <<~QUERY query($identifier: CustomerIdentifierInput!) { customer: customerByIdentifier(identifier: $identifier) { id amountSpent { amount currencyCode } } } QUERY variables = { "identifier": { "customId": { "namespace": "custom", "key": "id", "value": "16a3a6dd" } } } response = client.query(query: query, variables: variables) ``` ## Input variables JSON ```json { "identifier": { "customId": { "namespace": "custom", "key": "id", "value": "16a3a6dd" } } } ``` ## Response JSON ```json { "customer": { "id": "gid://shopify/Customer/544365967", "amountSpent": { "amount": "8305.6", "currencyCode": "USD" } } } ```