7

In Magento2, How to call REST API to register a new customer (What APIs need to call step by step). Thanks!

1
  • better you create your own rest API for registration as default API will ask so much data.. Dec 16 '16 at 5:12
7

Refer below link for Magento 2.x version. http://devdocs.magento.com/swagger/index_20.html#/

I have used below body for creating customers through Rest Api and it worked properly.

Url : http://www.xxxxxxxx.com/rest/V1/customers

Type: POST

Content-Type : application/json

payload Data:

  {
     "customer": {
         "email": "abc@gmail.com",
         "firstname": "Abc",
         "lastname": "Xyz"   

     },
     "password": "Abc@123456"
  }

Response:

 {
    "id": 4,
    "group_id": 1,
    "created_at": "2017-01-27 18:35:48",
    "updated_at": "2017-01-27 18:35:48",
    "created_in": "Default Store View",
    "email": "abc@gmail.com",
    "firstname": "Abc",
    "lastname": "Xyz",
    "store_id": 1,
    "website_id": 1,
    "addresses": [],
    "disable_auto_group_change": 0
}

Call through postman see example in attachment:

Register customer using Magento2 rest api

0
0

We can use /rest/V1/customers: http://devdocs.magento.com/swagger/#resource_customerAccountManagementV1

For example, payload:

{
  "id": 0,
  "group_id": 0,
  "default_billing": "string",
  "default_shipping": "string",
  "confirmation": "string",
  "created_at": "string",
  "updated_at": "string",
  "created_in": "string",
  "dob": "string",
  "email": "string",
  "firstname": "string",
  "lastname": "string",
  "middlename": "string",
  "prefix": "string",
  "suffix": "string",
  "gender": 0,
  "store_id": 0,
  "taxvat": "string",
  "website_id": 0,
  "addresses": [
    {
      "id": 0,
      "customer_id": 0,
      "region": {
        "region_code": "string",
        "region": "string",
        "region_id": 0,
        "extension_attributes": {}
      },
      "region_id": 0,
      "country_id": "string",
      "street": [
        "string"
      ],
      "company": "string",
      "telephone": "string",
      "fax": "string",
      "postcode": "string",
      "city": "string",
      "firstname": "string",
      "lastname": "string",
      "middlename": "string",
      "prefix": "string",
      "suffix": "string",
      "vat_id": "string",
      "default_shipping": true,
      "default_billing": true,
      "extension_attributes": {},
      "custom_attributes": [
        {
          "attribute_code": "string",
          "value": "string"
        }
      ]
    }
  ],
0

Url : http://www.test.com/rest/V1/customers

Type: POST

Content-Type : application/json

Body Raw Json Data:-

{
    "customer": {
        "email": "test@gmail.com",
        "firstname": "Test",
        "lastname": "User"   

    },
    "password": "Front@12345"
}

To block Api user creation add below line at robots.txt

Rest Api block if no need

Disallow:rest/default/V1/customers

Disallow:rest/V1/customers

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.