customer Sms Marketing Consent Updatemutation
mutation
2024-10latest
Requires write
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?
Code examples for MUTATION: customerSmsMarketingConsentUpdate
Query Reference for MUTATION: customerSmsMarketingConsentUpdate
"mutation customerSmsMarketingConsentUpdate($input: CustomerSmsMarketingConsentUpdateInput!) {\n customerSmsMarketingConsentUpdate(input: $input) {\n customer {\n # Customer fields\n }\n userErrors {\n field\n message\n }\n }\n}"
Input Reference for MUTATION: customerSmsMarketingConsentUpdate
"{\n \"input\": {\n \"customerId\": \"gid://shopify/<objectName>/10079785100\",\n \"smsMarketingConsent\": {\n \"consentUpdatedAt\": \"2019-09-07T15:50:00Z\",\n \"marketingOptInLevel\": \"CONFIRMED_OPT_IN\",\n \"marketingState\": \"NOT_SUBSCRIBED\"\n }\n }\n}"
Schema Reference for MUTATION: customerSmsMarketingConsentUpdate
"input CustomerSmsMarketingConsentUpdateInput {\n customerId: ID!\n smsMarketingConsent: CustomerSmsMarketingConsentInput!\n}\n\ninput CustomerSmsMarketingConsentInput {\n consentUpdatedAt: DateTime\n marketingOptInLevel: CustomerMarketingOptInLevel\n marketingState: CustomerSmsMarketingState!\n}\n"
Display Examples for MUTATION: customerSmsMarketingConsentUpdate
[ { "example": { "type_name": "customersmsmarketingconsentupdate", "title": "Subscribe a customer to SMS marketing materials", "query_string": "mutation customerSmsMarketingConsentUpdate($input: CustomerSmsMarketingConsentUpdateInput!) {\n customerSmsMarketingConsentUpdate(input: $input) {\n userErrors {\n field\n message\n }\n customer {\n id\n phone\n smsMarketingConsent {\n marketingState\n marketingOptInLevel\n consentUpdatedAt\n consentCollectedFrom\n }\n }\n }\n}", "variables": { "input": { "customerId": "gid://shopify/Customer/207119551", "smsMarketingConsent": { "marketingState": "SUBSCRIBED", "marketingOptInLevel": "SINGLE_OPT_IN" } } }, "response": { "data": { "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" } } } } }, "api_name": "admin", "minimum_api_version": "2023-10", "maximum_api_version": "unstable", "location": "/components/customers/test/unit/graph_api/admin/mutations/customer_sms_marketing_consent_update_test.rb", "curl_example": "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation customerSmsMarketingConsentUpdate($input: CustomerSmsMarketingConsentUpdateInput!) { customerSmsMarketingConsentUpdate(input: $input) { userErrors { field message } customer { id phone smsMarketingConsent { marketingState marketingOptInLevel consentUpdatedAt consentCollectedFrom } } } }\",\n \"variables\": {\n \"input\": {\n \"customerId\": \"gid://shopify/Customer/207119551\",\n \"smsMarketingConsent\": {\n \"marketingState\": \"SUBSCRIBED\",\n \"marketingOptInLevel\": \"SINGLE_OPT_IN\"\n }\n }\n }\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation customerSmsMarketingConsentUpdate($input: CustomerSmsMarketingConsentUpdateInput!) {\n customerSmsMarketingConsentUpdate(input: $input) {\n userErrors {\n field\n message\n }\n customer {\n id\n phone\n smsMarketingConsent {\n marketingState\n marketingOptInLevel\n consentUpdatedAt\n consentCollectedFrom\n }\n }\n }\n }`,\n {\n variables: {\n \"input\": {\n \"customerId\": \"gid://shopify/Customer/207119551\",\n \"smsMarketingConsent\": {\n \"marketingState\": \"SUBSCRIBED\",\n \"marketingOptInLevel\": \"SINGLE_OPT_IN\"\n }\n }\n },\n },\n);\n\nconst data = await response.json();\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 mutation customerSmsMarketingConsentUpdate($input: CustomerSmsMarketingConsentUpdateInput!) {\n customerSmsMarketingConsentUpdate(input: $input) {\n userErrors {\n field\n message\n }\n customer {\n id\n phone\n smsMarketingConsent {\n marketingState\n marketingOptInLevel\n consentUpdatedAt\n consentCollectedFrom\n }\n }\n }\n }\nQUERY\n\nvariables = {\n \"input\": {\n \"customerId\": \"gid://shopify/Customer/207119551\",\n \"smsMarketingConsent\": {\n \"marketingState\": \"SUBSCRIBED\",\n \"marketingOptInLevel\": \"SINGLE_OPT_IN\"\n }\n }\n}\n\nresponse = client.query(query: query, variables: variables)\n", "node_example": "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation customerSmsMarketingConsentUpdate($input: CustomerSmsMarketingConsentUpdateInput!) {\n customerSmsMarketingConsentUpdate(input: $input) {\n userErrors {\n field\n message\n }\n customer {\n id\n phone\n smsMarketingConsent {\n marketingState\n marketingOptInLevel\n consentUpdatedAt\n consentCollectedFrom\n }\n }\n }\n }`,\n \"variables\": {\n \"input\": {\n \"customerId\": \"gid://shopify/Customer/207119551\",\n \"smsMarketingConsent\": {\n \"marketingState\": \"SUBSCRIBED\",\n \"marketingOptInLevel\": \"SINGLE_OPT_IN\"\n }\n }\n },\n },\n});\n", "php_example": "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation customerSmsMarketingConsentUpdate($input: CustomerSmsMarketingConsentUpdateInput!) {\n customerSmsMarketingConsentUpdate(input: $input) {\n userErrors {\n field\n message\n }\n customer {\n id\n phone\n smsMarketingConsent {\n marketingState\n marketingOptInLevel\n consentUpdatedAt\n consentCollectedFrom\n }\n }\n }\n }\nQUERY;\n\n$variables = [\n \"input\" => [\n \"customerId\" => \"gid://shopify/Customer/207119551\",\n \"smsMarketingConsent\" => [\n \"marketingState\" => \"SUBSCRIBED\",\n \"marketingOptInLevel\" => \"SINGLE_OPT_IN\",\n ],\n ],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" }, "titleStringKey": "variables", "inputVariableEntries": [ { "arg": { "name": "input", "description": "Specifies the input fields to update a customer's SMS marketing consent information.", "type": { "kind": "INPUT_OBJECT", "name": "CustomerSmsMarketingConsentUpdateInput", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "CustomerSmsMarketingConsentUpdateInput!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "input", "argValue": " {\"customerId\":\"gid://shopify/Customer/207119551\",\"smsMarketingConsent\":{\"marketingState\":\"SUBSCRIBED\",\"marketingOptInLevel\":\"SINGLE_OPT_IN\"}}", "typeKind": "MUTATION" } ] }, { "example": { "type_name": "customersmsmarketingconsentupdate", "title": "Subscribe a customer to SMS marketing materials with the date at which the consent was collected", "query_string": "mutation customerSmsMarketingConsentUpdate($input: CustomerSmsMarketingConsentUpdateInput!) {\n customerSmsMarketingConsentUpdate(input: $input) {\n userErrors {\n field\n message\n }\n customer {\n id\n phone\n smsMarketingConsent {\n marketingState\n marketingOptInLevel\n consentUpdatedAt\n consentCollectedFrom\n }\n }\n }\n}", "variables": { "input": { "customerId": "gid://shopify/Customer/207119551", "smsMarketingConsent": { "marketingState": "UNSUBSCRIBED", "marketingOptInLevel": "SINGLE_OPT_IN", "consentUpdatedAt": "2021-01-07T15:50:00Z" } } }, "response": { "data": { "customerSmsMarketingConsentUpdate": { "userErrors": [], "customer": { "id": "gid://shopify/Customer/207119551", "phone": "+16136120707", "smsMarketingConsent": { "marketingState": "UNSUBSCRIBED", "marketingOptInLevel": "SINGLE_OPT_IN", "consentUpdatedAt": "2021-01-07T15:50:00Z", "consentCollectedFrom": "OTHER" } } } } }, "api_name": "admin", "minimum_api_version": "2023-10", "maximum_api_version": "unstable", "location": "/components/customers/test/unit/graph_api/admin/mutations/customer_sms_marketing_consent_update_test.rb", "curl_example": "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation customerSmsMarketingConsentUpdate($input: CustomerSmsMarketingConsentUpdateInput!) { customerSmsMarketingConsentUpdate(input: $input) { userErrors { field message } customer { id phone smsMarketingConsent { marketingState marketingOptInLevel consentUpdatedAt consentCollectedFrom } } } }\",\n \"variables\": {\n \"input\": {\n \"customerId\": \"gid://shopify/Customer/207119551\",\n \"smsMarketingConsent\": {\n \"marketingState\": \"UNSUBSCRIBED\",\n \"marketingOptInLevel\": \"SINGLE_OPT_IN\",\n \"consentUpdatedAt\": \"2021-01-07T15:50:00Z\"\n }\n }\n }\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation customerSmsMarketingConsentUpdate($input: CustomerSmsMarketingConsentUpdateInput!) {\n customerSmsMarketingConsentUpdate(input: $input) {\n userErrors {\n field\n message\n }\n customer {\n id\n phone\n smsMarketingConsent {\n marketingState\n marketingOptInLevel\n consentUpdatedAt\n consentCollectedFrom\n }\n }\n }\n }`,\n {\n variables: {\n \"input\": {\n \"customerId\": \"gid://shopify/Customer/207119551\",\n \"smsMarketingConsent\": {\n \"marketingState\": \"UNSUBSCRIBED\",\n \"marketingOptInLevel\": \"SINGLE_OPT_IN\",\n \"consentUpdatedAt\": \"2021-01-07T15:50:00Z\"\n }\n }\n },\n },\n);\n\nconst data = await response.json();\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 mutation customerSmsMarketingConsentUpdate($input: CustomerSmsMarketingConsentUpdateInput!) {\n customerSmsMarketingConsentUpdate(input: $input) {\n userErrors {\n field\n message\n }\n customer {\n id\n phone\n smsMarketingConsent {\n marketingState\n marketingOptInLevel\n consentUpdatedAt\n consentCollectedFrom\n }\n }\n }\n }\nQUERY\n\nvariables = {\n \"input\": {\n \"customerId\": \"gid://shopify/Customer/207119551\",\n \"smsMarketingConsent\": {\n \"marketingState\": \"UNSUBSCRIBED\",\n \"marketingOptInLevel\": \"SINGLE_OPT_IN\",\n \"consentUpdatedAt\": \"2021-01-07T15:50:00Z\"\n }\n }\n}\n\nresponse = client.query(query: query, variables: variables)\n", "node_example": "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation customerSmsMarketingConsentUpdate($input: CustomerSmsMarketingConsentUpdateInput!) {\n customerSmsMarketingConsentUpdate(input: $input) {\n userErrors {\n field\n message\n }\n customer {\n id\n phone\n smsMarketingConsent {\n marketingState\n marketingOptInLevel\n consentUpdatedAt\n consentCollectedFrom\n }\n }\n }\n }`,\n \"variables\": {\n \"input\": {\n \"customerId\": \"gid://shopify/Customer/207119551\",\n \"smsMarketingConsent\": {\n \"marketingState\": \"UNSUBSCRIBED\",\n \"marketingOptInLevel\": \"SINGLE_OPT_IN\",\n \"consentUpdatedAt\": \"2021-01-07T15:50:00Z\"\n }\n }\n },\n },\n});\n", "php_example": "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation customerSmsMarketingConsentUpdate($input: CustomerSmsMarketingConsentUpdateInput!) {\n customerSmsMarketingConsentUpdate(input: $input) {\n userErrors {\n field\n message\n }\n customer {\n id\n phone\n smsMarketingConsent {\n marketingState\n marketingOptInLevel\n consentUpdatedAt\n consentCollectedFrom\n }\n }\n }\n }\nQUERY;\n\n$variables = [\n \"input\" => [\n \"customerId\" => \"gid://shopify/Customer/207119551\",\n \"smsMarketingConsent\" => [\n \"marketingState\" => \"UNSUBSCRIBED\",\n \"marketingOptInLevel\" => \"SINGLE_OPT_IN\",\n \"consentUpdatedAt\" => \"2021-01-07T15:50:00Z\",\n ],\n ],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" }, "titleStringKey": "variables", "inputVariableEntries": [ { "arg": { "name": "input", "description": "Specifies the input fields to update a customer's SMS marketing consent information.", "type": { "kind": "INPUT_OBJECT", "name": "CustomerSmsMarketingConsentUpdateInput", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "CustomerSmsMarketingConsentUpdateInput!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "input", "argValue": " {\"customerId\":\"gid://shopify/Customer/207119551\",\"smsMarketingConsent\":{\"marketingState\":\"UNSUBSCRIBED\",\"marketingOptInLevel\":\"SINGLE_OPT_IN\",\"consentUpdatedAt\":\"2021-01-07T15:50:00Z\"}}", "typeKind": "MUTATION" } ] }, { "example": { "type_name": "customersmsmarketingconsentupdate", "title": "Unsubscribe a customer from SMS marketing materials", "query_string": "mutation customerSmsMarketingConsentUpdate($input: CustomerSmsMarketingConsentUpdateInput!) {\n customerSmsMarketingConsentUpdate(input: $input) {\n userErrors {\n field\n message\n }\n customer {\n id\n phone\n smsMarketingConsent {\n marketingState\n marketingOptInLevel\n consentUpdatedAt\n consentCollectedFrom\n }\n }\n }\n}", "variables": { "input": { "customerId": "gid://shopify/Customer/207119551", "smsMarketingConsent": { "marketingState": "UNSUBSCRIBED", "marketingOptInLevel": "SINGLE_OPT_IN" } } }, "response": { "data": { "customerSmsMarketingConsentUpdate": { "userErrors": [], "customer": { "id": "gid://shopify/Customer/207119551", "phone": "+16136120707", "smsMarketingConsent": { "marketingState": "UNSUBSCRIBED", "marketingOptInLevel": "SINGLE_OPT_IN", "consentUpdatedAt": "2024-09-12T01:08:05Z", "consentCollectedFrom": "OTHER" } } } } }, "api_name": "admin", "minimum_api_version": "2023-10", "maximum_api_version": "unstable", "location": "/components/customers/test/unit/graph_api/admin/mutations/customer_sms_marketing_consent_update_test.rb", "curl_example": "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation customerSmsMarketingConsentUpdate($input: CustomerSmsMarketingConsentUpdateInput!) { customerSmsMarketingConsentUpdate(input: $input) { userErrors { field message } customer { id phone smsMarketingConsent { marketingState marketingOptInLevel consentUpdatedAt consentCollectedFrom } } } }\",\n \"variables\": {\n \"input\": {\n \"customerId\": \"gid://shopify/Customer/207119551\",\n \"smsMarketingConsent\": {\n \"marketingState\": \"UNSUBSCRIBED\",\n \"marketingOptInLevel\": \"SINGLE_OPT_IN\"\n }\n }\n }\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation customerSmsMarketingConsentUpdate($input: CustomerSmsMarketingConsentUpdateInput!) {\n customerSmsMarketingConsentUpdate(input: $input) {\n userErrors {\n field\n message\n }\n customer {\n id\n phone\n smsMarketingConsent {\n marketingState\n marketingOptInLevel\n consentUpdatedAt\n consentCollectedFrom\n }\n }\n }\n }`,\n {\n variables: {\n \"input\": {\n \"customerId\": \"gid://shopify/Customer/207119551\",\n \"smsMarketingConsent\": {\n \"marketingState\": \"UNSUBSCRIBED\",\n \"marketingOptInLevel\": \"SINGLE_OPT_IN\"\n }\n }\n },\n },\n);\n\nconst data = await response.json();\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 mutation customerSmsMarketingConsentUpdate($input: CustomerSmsMarketingConsentUpdateInput!) {\n customerSmsMarketingConsentUpdate(input: $input) {\n userErrors {\n field\n message\n }\n customer {\n id\n phone\n smsMarketingConsent {\n marketingState\n marketingOptInLevel\n consentUpdatedAt\n consentCollectedFrom\n }\n }\n }\n }\nQUERY\n\nvariables = {\n \"input\": {\n \"customerId\": \"gid://shopify/Customer/207119551\",\n \"smsMarketingConsent\": {\n \"marketingState\": \"UNSUBSCRIBED\",\n \"marketingOptInLevel\": \"SINGLE_OPT_IN\"\n }\n }\n}\n\nresponse = client.query(query: query, variables: variables)\n", "node_example": "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation customerSmsMarketingConsentUpdate($input: CustomerSmsMarketingConsentUpdateInput!) {\n customerSmsMarketingConsentUpdate(input: $input) {\n userErrors {\n field\n message\n }\n customer {\n id\n phone\n smsMarketingConsent {\n marketingState\n marketingOptInLevel\n consentUpdatedAt\n consentCollectedFrom\n }\n }\n }\n }`,\n \"variables\": {\n \"input\": {\n \"customerId\": \"gid://shopify/Customer/207119551\",\n \"smsMarketingConsent\": {\n \"marketingState\": \"UNSUBSCRIBED\",\n \"marketingOptInLevel\": \"SINGLE_OPT_IN\"\n }\n }\n },\n },\n});\n", "php_example": "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation customerSmsMarketingConsentUpdate($input: CustomerSmsMarketingConsentUpdateInput!) {\n customerSmsMarketingConsentUpdate(input: $input) {\n userErrors {\n field\n message\n }\n customer {\n id\n phone\n smsMarketingConsent {\n marketingState\n marketingOptInLevel\n consentUpdatedAt\n consentCollectedFrom\n }\n }\n }\n }\nQUERY;\n\n$variables = [\n \"input\" => [\n \"customerId\" => \"gid://shopify/Customer/207119551\",\n \"smsMarketingConsent\" => [\n \"marketingState\" => \"UNSUBSCRIBED\",\n \"marketingOptInLevel\" => \"SINGLE_OPT_IN\",\n ],\n ],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" }, "titleStringKey": "variables", "inputVariableEntries": [ { "arg": { "name": "input", "description": "Specifies the input fields to update a customer's SMS marketing consent information.", "type": { "kind": "INPUT_OBJECT", "name": "CustomerSmsMarketingConsentUpdateInput", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "CustomerSmsMarketingConsentUpdateInput!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "input", "argValue": " {\"customerId\":\"gid://shopify/Customer/207119551\",\"smsMarketingConsent\":{\"marketingState\":\"UNSUBSCRIBED\",\"marketingOptInLevel\":\"SINGLE_OPT_IN\"}}", "typeKind": "MUTATION" } ] } ]