Skip to main content Link Menu Expand (external link) Document Search Copy Copied

Module: Mage_Customer

Allows you to export/import customers from/to Magento.

Resource: customer

Method:

  • customer.create (SOAP V1)
  • customerCustomerCreate (SOAP V2)

Create a new customer.

Arguments:

TypeNameDescription
stringsessionIdSession ID
arraycustomerDataArray of customerCustomerEntityToCreate

Returns:

TypeNameDescription
intresultID of the created customer

The customerCustomerEntityToCreate content is as follows:

TypeNameDescription
stringemailCustomer email
stringfirstnameCustomer first name
stringlastnameCustomer last name
stringpasswordCustomer password
intwebsite_idWebsite ID
intstore_idStore ID
intgroup_idGroup ID
stringprefixCustomer prefix (optional)
stringsuffixCustomer suffix (optional)
stringdobCustomer date of birth (optional)
stringtaxvatCustomer tax/VAT number (optional)
intgenderCustomer gender: 1 - Male, 2 - Female (optional)
stringmiddlenameCustomer middle name/initial (optional)

Examples

Request Example SOAP V1
$client = new SoapClient('http://magentohost/api/soap/?wsdl');

// If somestuff requires API authentication,
// then get a session token
$session = $client->login('apiUser', 'apiKey');
$result = $client->call($session,'customer.create',array(array('email' => 'mail@example.org', 'firstname' => 'Dough', 'lastname' => 'Deeks', 'password' => 'password', 'website_id' => 1, 'store_id' => 1, 'group_id' => 1)));

var_dump ($result);

// If you don't need the session anymore
//$client->endSession($session);
Request Example SOAP V2
$client = new SoapClient('http://magentohost/api/v2_soap/?wsdl');

// If some stuff requires API authentication,
// then get a session token
$session = $client->login('apiUser', 'apiKey');
$result = $client->customerCustomerCreate($session, array('email' => 'customer-mail@example.org', 'firstname' => 'Dough', 'lastname' => 'Deeks', 'password' => 'password', 'website_id' => 1, 'store_id' => 1, 'group_id' => 1));

var_dump ($result);
Request Example SOAP V2 (WS-I Compliance Mode)
$proxy = new SoapClient('http://magentohost/api/v2_soap/?wsdl'); 

$sessionId = $proxy->login((object)array('username' => 'apiUser', 'apiKey' => 'apiKey')); 
 
$result = $proxy->customerCustomerCreate((object)array('sessionId' => $sessionId->result, 'customerData' => ((object)array(
'email' => 'customer-mail@example.org',
'firstname' => 'John',
'lastname' => 'Dou',
'password' => '123123',
'website_id' => '0',
'group_id' => '1'
))));   
var_dump($result->result);