Customer API
Overview
The Customer API provides endpoints for managing customer accounts in your EverShop store. These endpoints allow you to create and manage customer profiles, handle authentication, and maintain customer data securely.
Endpoints
Create a Customer
Creates a new customer account in the system. This endpoint registers a new user with their basic information and credentials.
Field Name | Field Type | Required |
---|---|---|
status | string or integer ('0', '1', 0, 1) | No |
string | Yes | |
password | string | Yes |
full_name | string | Yes |
- cURL
- JavaScript
curl
-H "Accept: application/json"
-H "Cookie: asid=<your admin cookie>"
https://<your domain>/api/customers
fetch('https://<your domain>/api/customers', {
headers: {
'Accept': 'application/json',
'Cookie': 'asid=<your admin cookie>'
}
})
.then(response => response.json())
.then(data => {
if(data.error) {
// Handle the error
} else {
// Handle the data
}
})
.catch(error => {
// Handle the error
});
{
"data": {
"customer_id": 21,
"uuid": "e1b20098a66c11edb46b60d819134f39",
"status": 1,
"group_id": 1,
"email": "john.smith@example.com",
"full_name": "John Smith",
"created_at": "2023-02-07 14:18:05",
"updated_at": "2023-02-07 14:18:05",
"links": [
{
"rel": "customerGrid",
"href": "/admin/customers",
"action": "GET",
"types": [
"text/xml"
]
},
{
"rel": "edit",
"href": "/admin/customers/edit/e1b20098a66c11edb46b60d819134f39",
"action": "GET",
"types": [
"text/xml"
]
}
]
}
}
Update a Customer
Modifies an existing customer account. This endpoint allows you to update customer information such as email, name, or password.
Field Name | Field Type | Required |
---|---|---|
string | No | |
password | string | No |
full_name | string | No |
status | string or integer ('0', '1', 0, 1) | No |
- cURL
- JavaScript
curl
-H "Accept: application/json"
-H "Cookie: asid=<your admin cookie>"
https://<your domain>/api/customers/433ba97f-8be7-4be9-be3f-a9f341f2b89f
fetch('https://<your domain>/api/customers/433ba97f-8be7-4be9-be3f-a9f341f2b89f', {
headers: {
'Accept': 'application/json',
'Cookie': 'asid=<your admin cookie>'
}
})
.then(response => response.json())
.then(data => {
if(data.error) {
// Handle the error
} else {
// Handle the data
}
})
.catch(error => {
// Handle the error
});
{
"data": {
"customer_id": 21,
"uuid": "433ba97f-8be7-4be9-be3f-a9f341f2b89f",
"status": 1,
"group_id": 1,
"email": "john.smith@example.com",
"full_name": "John A. Smith",
"created_at": "2023-02-07 14:18:05",
"updated_at": "2023-02-07 14:18:06",
"links": [
{
"rel": "customerGrid",
"href": "/admin/customers",
"action": "GET",
"types": [
"text/xml"
]
},
{
"rel": "edit",
"href": "/admin/customers/edit/433ba97f-8be7-4be9-be3f-a9f341f2b89f",
"action": "GET",
"types": [
"text/xml"
]
}
]
}
}
Delete a Customer
Permanently removes a customer account from the system. This operation cannot be undone.
- cURL
- JavaScript
curl
-H "Accept: application/json"
-H "Cookie: asid=<your admin cookie>"
https://<your domain>/api/customers/433ba97f-8be7-4be9-be3f-a9f341f2b89f
fetch('https://<your domain>/api/customers/433ba97f-8be7-4be9-be3f-a9f341f2b89f', {
headers: {
'Accept': 'application/json',
'Cookie': 'asid=<your admin cookie>'
}
})
.then(response => response.json())
.then(data => {
if(data.error) {
// Handle the error
} else {
// Handle the data
}
})
.catch(error => {
// Handle the error
});
{
"data": {
"customer_id": 21,
"uuid": "433ba97f-8be7-4be9-be3f-a9f341f2b89f",
"status": 1,
"group_id": 1,
"email": "john.smith@example.com",
"full_name": "John A. Smith",
"created_at": "2023-02-07 14:18:05",
"updated_at": "2023-02-07 14:18:06"
}
}
Login
Authenticates a customer and creates a session. Returns a session identifier that should be used for authenticated requests.
Field Name | Field Type | Required |
---|---|---|
string | Yes | |
password | string | Yes |
- cURL
- JavaScript
curl
-H "Accept: application/json"
https://<your domain>/customer/login
fetch('https://<your domain>/customer/login', {
headers: {
'Accept': 'application/json',
}
})
.then(response => response.json())
.then(data => {
if(data.error) {
// Handle the error
} else {
// Handle the data
}
})
.catch(error => {
// Handle the error
});
{
"data": {
"sid": "09d34c21-4af3-4db8-a38b-335ebf6d45fa"
}
}
Logout
Terminates a customer's active session. This invalidates the session identifier and requires re-authentication for future requests.
- cURL
- JavaScript
curl
-H "Accept: application/json"
https://<your domain>/customers/logout
fetch('https://<your domain>/customers/logout', {
headers: {
'Accept': 'application/json',
}
})
.then(response => response.json())
.then(data => {
if(data.error) {
// Handle the error
} else {
// Handle the data
}
})
.catch(error => {
// Handle the error
});
{
"data": {}
}
Get a Customer
Retrieves detailed information about a specific customer account.
- cURL
- JavaScript
curl
-H "Accept: application/json"
-H "Cookie: asid=<your admin cookie>"
https://<your domain>/api/customers/433ba97f-8be7-4be9-be3f-a9f341f2b89f
fetch('https://<your domain>/api/customers/433ba97f-8be7-4be9-be3f-a9f341f2b89f', {
headers: {
'Accept': 'application/json',
'Cookie': 'asid=<your admin cookie>'
}
})
.then(response => response.json())
.then(data => {
if(data.error) {
// Handle the error
} else {
// Handle the data
}
})
.catch(error => {
// Handle the error
});
{
"data": {
"customer_id": 21,
"uuid": "433ba97f-8be7-4be9-be3f-a9f341f2b89f",
"status": 1,
"group_id": 1,
"email": "john.smith@example.com",
"full_name": "John A. Smith",
"created_at": "2023-02-07 14:18:05",
"updated_at": "2023-02-07 14:18:06",
"addresses": [
{
"customer_address_id": 15,
"uuid": "f2c30099a66c11edb46b60d819134f39",
"full_name": "John A. Smith",
"telephone": "555-123-4567",
"address_1": "123 Main Street",
"address_2": "Apt 4B",
"city": "Springfield",
"province": "IL",
"country": "US",
"postcode": "62701",
"is_default": true
}
]
}
}
List All Customers
Retrieves a paginated list of all customer accounts in the system.
- cURL
- JavaScript
curl
-H "Accept: application/json"
-H "Cookie: asid=<your admin cookie>"
https://<your domain>/api/customers
fetch('https://<your domain>/api/customers', {
headers: {
'Accept': 'application/json',
'Cookie': 'asid=<your admin cookie>'
}
})
.then(response => response.json())
.then(data => {
if(data.error) {
// Handle the error
} else {
// Handle the data
}
})
.catch(error => {
// Handle the error
});
{
"data": [
{
"customer_id": 20,
"uuid": "d1b20098a66c11edb46b60d819134f39",
"status": 1,
"group_id": 1,
"email": "jane.doe@example.com",
"full_name": "Jane Doe",
"created_at": "2023-02-06 10:15:22",
"updated_at": "2023-02-06 10:15:22"
},
{
"customer_id": 21,
"uuid": "e1b20098a66c11edb46b60d819134f39",
"status": 1,
"group_id": 1,
"email": "john.smith@example.com",
"full_name": "John A. Smith",
"created_at": "2023-02-07 14:18:05",
"updated_at": "2023-02-07 14:18:06"
}
],
"links": {
"first": "/api/customers?page=1",
"last": "/api/customers?page=1",
"prev": null,
"next": null
},
"meta": {
"current_page": 1,
"from": 1,
"last_page": 1,
"path": "/api/customers",
"per_page": 20,
"to": 2,
"total": 2
}
}
Authentication
Customer API endpoints use session-based authentication. After a successful login, include the session identifier (sid) in subsequent requests using one of the following methods:
- Cookie-based authentication - The session cookie is automatically included in browser-based requests
- Header-based authentication - Include the session ID in the
X-Session-ID
header
Error Handling
All endpoints may return the following error responses:
Status Code | Description |
---|---|
400 | Bad Request - Invalid parameters |
401 | Unauthorized - Authentication required |
403 | Forbidden - Insufficient permissions |
404 | Not Found - Customer doesn't exist |
409 | Conflict - Email already in use |
500 | Server Error - Something went wrong |
Error responses follow this format:
{
"error": {
"status": 404,
"message": "Customer not found"
}
}