Customer API¶
Introduction¶
The Customer API allows you to manage customers in your OpenMage store. You can retrieve customer information, create new customers, update existing ones, and delete customers.
Available Methods¶
list¶
Retrieve list of customers with basic info.
Method Name: customer.list
Parameters:
filters
(object|array, optional) - Filters to apply to the list:customer_id
(int|array) - Filter by customer ID(s)email
(string|array) - Filter by email(s)firstname
(string|array) - Filter by first name(s)lastname
(string|array) - Filter by last name(s)created_at
(string|array) - Filter by creation dateupdated_at
(string|array) - Filter by update datewebsite_id
(int|array) - Filter by website ID(s)group_id
(int|array) - Filter by customer group ID(s)- Other attributes can also be used as filters
store
(string|int, optional) - Store ID or code
Return:
- (array) - Array of customers with the following structure:
customer_id
(int) - Customer IDemail
(string) - Customer emailfirstname
(string) - Customer first namelastname
(string) - Customer last namecreated_at
(string) - Creation dateupdated_at
(string) - Update datewebsite_id
(int) - Website IDgroup_id
(int) - Customer group ID
Example Request:
{
"jsonrpc": "2.0",
"method": "call",
"params": [
"session_id",
"customer.list",
[{"group_id": 1}]
],
"id": 1
}
Example Response:
{
"jsonrpc": "2.0",
"result": [
{
"customer_id": 1,
"email": "john.doe@example.com",
"firstname": "John",
"lastname": "Doe",
"created_at": "2023-01-15 14:30:12",
"updated_at": "2023-01-15 14:30:12",
"website_id": 1,
"group_id": 1
},
{
"customer_id": 2,
"email": "jane.smith@example.com",
"firstname": "Jane",
"lastname": "Smith",
"created_at": "2023-01-16 09:45:23",
"updated_at": "2023-01-16 09:45:23",
"website_id": 1,
"group_id": 1
}
],
"id": 1
}
Possible Errors:
filters_invalid
- Invalid filters providedstore_not_exists
- Requested store does not exist
info¶
Retrieve detailed customer information.
Method Name: customer.info
Parameters:
customerId
(int, required) - Customer IDstore
(string|int, optional) - Store ID or code
Return:
- (object) - Customer information with the following structure:
customer_id
(int) - Customer IDemail
(string) - Customer emailfirstname
(string) - Customer first namelastname
(string) - Customer last namemiddlename
(string) - Customer middle nameprefix
(string) - Name prefixsuffix
(string) - Name suffixcreated_at
(string) - Creation dateupdated_at
(string) - Update datewebsite_id
(int) - Website IDgroup_id
(int) - Customer group IDdob
(string) - Date of birthtaxvat
(string) - Tax/VAT numberconfirmation
(string) - Confirmation codecreated_in
(string) - Store where customer was createddefault_billing
(string) - Default billing address IDdefault_shipping
(string) - Default shipping address IDis_active
(int) - Whether customer is active (1 - yes, 0 - no)
Example Request:
{
"jsonrpc": "2.0",
"method": "call",
"params": [
"session_id",
"customer.info",
[1, "default"]
],
"id": 1
}
Example Response:
{
"jsonrpc": "2.0",
"result": {
"customer_id": 1,
"email": "john.doe@example.com",
"firstname": "John",
"lastname": "Doe",
"middlename": "",
"prefix": "Mr",
"suffix": "",
"created_at": "2023-01-15 14:30:12",
"updated_at": "2023-01-15 14:30:12",
"website_id": 1,
"group_id": 1,
"dob": "1980-01-01",
"taxvat": "123456789",
"confirmation": null,
"created_in": "Default Store View",
"default_billing": "1",
"default_shipping": "1",
"is_active": 1
},
"id": 1
}
Possible Errors:
customer_not_exists
- Customer does not existstore_not_exists
- Requested store does not exist
create¶
Create new customer.
Method Name: customer.create
Parameters:
customerData
(array, required) - Customer data:email
(string, required) - Customer emailfirstname
(string, required) - Customer first namelastname
(string, required) - Customer last namepassword
(string, required) - Customer passwordwebsite_id
(int, required) - Website IDgroup_id
(int, optional) - Customer group IDmiddlename
(string, optional) - Customer middle nameprefix
(string, optional) - Name prefixsuffix
(string, optional) - Name suffixdob
(string, optional) - Date of birth (format:YYYY-MM-DD
)taxvat
(string, optional) - Tax/VAT numberis_subscribed
(boolean, optional) - Whether customer is subscribed to newsletterstore_id
(int, optional) - Store IDstore
(string|int, optional) - Store ID or code
Return:
- (int) - ID of the created customer
Example Request:
{
"jsonrpc": "2.0",
"method": "call",
"params": [
"session_id",
"customer.create",
[
{
"email": "new.customer@example.com",
"firstname": "New",
"lastname": "Customer",
"password": "password123",
"website_id": 1,
"group_id": 1,
"dob": "1985-05-15",
"taxvat": "987654321",
"is_subscribed": true
},
"default"
]
],
"id": 1
}
Example Response:
Possible Errors:
data_invalid
- Invalid data providedcustomer_data_invalid
- Invalid customer datacustomer_exists
- Customer with the same email already existswebsite_not_exists
- Website does not existgroup_not_exists
- Customer group does not exist
update¶
Update customer data.
Method Name: customer.update
Parameters:
customerId
(int, required) - Customer IDcustomerData
(array, required) - Customer data to update (same structure as in create method, except password is optional)store
(string|int, optional) - Store ID or code
Return:
- (boolean) - True on success
Example Request:
{
"jsonrpc": "2.0",
"method": "call",
"params": [
"session_id",
"customer.update",
[
1,
{
"firstname": "Updated",
"lastname": "Name",
"email": "updated.email@example.com"
},
"default"
]
],
"id": 1
}
Example Response:
Possible Errors:
data_invalid
- Invalid data providedcustomer_not_exists
- Customer does not existcustomer_data_invalid
- Invalid customer datacustomer_exists
- Another customer with the same email already existswebsite_not_exists
- Website does not existgroup_not_exists
- Customer group does not exist
delete¶
Delete customer.
Method Name: customer.delete
Parameters:
customerId
(int, required) - Customer ID
Return:
- (boolean) - True on success
Example Request:
Example Response:
Possible Errors:
customer_not_exists
- Customer does not existnot_deleted
- Customer could not be deleted