--- title: customerSmsMarketingSubscribe - Storefront API description: Subscribes a customer to the newsletter with a phone number. api_version: unstable api_name: storefront source_url: html: https://shopify.dev/docs/api/storefront/unstable/mutations/customersmsmarketingsubscribe md: https://shopify.dev/docs/api/storefront/unstable/mutations/customersmsmarketingsubscribe.md --- # customer​Sms​Marketing​Subscribe mutation Requires `unauthenticated_write_customers` access scope. Subscribes a customer to the newsletter with a phone number. ## Arguments * phone​Number [String!](https://shopify.dev/docs/api/storefront/unstable/scalars/String) required The customer's phone number. *** ## Customer​Sms​Marketing​Subscribe​Payload returns * customer [Customer​Marketing​Subscribe](https://shopify.dev/docs/api/storefront/unstable/objects/CustomerMarketingSubscribe) The created customer object. * customer​User​Errors [\[Customer​User​Error!\]!](https://shopify.dev/docs/api/storefront/unstable/objects/CustomerUserError) non-null The list of errors that occurred from executing the mutation. *** ## Examples * ### Subscribe a customer to your newsletter with a phone number #### Description Subscribe a customer to your newsletter with a phone number #### Query ```graphql mutation customerSmsMarketingSubscribe($phoneNumber: String!) { customerSmsMarketingSubscribe(phoneNumber: $phoneNumber) { customer { phone } customerUserErrors { field message code } } } ``` #### Variables ```json { "phoneNumber": "+16475555555" } ``` #### cURL ```bash curl -X POST \ https://your-development-store.myshopify.com/api/unstable/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Storefront-Access-Token: {storefront_access_token}' \ -d '{ "query": "mutation customerSmsMarketingSubscribe($phoneNumber: String!) { customerSmsMarketingSubscribe(phoneNumber: $phoneNumber) { customer { phone } customerUserErrors { field message code } } }", "variables": { "phoneNumber": "+16475555555" } }' ``` #### React Router ```javascript import { unauthenticated } from "../shopify.server"; export const loader = async () => { const { storefront } = await unauthenticated.storefront( 'your-development-store.myshopify.com' ); const response = await storefront.graphql( `#graphql mutation customerSmsMarketingSubscribe($phoneNumber: String!) { customerSmsMarketingSubscribe(phoneNumber: $phoneNumber) { customer { phone } customerUserErrors { field message code } } }`, { variables: { "phoneNumber": "+16475555555" }, }, ); const json = await response.json(); return json.data; } ``` #### Node.js ```javascript const client = new shopify.clients.Storefront({ domain: 'your-development-store.myshopify.com', storefrontAccessToken, }); const data = await client.query({ data: { "query": `mutation customerSmsMarketingSubscribe($phoneNumber: String!) { customerSmsMarketingSubscribe(phoneNumber: $phoneNumber) { customer { phone } customerUserErrors { field message code } } }`, "variables": { "phoneNumber": "+16475555555" }, }, }); ``` #### Response ```json { "customerSmsMarketingSubscribe": { "customer": { "phone": "+16475555555" }, "customerUserErrors": [] } } ``` * ### customerSmsMarketingSubscribe reference [Open in GraphiQL](http://localhost:3457/graphiql?query=mutation%20customerSmsMarketingSubscribe\(%24phoneNumber%3A%20String!\)%20%7B%0A%20%20customerSmsMarketingSubscribe\(phoneNumber%3A%20%24phoneNumber\)%20%7B%0A%20%20%20%20customer%20%7B%0A%20%20%20%20%20%20phone%0A%20%20%20%20%7D%0A%20%20%20%20customerUserErrors%20%7B%0A%20%20%20%20%20%20field%0A%20%20%20%20%20%20message%0A%20%20%20%20%20%20code%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D\&variables=%7B%0A%20%20%22phoneNumber%22%3A%20%22%2B16475555555%22%0A%7D) ##### GQL ```graphql mutation customerSmsMarketingSubscribe($phoneNumber: String!) { customerSmsMarketingSubscribe(phoneNumber: $phoneNumber) { customer { phone } customerUserErrors { field message code } } } ``` ##### cURL ```bash curl -X POST \ https://your-development-store.myshopify.com/api/unstable/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Storefront-Access-Token: {storefront_access_token}' \ -d '{ "query": "mutation customerSmsMarketingSubscribe($phoneNumber: String!) { customerSmsMarketingSubscribe(phoneNumber: $phoneNumber) { customer { phone } customerUserErrors { field message code } } }", "variables": { "phoneNumber": "+16475555555" } }' ``` ##### React Router ```javascript import { unauthenticated } from "../shopify.server"; export const loader = async () => { const { storefront } = await unauthenticated.storefront( 'your-development-store.myshopify.com' ); const response = await storefront.graphql( `#graphql mutation customerSmsMarketingSubscribe($phoneNumber: String!) { customerSmsMarketingSubscribe(phoneNumber: $phoneNumber) { customer { phone } customerUserErrors { field message code } } }`, { variables: { "phoneNumber": "+16475555555" }, }, ); const json = await response.json(); return json.data; } ``` ##### Node.js ```javascript const client = new shopify.clients.Storefront({ domain: 'your-development-store.myshopify.com', storefrontAccessToken, }); const data = await client.query({ data: { "query": `mutation customerSmsMarketingSubscribe($phoneNumber: String!) { customerSmsMarketingSubscribe(phoneNumber: $phoneNumber) { customer { phone } customerUserErrors { field message code } } }`, "variables": { "phoneNumber": "+16475555555" }, }, }); ``` ## Input variables JSON ```json { "phoneNumber": "+16475555555" } ``` ## Response JSON ```json { "customerSmsMarketingSubscribe": { "customer": { "phone": "+16475555555" }, "customerUserErrors": [] } } ```