customer Sms Marketing Consent Updatemutation
mutation
2024-07
Requires
write_customers
access scope. Also: User needs customers permission.
Update a customer's SMS marketing consent information.
Arguments
Specifies the input fields to update a customer's SMS marketing consent information.
Was this section helpful?
CustomerSmsMarketingConsentUpdatePayload returns
The updated customer.
The list of errors that occurred from executing the mutation.
Was this section helpful?
Examples
Hide code
Copy
mutation customerSmsMarketingConsentUpdate($input: CustomerSmsMarketingConsentUpdateInput!) { customerSmsMarketingConsentUpdate(input: $input) { userErrors { field message } customer { id phone smsMarketingConsent { marketingState marketingOptInLevel consentUpdatedAt consentCollectedFrom } } } }
curl -X POST \ https://your-development-store.myshopify.com/admin/api/2024-07/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "mutation customerSmsMarketingConsentUpdate($input: CustomerSmsMarketingConsentUpdateInput!) { customerSmsMarketingConsentUpdate(input: $input) { userErrors { field message } customer { id phone smsMarketingConsent { marketingState marketingOptInLevel consentUpdatedAt consentCollectedFrom } } } }", "variables": { "input": { "customerId": "gid://shopify/Customer/207119551", "smsMarketingConsent": { "marketingState": "SUBSCRIBED", "marketingOptInLevel": "SINGLE_OPT_IN" } } } }'
const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql mutation customerSmsMarketingConsentUpdate($input: CustomerSmsMarketingConsentUpdateInput!) { customerSmsMarketingConsentUpdate(input: $input) { userErrors { field message } customer { id phone smsMarketingConsent { marketingState marketingOptInLevel consentUpdatedAt consentCollectedFrom } } } }`, { variables: { "input": { "customerId": "gid://shopify/Customer/207119551", "smsMarketingConsent": { "marketingState": "SUBSCRIBED", "marketingOptInLevel": "SINGLE_OPT_IN" } } }, }, ); const data = await response.json();
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 mutation customerSmsMarketingConsentUpdate($input: CustomerSmsMarketingConsentUpdateInput!) { customerSmsMarketingConsentUpdate(input: $input) { userErrors { field message } customer { id phone smsMarketingConsent { marketingState marketingOptInLevel consentUpdatedAt consentCollectedFrom } } } } QUERY variables = { "input": { "customerId": "gid://shopify/Customer/207119551", "smsMarketingConsent": { "marketingState": "SUBSCRIBED", "marketingOptInLevel": "SINGLE_OPT_IN" } } } response = client.query(query: query, variables: variables)
const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `mutation customerSmsMarketingConsentUpdate($input: CustomerSmsMarketingConsentUpdateInput!) { customerSmsMarketingConsentUpdate(input: $input) { userErrors { field message } customer { id phone smsMarketingConsent { marketingState marketingOptInLevel consentUpdatedAt consentCollectedFrom } } } }`, "variables": { "input": { "customerId": "gid://shopify/Customer/207119551", "smsMarketingConsent": { "marketingState": "SUBSCRIBED", "marketingOptInLevel": "SINGLE_OPT_IN" } } }, }, });
use Shopify\Clients\Graphql; $client = new Graphql("your-development-store.myshopify.com", $accessToken); $query = <<<QUERY mutation customerSmsMarketingConsentUpdate($input: CustomerSmsMarketingConsentUpdateInput!) { customerSmsMarketingConsentUpdate(input: $input) { userErrors { field message } customer { id phone smsMarketingConsent { marketingState marketingOptInLevel consentUpdatedAt consentCollectedFrom } } } } QUERY; $variables = [ "input" => [ "customerId" => "gid://shopify/Customer/207119551", "smsMarketingConsent" => [ "marketingState" => "SUBSCRIBED", "marketingOptInLevel" => "SINGLE_OPT_IN", ], ], ]; $response = $client->query(["query" => $query, "variables" => $variables]);
Hide code
Input variables
Copy
{ "input": { "customerId": "gid://shopify/Customer/207119551", "smsMarketingConsent": { "marketingState": "SUBSCRIBED", "marketingOptInLevel": "SINGLE_OPT_IN" } } }
Hide code
Response
JSON
{ "customerSmsMarketingConsentUpdate": { "userErrors": [], "customer": { "id": "gid://shopify/Customer/207119551", "phone": "+16136120707", "smsMarketingConsent": { "marketingState": "SUBSCRIBED", "marketingOptInLevel": "SINGLE_OPT_IN", "consentUpdatedAt": "2024-09-12T01:08:05Z", "consentCollectedFrom": "OTHER" } } } }