In this article on the Magento 2 Rest API category, I am going to explain how you can sign up Magento 2 new customers from a different website or your localhost system using Magento 2 Customer Sign Up Rest API. So simply we can say call Magento 2 customer sign up reset API Step by step guide from beginning to end.
Magento Customers can Purchases in Three Ways:
So basically Magento customer has three choices when they purchase the product from the store.
- If customers are already registered then they can simply log in and purchase.
- There are other facilities that don't want to register but want to purchase the product so they can continue as a guest customer.
- Another option is when customers reached the checkout page then they have to fill in the details and simultaneously can choose to register their account with the store.
So here we will understand the first type of customer and how we can call the Magento default REST API to create a customer.
Call Customer Sign Up REST API
By using Magento 2 default REST API we can easily create the customer so in order to create the new customer, we have to call the rest API and check on the postman if the request will send successfully then the account will create and show some response message.
First, we need to open the postman.
Endpoint:
https://wishusucess.com/rest/all/V1/customers
Note: wishusucess.com is your domain name if you are using localhost then you have to use your localhost address something like:
http://localhost/magento_installation_directory/rest/all/V1/customers
Method: POST
Request:
{ "customer": { "email": "cs.hemantsingh@gmail.com", "firstname": "Hemant", "lastname": "Singh" }, "password": "Abcd@$123456" }
Once you have entered the details then you have to send the request then you will get the result something like an image.
Remember we always send the request in JSON format. so you have to select the format of the request before the request is sent.
Response:
{ "id": 12919, "group_id": 1, "created_at": "2021-10-06 19:01:40", "updated_at": "2021-10-06 19:01:40", "created_in": "Wishusucess", "email": "cs.hemantsingh@gmail.com", "firstname": "Hemant", "lastname": "Singh", "store_id": 1, "website_id": 1, "addresses": [], "disable_auto_group_change": 0, "extension_attributes": { "is_subscribed": false } }
If the email data is already there with the same details of the email then you will get a message like the below image.
Magento 2 create New Customer Using GraphQL
When we talk about GraphQL then there are two things one is mutation and the second is Query so here we are sending a request to create a customer so we will use mutation.
Create Customer Mutation creates a new customer.
Syntax
mutation: {createCustomer(input: CustomerInput!) {CustomerOutput}}
Example usage
You can use the below mutation to create a new customer.
mutation { createCustomer( input: { firstname: "Hemant" lastname: "Singh" email: "hemant.singh@wishudeal.com" password: "Abcd@$123456" is_subscribed: true } ) { customer { firstname lastname email is_subscribed } } }
So by using Magento 2 GraphQL you can easily create a new customer and for that, you have to use the endpoint below like that:
https://wishusucess.com/graphql
Here, you can choose your website URL and then type graphql
Related Post:
Magento 2 Customer API: Create Custom API For Customer
Recommended Post:
Magento 2.4 Installation Guide: How to Install Magento 2.4.2
SEO Packages: How Much Do SEO Packages Cost in India, SEO Pricing