# customerByIdentifier - admin - QUERY Version: 2025-01 ## Description Return a customer by an identifier. ### Access Scopes `read_customers` access scope. ## Arguments * [identifier](/docs/api/admin/2025-01/input-objects/CustomerIdentifierInput): CustomerIdentifierInput! - The identifier of the customer. ## Returns * [addresses](/docs/api/admin/2025-01/objects/MailingAddress): MailingAddress! A list of addresses associated with the customer. * [amountSpent](/docs/api/admin/2025-01/objects/MoneyV2): MoneyV2! The total amount that the customer has spent on orders in their lifetime. * [canDelete](/docs/api/admin/2025-01/scalars/Boolean): Boolean! Whether the merchant can delete the customer from their store. A customer can be deleted from a store only if they haven't yet made an order. After a customer makes an order, they can't be deleted from a store. * [companyContactProfiles](/docs/api/admin/2025-01/objects/CompanyContact): CompanyContact! A list of the customer's company contact profiles. * [createdAt](/docs/api/admin/2025-01/scalars/DateTime): DateTime! The date and time when the customer was added to the store. * [dataSaleOptOut](/docs/api/admin/2025-01/scalars/Boolean): Boolean! Whether the customer has opted out of having their data sold. * [defaultAddress](/docs/api/admin/2025-01/objects/MailingAddress): MailingAddress The default address associated with the customer. * [displayName](/docs/api/admin/2025-01/scalars/String): String! The full name of the customer, based on the values for first_name and last_name. If the first_name and last_name are not available, then this falls back to the customer's email address, and if that is not available, the customer's phone number. * [email](/docs/api/admin/2025-01/scalars/String): String The customer's email address. * [emailMarketingConsent](/docs/api/admin/2025-01/objects/CustomerEmailMarketingConsentState): CustomerEmailMarketingConsentState The current email marketing state for the customer. If the customer doesn't have an email address, then this property is `null`. * [firstName](/docs/api/admin/2025-01/scalars/String): String The customer's first name. * [hasTimelineComment](/docs/api/admin/2025-01/scalars/Boolean): Boolean! Whether the merchant has added timeline comments about the customer on the customer's page. * [id](/docs/api/admin/2025-01/scalars/ID): ID! A globally-unique ID. * [image](/docs/api/admin/2025-01/objects/Image): Image! The image associated with the customer. * [lastName](/docs/api/admin/2025-01/scalars/String): String The customer's last name. * [lastOrder](/docs/api/admin/2025-01/objects/Order): Order The customer's last order. * [legacyResourceId](/docs/api/admin/2025-01/scalars/UnsignedInt64): UnsignedInt64! The ID of the corresponding resource in the REST Admin API. * [lifetimeDuration](/docs/api/admin/2025-01/scalars/String): String! The amount of time since the customer was first added to the store. Example: 'about 12 years'. * [locale](/docs/api/admin/2025-01/scalars/String): String! The customer's locale. * [market](/docs/api/admin/2025-01/objects/Market): Market The market that includes the customer’s default address. * [mergeable](/docs/api/admin/2025-01/objects/CustomerMergeable): CustomerMergeable! Whether the customer can be merged with another customer. * [metafield](/docs/api/admin/2025-01/objects/Metafield): Metafield A [custom field](https://shopify.dev/docs/apps/build/custom-data), including its `namespace` and `key`, that's associated with a Shopify resource for the purposes of adding and storing additional information. * [multipassIdentifier](/docs/api/admin/2025-01/scalars/String): String A unique identifier for the customer that's used with Multipass login. * [note](/docs/api/admin/2025-01/scalars/String): String A note about the customer. * [numberOfOrders](/docs/api/admin/2025-01/scalars/UnsignedInt64): UnsignedInt64! The number of orders that the customer has made at the store in their lifetime. * [phone](/docs/api/admin/2025-01/scalars/String): String The customer's phone number. * [productSubscriberStatus](/docs/api/admin/2025-01/enums/CustomerProductSubscriberStatus): CustomerProductSubscriberStatus! Possible subscriber states of a customer defined by their subscription contracts. * [smsMarketingConsent](/docs/api/admin/2025-01/objects/CustomerSmsMarketingConsentState): CustomerSmsMarketingConsentState The current SMS marketing state for the customer's phone number. If the customer does not have a phone number, then this property is `null`. * [state](/docs/api/admin/2025-01/enums/CustomerState): CustomerState! The state of the customer's account with the shop. Please note that this only meaningful when Classic Customer Accounts is active. * [statistics](/docs/api/admin/2025-01/objects/CustomerStatistics): CustomerStatistics! The statistics for a given customer. * [tags](/docs/api/admin/2025-01/scalars/String): String! A comma separated list of tags that have been added to the customer. * [taxExempt](/docs/api/admin/2025-01/scalars/Boolean): Boolean! Whether the customer is exempt from being charged taxes on their orders. * [taxExemptions](/docs/api/admin/2025-01/enums/TaxExemption): TaxExemption! The list of tax exemptions applied to the customer. * [unsubscribeUrl](/docs/api/admin/2025-01/scalars/URL): URL! The URL to unsubscribe the customer from the mailing list. * [updatedAt](/docs/api/admin/2025-01/scalars/DateTime): DateTime! The date and time when the customer was last updated. * [validEmailAddress](/docs/api/admin/2025-01/scalars/Boolean): Boolean! Whether the email address is formatted correctly. Returns `true` when the email is formatted correctly and belongs to an existing domain. This doesn't guarantee that the email address actually exists. * [verifiedEmail](/docs/api/admin/2025-01/scalars/Boolean): Boolean! Whether the customer has verified their email address. Defaults to `true` if the customer is created through the Shopify admin or API. ## Examples ### Find a customer by custom id Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query($identifier: CustomerIdentifierInput!) { customer: customerByIdentifier(identifier: $identifier) { id amountSpent { amount currencyCode } } }\",\n \"variables\": {\n \"identifier\": {\n \"customId\": {\n \"namespace\": \"custom\",\n \"key\": \"id\",\n \"value\": \"16a3a6dd\"\n }\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `query($identifier: CustomerIdentifierInput!) {\n customer: customerByIdentifier(identifier: $identifier) {\n id\n amountSpent {\n amount\n currencyCode\n }\n }\n }`,\n \"variables\": {\n \"identifier\": {\n \"customId\": {\n \"namespace\": \"custom\",\n \"key\": \"id\",\n \"value\": \"16a3a6dd\"\n }\n }\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n query($identifier: CustomerIdentifierInput!) {\n customer: customerByIdentifier(identifier: $identifier) {\n id\n amountSpent {\n amount\n currencyCode\n }\n }\n }\nQUERY\n\nvariables = {\n \"identifier\": {\n \"customId\": {\n \"namespace\": \"custom\",\n \"key\": \"id\",\n \"value\": \"16a3a6dd\"\n }\n }\n}\n\nresponse = client.query(query: query, variables: variables)\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query($identifier: CustomerIdentifierInput!) {\n customer: customerByIdentifier(identifier: $identifier) {\n id\n amountSpent {\n amount\n currencyCode\n }\n }\n }`,\n {\n variables: {\n \"identifier\": {\n \"customId\": {\n \"namespace\": \"custom\",\n \"key\": \"id\",\n \"value\": \"16a3a6dd\"\n }\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "query($identifier: CustomerIdentifierInput!) {\n customer: customerByIdentifier(identifier: $identifier) {\n id\n amountSpent {\n amount\n currencyCode\n }\n }\n}" #### Graphql Input { "identifier": { "customId": { "namespace": "custom", "key": "id", "value": "16a3a6dd" } } } #### Graphql Response { "data": { "customer": { "id": "gid://shopify/Customer/544365967", "amountSpent": { "amount": "8305.6", "currencyCode": "USD" } } } } ### Find a customer by email address Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query($identifier: CustomerIdentifierInput!) { customer: customerByIdentifier(identifier: $identifier) { id amountSpent { amount currencyCode } } }\",\n \"variables\": {\n \"identifier\": {\n \"emailAddress\": \"bob@example.com\"\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `query($identifier: CustomerIdentifierInput!) {\n customer: customerByIdentifier(identifier: $identifier) {\n id\n amountSpent {\n amount\n currencyCode\n }\n }\n }`,\n \"variables\": {\n \"identifier\": {\n \"emailAddress\": \"bob@example.com\"\n }\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n query($identifier: CustomerIdentifierInput!) {\n customer: customerByIdentifier(identifier: $identifier) {\n id\n amountSpent {\n amount\n currencyCode\n }\n }\n }\nQUERY\n\nvariables = {\n \"identifier\": {\n \"emailAddress\": \"bob@example.com\"\n }\n}\n\nresponse = client.query(query: query, variables: variables)\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query($identifier: CustomerIdentifierInput!) {\n customer: customerByIdentifier(identifier: $identifier) {\n id\n amountSpent {\n amount\n currencyCode\n }\n }\n }`,\n {\n variables: {\n \"identifier\": {\n \"emailAddress\": \"bob@example.com\"\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "query($identifier: CustomerIdentifierInput!) {\n customer: customerByIdentifier(identifier: $identifier) {\n id\n amountSpent {\n amount\n currencyCode\n }\n }\n}" #### Graphql Input { "identifier": { "emailAddress": "bob@example.com" } } #### Graphql Response { "data": { "customer": { "id": "gid://shopify/Customer/544365967", "amountSpent": { "amount": "8305.6", "currencyCode": "USD" } } } } ### Find a customer by phone number Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query($identifier: CustomerIdentifierInput!) { customer: customerByIdentifier(identifier: $identifier) { id amountSpent { amount currencyCode } } }\",\n \"variables\": {\n \"identifier\": {\n \"phoneNumber\": \"+13125551212\"\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `query($identifier: CustomerIdentifierInput!) {\n customer: customerByIdentifier(identifier: $identifier) {\n id\n amountSpent {\n amount\n currencyCode\n }\n }\n }`,\n \"variables\": {\n \"identifier\": {\n \"phoneNumber\": \"+13125551212\"\n }\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n query($identifier: CustomerIdentifierInput!) {\n customer: customerByIdentifier(identifier: $identifier) {\n id\n amountSpent {\n amount\n currencyCode\n }\n }\n }\nQUERY\n\nvariables = {\n \"identifier\": {\n \"phoneNumber\": \"+13125551212\"\n }\n}\n\nresponse = client.query(query: query, variables: variables)\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query($identifier: CustomerIdentifierInput!) {\n customer: customerByIdentifier(identifier: $identifier) {\n id\n amountSpent {\n amount\n currencyCode\n }\n }\n }`,\n {\n variables: {\n \"identifier\": {\n \"phoneNumber\": \"+13125551212\"\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "query($identifier: CustomerIdentifierInput!) {\n customer: customerByIdentifier(identifier: $identifier) {\n id\n amountSpent {\n amount\n currencyCode\n }\n }\n}" #### Graphql Input { "identifier": { "phoneNumber": "+13125551212" } } #### Graphql Response { "data": { "customer": { "id": "gid://shopify/Customer/544365967", "amountSpent": { "amount": "8305.6", "currencyCode": "USD" } } } }