Anchor to customerDeletecustomer
customerDelete
mutation
Requires access scope.
Delete a customer. As of API version 2022-10, apps using protected customer data must meet the protected customer data requirements.
Anchor to Arguments
Arguments
- Anchor to inputinput•Customer
Delete requiredInput! Specifies the customer to delete.
Was this section helpful?
Anchor to CustomerDeletePayload returnsCustomerDeletePayload returns
- Anchor to deletedCustomerIddeleted•
Customer Id The ID of the deleted customer.
- Anchor to shopshop•Shop!non-null
The shop of the deleted customer.
- Anchor to userErrorsuser•
Errors [UserError!]! non-null The list of errors that occurred from executing the mutation.
Was this section helpful?
- Deletes a customer
- customerDelete reference
Examples
1const { admin } = await authenticate.admin(request);23const response = await admin.graphql(4 `#graphql5 mutation customerDelete($id: ID!) {6 customerDelete(input: {id: $id}) {7 shop {8 id9 }10 userErrors {11 field12 message13 }14 deletedCustomerId15 }16 }`,17 {18 variables: {19 "id": "gid://shopify/Customer/105906728"20 },21 },22);2324const data = await response.json();25
mutation customerDelete($id: ID!) {
customerDelete(input: {id: $id}) {
shop {
id
}
userErrors {
field
message
}
deletedCustomerId
}
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2024-04/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "mutation customerDelete($id: ID!) { customerDelete(input: {id: $id}) { shop { id } userErrors { field message } deletedCustomerId } }",
"variables": {
"id": "gid://shopify/Customer/105906728"
}
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation customerDelete($id: ID!) {
customerDelete(input: {id: $id}) {
shop {
id
}
userErrors {
field
message
}
deletedCustomerId
}
}`,
{
variables: {
"id": "gid://shopify/Customer/105906728"
},
},
);
const data = await response.json();
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `mutation customerDelete($id: ID!) {
customerDelete(input: {id: $id}) {
shop {
id
}
userErrors {
field
message
}
deletedCustomerId
}
}`,
"variables": {
"id": "gid://shopify/Customer/105906728"
},
},
});
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 customerDelete($id: ID!) {
customerDelete(input: {id: $id}) {
shop {
id
}
userErrors {
field
message
}
deletedCustomerId
}
}
QUERY
variables = {
"id": "gid://shopify/Customer/105906728"
}
response = client.query(query: query, variables: variables)
Input variables
JSON1{2 "id": "gid://shopify/Customer/105906728"3}
Response
JSON1{2 "customerDelete": {3 "shop": {4 "id": "gid://shopify/Shop/26371970"5 },6 "userErrors": [],7 "deletedCustomerId": "gid://shopify/Customer/105906728"8 }9}