How to delete customer using REST API?

Alley_C
New Member
4 0 0

Could you please help me understand the customer deletion process using Shopify REST API?
I faced with an issue when I cannot delete a customer using either Shopify REST or GraphQL APIs.
The deletion process is performed on behalf of the shop owner via OAuth App. The App has customer_write scope and it had been successfully deleting customers until January 29th.
The behavior of the Shopify REST API does not change and it still returned the 200 status code as a result of the delete request and the 404 error code for the same request with the same customer id but the customer stays in the shop.
When I use GraphQL API it responds successfully and returns me the id of the customer that I sent to delete but the customer was not deleted. And the API returns an error with the "Customer can't be found" message for the reattempted request with the same customer id.
All following requests to read the deleted customer return me that customer.
The deleted customers are not displayed in the shop but can be seen if I request them directly by their ids.
Does it mean that customers cannot be deleted but only hidden on the Shopify platform?

Customers that I'm trying to delete don't have orders.

 

0 Likes
Greg_Kujawa
Shopify Partner
1016 83 227

Are you using a specific API version in the URL's for these API calls? If not maybe try the latest production API version and see if anything changes.

0 Likes
Alley_C
New Member
4 0 0

Thank you for the reply!
I've tried the next routes related to REST and GraphQL APIs:
Shopify REST API delete route - /admin/api/2021-04/customers/{{customer_id}}.json
Shopify GraphQL API delete route - /admin/api/2020-10/graphql.json
Unfortunately, it did not help.

0 Likes
Greg_Kujawa
Shopify Partner
1016 83 227

I could easily duplicate the same behavior. Using the GraphQL 2021-01 API version. Below are the screen shots. Using the Shopify web admin I created a new customer. Only specifying name, phone number, and e-mail address. Deleted the customer via the GraphiQL app. Went back into the Shopify web admin and I could pull up the customer using their ID in the URL. Although I wasn't able to search for the customer, find them, and pull them up. Only thing about the customer record that had changed on the web admin detail view was the e-mail address was deleted. Odd.

Untitled1.pngUntitled2.pngUntitled3.png

Anyone from Shopify want to weigh in on this?

0 Likes
Greg_Kujawa
Shopify Partner
1016 83 227

If you are concerned about pulling customer records via the API and deleted ones accidentally coming as part of the response set, I think there are two properties that indicate a customer record has been deleted. 1) the e-mail property is null, 2) the account is in a disabled state. Screen shot below!

Untitled.png

0 Likes
Greg_Kujawa
Shopify Partner
1016 83 227

Just ran the same request again and now that deleted customer record comes back as null. So there might be some scheduled garbage collection routine that sweeps away the deleted records.

Untitled.png

0 Likes
Alley_C
New Member
4 0 0

Thank you for your spent time!
I've tested one more time and got the next results:
REST API DELETE requests do nothing with customers, even the state did not change and I can view the customer email even after deletion. But GraphQL API acts a bit differently and it returns email as null but as well as the REST API response the GraphQL API does not change the state of the user.

Screenshot 2021-02-22 at 20.37.59.pngScreenshot 2021-02-22 at 20.35.35.png

Currently, I use the REST API approach, and because of certain circumstances, I would prefer to use it further.
As it is not documented in any way it would be nice to have a response from Shopify with some clarification regarding such behavior.

Looking back to your very last message I guess I will try one more test later. Thank you!

0 Likes
_JCC_
Shopify Staff
Shopify Staff
142 20 26

@Alley_C ,

Just wanted to follow-up and let you know the issue is being tracked on our end. I don't have a timeline for a resolution but will do my best to follow-up when I know more.

Regards,

John

John C | Developer Support @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

0 Likes
Alley_C
New Member
4 0 0

@_JCC_,
Thank you for letting me know.
Maybe there is any news that appeared since your very last reply?

Regards,

Alley

0 Likes