A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
Hey there,
Our company is considering moving to Shopify as primary ecommerce platform, and we would like to seamlessly migrate our existing customers to Shopify. Part of this process would be to create Customer accounts with identical login email & password as they have in the current system, as well as carry over following data:
- personal information
- contact email, phone number
- physical address
- web address
- possibly billing info like the IBAN
- other custom data fields
I've read the documentation for Customer resource in the Admin API (https://shopify.dev/docs/api/admin-rest/2023-07/resources/customer) and it looks like the `POST` request should create a customer with given logn email, data & password. We would also be interested in setting the aforementioned custom data fields on the newly created customer accounts, however I could not find appropriate way to add additional custom metadata fields to the customer in the `POST` request.
Could you please review my approach, and maybe suggest a way of doing the above? This seamless migration is a critical requirement for our transition to Shopify.
Kind regards,
Marcin Praski
Solved! Go to the solution
This is an accepted solution.
HI Mpraski,
Your approach of leveraging Shopify's Admin API to create customer profiles is correct. You can indeed use a `POST` request via the `/admin/api/2023-07/customers.json` endpoint to create a new customer.
Here is an example of the request body:
{
"customer": {
"first_name": "Steve",
"last_name": "Lastnameson",
"email": "steve.lastnameson@example.com",
"phone": "+15142546011",
"verified_email": true,
"addresses": [
{
"address1": "123 Oak St",
"city": "Ottawa",
"province": "ON",
"phone": "555-1212",
"zip": "123 ABC",
"last_name": "Lastnameson",
"first_name": "Mother",
"country": "CA"
}
]
}
}
As for custom data fields, Shopify provides the ability to store additional information for resources like products, customers, and orders with Metafields. To add metafields to a customer, you would need to use the `POST/admin
Here is an example of how you can create a metafield for a customer:
{
"metafield": {
"namespace": "custom_fields",
"key": "web_address",
"value": "www.example.com",
"value_type": "string",
"owner_resource": "customer",
"owner_id": 207119551
}
}
In the above example you'd replace `"web_address"` and `"www.example.com"` with your custom field key and value respectively.
Where you might have an issue however is around migrating passwords - Shopify does not support importing sensitive information such as passwords due to security and privacy reasons. Your customers would need to reset their passwords upon first log in to the new site and possibly re-enter their billing information. There are some apps such as BAIS that could assist with this part.
Hope this helps and best of luck with the migration!
Liam | Developer Advocate @ 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
This is an accepted solution.
Hey @mpraski
That approach seems reasonable if you have access to the passwords. Here's an example of creating a customer with a metafield (third example down): https://shopify.dev/docs/api/admin-rest/2023-07/resources/customer#post-customers-examples
Also keep Multipass in mind, it might fit into your flow somewhere (Plus plans only).
Scott | Developer Advocate @ Shopify
This is an accepted solution.
HI Mpraski,
Your approach of leveraging Shopify's Admin API to create customer profiles is correct. You can indeed use a `POST` request via the `/admin/api/2023-07/customers.json` endpoint to create a new customer.
Here is an example of the request body:
{
"customer": {
"first_name": "Steve",
"last_name": "Lastnameson",
"email": "steve.lastnameson@example.com",
"phone": "+15142546011",
"verified_email": true,
"addresses": [
{
"address1": "123 Oak St",
"city": "Ottawa",
"province": "ON",
"phone": "555-1212",
"zip": "123 ABC",
"last_name": "Lastnameson",
"first_name": "Mother",
"country": "CA"
}
]
}
}
As for custom data fields, Shopify provides the ability to store additional information for resources like products, customers, and orders with Metafields. To add metafields to a customer, you would need to use the `POST/admin
Here is an example of how you can create a metafield for a customer:
{
"metafield": {
"namespace": "custom_fields",
"key": "web_address",
"value": "www.example.com",
"value_type": "string",
"owner_resource": "customer",
"owner_id": 207119551
}
}
In the above example you'd replace `"web_address"` and `"www.example.com"` with your custom field key and value respectively.
Where you might have an issue however is around migrating passwords - Shopify does not support importing sensitive information such as passwords due to security and privacy reasons. Your customers would need to reset their passwords upon first log in to the new site and possibly re-enter their billing information. There are some apps such as BAIS that could assist with this part.
Hope this helps and best of luck with the migration!
Liam | Developer Advocate @ 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
Thank you for your answer Liam!
It is much clearer now.
This is an accepted solution.
Hey @mpraski
That approach seems reasonable if you have access to the passwords. Here's an example of creating a customer with a metafield (third example down): https://shopify.dev/docs/api/admin-rest/2023-07/resources/customer#post-customers-examples
Also keep Multipass in mind, it might fit into your flow somewhere (Plus plans only).
Scott | Developer Advocate @ Shopify
Thank you for your answer SBD_!