CustomerAccountsCreateWithPassword Endpoint

Overview

Nearly every single store needs customers.  That's the whole point, right?  This endpoint allows you to create as many customer accounts as you want for your store while also specifying their password.

Requirements

The following pre-requisites will be necessary to accomplish the goals of this article:

  • General understanding of REST and API’s
  • Understanding of C# and/or JavaScript
  • Visual Studio 2012 or newer

Getting Started

You should already have a project open and ready to accept code to allow you to use this REST API endpoint.  You should also have some kind of idea what attributes that you want your customer account to have before you create it.

CustomerAccountsCreateWithPassword

This REST API endpoint allows you to create a customer account for your store while specifying their password at the same time.  This method should only be considered as a last resort.  Creating the password presents many potential security issues, including the password being sent in clear text, someone other than the customer potentially knowing the password, and more.

Example URL

This is what the REST endpoint will look like if you are calling it using JavaScript.  See our REST API URL documentation for more information.

http://example.com/DesktopModules/Hotcakes/API/rest/v1/customeraccounts?key=[YOURKEY]&pwd=[ANYVALUE]

ANYVALUE is literally what it means. the querystring just needs to have a value to execute the right logic when creating a new user.

HTTP Method

POST

Parameters

In addition to the URL parameter mentioned above, this method requires that you pass an instance of the CustomerAccountDTO object to the endpoint.  Be sure to populate the Password property of the parameter like shown in the example below.

Returns

If successful, this endpoint will return a CustomerAccountDTO object in JSON format.  Otherwise, you will have one or more errors returned.

Example Code

The following code will allow you to successfully call this endpoint, provided that you have enabled it.

Project References

  • Hotcakes.CommerceDTO

Import Namespaces

  • Hotcakes.CommerceDTO.v1
  • Hotcakes.CommerceDTO.v1.Client
  • Hotcakes.CommerceDTO.v1.Membership

 

string url = "http://example.com";
string key = "YOUR-API-KEY";

Api proxy = new Api(url, key);

// create an instance of customer account
var customerAccount = new CustomerAccountDTO();

// specify a password to use
var password = "supersecret";

// populate the customer account with minimal information
customerAccount.FirstName = "Bruce";
customerAccount.LastName = "Wayne";
customerAccount.Email = "batman@domain.com";
customerAccount.Password = password; // this must exist as well

// call the API to create the customer account
ApiResponse<CustomerAccountDTO> response = proxy.CustomerAccountsCreateWithPassword(customerAccount, password);
// your domain name
var url = "http://example.com"; 
// the path where the API is
var apiPath = "/DesktopModules/Hotcakes/API/rest/v1/";  
// endpoint as shown in the documentation
var endPoint = "customeraccounts";  
// get this from the store admin
var apiKey = "YOUR-API-KEY";

$(document).ready(function() {

    // create a password
    var password = "supersecret";

    // create a new instance of customer account
    // populate the customer account with minimum details
    var customerAccount = {
        "FirstName": "Bruce",
        "LastName": "Wayne",
        "Email": "batman@domain.com",
        "Password": password // this must exist as well
    };

    // call the API to create the customer accounts with a password
    $.ajax({
        dataType: "json",
        url: url + apiPath + endPoint + "?key=" + apiKey + "&pwd=anyvalue",
        data: JSON.stringify(customerAccount),
        type: 'POST',
        success: function (data) {
            // do something
        },
        error: function(jqXHR, textStatus) {
            // do something else
        }
    });

});
{
   "Errors":[

   ],
   "Content":{
      "Bvin":"14",
      "Email":"batman@domain.com",
      "FirstName":"Bruce",
      "LastName":"Wayne",
      "Password":"",
      "Salt":"",
      "Addresses":[

      ],
      "TaxExempt":false,
      "Notes":"",
      "PricingGroupId":"",
      "FailedLoginCount":0,
      "LastUpdatedUtc":"/Date(1396483029243)/",
      "CreationDateUtc":"/Date(1396483029213)/",
      "LastLoginDateUtc":"/Date(1396483029347)/",
      "ShippingAddress":{
         "Bvin":null,
         "LastUpdatedUtc":"/Date(1396483029046)/",
         "StoreId":0,
         "NickName":"",
         "FirstName":"",
         "MiddleInitial":"",
         "LastName":"",
         "Company":"",
         "Line1":"",
         "Line2":"",
         "Line3":"",
         "City":"",
         "RegionName":"",
         "RegionBvin":"",
         "PostalCode":"",
         "CountryName":"United States",
         "CountryBvin":"bf7389a2-9b21-4d33-b276-23c9c18ea0c0",
         "Phone":"",
         "Fax":"",
         "WebSiteUrl":"",
         "CountyName":"",
         "CountyBvin":"",
         "UserBvin":"",
         "AddressType":0
      },
      "BillingAddress":{
         "Bvin":null,
         "LastUpdatedUtc":"/Date(1396483029046)/",
         "StoreId":0,
         "NickName":"",
         "FirstName":"",
         "MiddleInitial":"",
         "LastName":"",
         "Company":"",
         "Line1":"",
         "Line2":"",
         "Line3":"",
         "City":"",
         "RegionName":"",
         "RegionBvin":"",
         "PostalCode":"",
         "CountryName":"United States",
         "CountryBvin":"bf7389a2-9b21-4d33-b276-23c9c18ea0c0",
         "Phone":"",
         "Fax":"",
         "WebSiteUrl":"",
         "CountyName":"",
         "CountyBvin":"",
         "UserBvin":"",
         "AddressType":0
      }
   }
}
Have more questions? Submit a request

Need More Help?

Do you need more assistance with this article? Please review your support options.