Anchor to customerSmsMarketingConsentUpdatecustomer
customerSmsMarketingConsentUpdate
mutation
Requires access scope.
Update a customer's SMS marketing consent information.
Anchor to Arguments
Arguments
- Anchor to inputinput•
Specifies the input fields to update a customer's SMS marketing consent information.
Was this section helpful?
Anchor to CustomerSmsMarketingConsentUpdatePayload returnsCustomerSmsMarketingConsentUpdatePayload returns
- Anchor to customercustomer•
The updated customer.
- Anchor to userErrorsuser•
Errors The list of errors that occurred from executing the mutation.
Was this section helpful?
- Subscribe a customer to SMS marketing materials
- Subscribe a customer to SMS marketing materials with the date at which the consent was collected
- Unsubscribe a customer from SMS marketing materials
- customerSmsMarketingConsentUpdate reference
Examples
1const { admin } = await authenticate.admin(request);23const response = await admin.graphql(4 `#graphql5 mutation customerSmsMarketingConsentUpdate($input: CustomerSmsMarketingConsentUpdateInput!) {6 customerSmsMarketingConsentUpdate(input: $input) {7 userErrors {8 field9 message10 }11 customer {12 id13 phone14 smsMarketingConsent {15 marketingState16 marketingOptInLevel17 consentUpdatedAt18 consentCollectedFrom19 }20 }21 }22 }`,23 {24 variables: {25 "input": {26 "customerId": "gid://shopify/Customer/207119551",27 "smsMarketingConsent": {28 "marketingState": "SUBSCRIBED",29 "marketingOptInLevel": "SINGLE_OPT_IN"30 }31 }32 },33 },34);3536const data = await response.json();37
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/2025-04/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();
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"
}
}
},
},
});
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)
Input variables
JSON1{2 "input": {3 "customerId": "gid://shopify/Customer/207119551",4 "smsMarketingConsent": {5 "marketingState": "SUBSCRIBED",6 "marketingOptInLevel": "SINGLE_OPT_IN"7 }8 }9}
Response
JSON1{2 "customerSmsMarketingConsentUpdate": {3 "userErrors": [],4 "customer": {5 "id": "gid://shopify/Customer/207119551",6 "phone": "+16136120707",7 "smsMarketingConsent": {8 "marketingState": "SUBSCRIBED",9 "marketingOptInLevel": "SINGLE_OPT_IN",10 "consentUpdatedAt": "2024-09-12T01:08:05Z",11 "consentCollectedFrom": "OTHER"12 }13 }14 }15}