When building a Shopify Remix app, developers often work with the GraphQL Admin API to manage customers, orders, products, and other store data. One common task is deleting a customer from the Shopify store. In this guide, we’ll walk through how to delete a customer using Shopify’s GraphQL API within a Remix app.

In this blog post, we will learn how to delete a customer in the Shopify Remix app using the GraphQL API.
Steps to Delete Customer using GraphQL API in Shopify Remix App:
Step 1: Need to have access of write_customers
First, you need to have access to write_customers in Shopify; without that, you can’t delete customers from the Shopify store using the API.
Step 2: Add API for delete customer
The customer delete API will be called anywhere, like on the storefront and also on the backend.
Here is a code sample for delete customer :
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();
In the variable field, you need to pass the customer ID like this:
{
"id": "gid://shopify/Customer/105906728"
}
Response will be displayed like this:
{
"customerDelete": {
"shop": {
"id": "gid://shopify/Shop/26371970"
},
"userErrors": [],
"deletedCustomerId": "gid://shopify/Customer/105906728"
}
}
After successfully integrating this API, you can delete your customers from the backend, and you can also call this as an API and delete your customers from the frontend, too.
Conclusion:
That’s it! You now know how to delete a customer using the GraphQL API in a Shopify Remix App. In conclusion, deleting customers is sometimes required for data privacy policy and data security. You can add this feature by adding this API to your code. Make sure that you can also delete a customer from the frontend using this code as API in the backend.

FAQ
- Do I need special permissions to delete customers in Shopify?
Yes, your Shopify Remix app must have read and write permissions for customers in the Admin API scopes. Without this, the mutation will fail.
- What is a Shopify Remix App?
A Shopify Remix app is a custom application that is developed using the Remix framework and runs on the Shopify platform.