Create Customer
This POST endpoint is used to create a new customer record in the system. The request must include necessary customer details, including personal, contact, and address information.
Endpoint
- URL:
/customers - Method:
POST
Authentication
- Header:
accessToken - Type: Bearer Token
- Value:
<ACCESS-TOKEN>
Request Headers
| Header | Type | Description |
|---|---|---|
Content-Type | string | Must be application/json. |
accessToken | string | Access token for authentication. (required) |
Request Body
The body of the request should be a JSON object containing the following customer details:
| Field | Type | Description |
|---|---|---|
firstName | string | The first name of the customer. (required) |
lastName | string | The last name of the customer. (required) |
email | string | The email of the customer. (required) |
phoneNumber | string | The contact number of the customer. |
status | string | The status of the customer (e.g., "active"). (required) |
address | array | Array of address objects related to the customer. |
company | string | Associated company ID. |
metaFields | array | Array of meta-information fields for the customer. |
notes | string | Optional field for additional notes on the customer. |
Address Object (address[])
| Field | Type | Description |
|---|---|---|
firstName | string | First name of the contact person at the address. |
lastName | string | Last name of the contact person at the address. |
phoneNumber | string | Contact phone number for the address. |
address1 | string | Primary address line. |
address2 | string | Secondary address line. |
city | string | City of the address. |
state | string | State code of the address (e.g., "NJ"). |
country | string | Country code of the address (e.g., "US"). |
zipcode | string | Postal code of the address. |
isDefaultAddress | boolean | Indicates whether this is the default address. |
MetaFields Object (metaFields[])
| Field | Type | Description |
|---|---|---|
code | string | Code for the metafield. |
value | mixed | Value of the metafield. |
Sample Request Body
{
"firstName": "John",
"lastName": "Doe",
"email": "John@aximcommerce.com",
"phoneNumber": "65161861",
"status": "active",
"address": [
{
"firstName": "John",
"lastName": "Doe",
"phoneNumber": "65161861",
"address1": "12/4, test st",
"address2": "",
"city": "Elizabeth",
"state": "NJ",
"country": "US",
"zipcode": "07202",
"isDefaultAddress": false
}
],
"company": "637e18fc741020de0693227a",
"metaFields": [
{
"code": "p21_contact_id",
"value": 1254
}
],
"notes": "NOTE AREA"
}
Response
- Status Code: 201 Created
Success Response Body
{
"success": true,
"message": "Customer created successfully",
"data": {
"id": "generated_id_here"
// other customer details...
}
}
Success Response Body Structure
| Field | Type | Description |
|---|---|---|
success | boolean | Indicates if the request was successful. |
message | string | Message indicating the result of the operation. |
data | object | Contains details of the newly created customer. |
Data Object (data)
| Field | Type | Description |
|---|---|---|
email | string | Email address of the customer. |
firstName | string | First name of the customer. |
lastName | string | Last name of the customer. |
phoneNumber | string | Contact number of the customer. |
role | string | Role ID associated with the customer. |
company | string | Company ID related to the customer. |
status | string | Current status of the customer (e.g., "pending"). |
verifiedEmail | boolean | Indicates if the customer's email is verified. |
newsletter | boolean | Indicates subscription to the newsletter. |
isB2B | boolean | Indicates if the customer is a business customer. |
metaFields | array | Additional metadata related to the customer. |
createdBy | object | Information about who created the customer entry. |
createdAt | string (ISO 8601) | Timestamp of when the customer was created. |
updatedAt | string (ISO 8601) | Timestamp of the last update to the customer data. |
id | string | Unique identifier for the customer. |
address | object | Address information of the customer. |
Error Responses
| Status Code | Description |
|---|---|
| 400 Bad Request | The request body contains invalid data or is missing required fields. |
| 401 Unauthorized | The access token is invalid or missing. |
| 500 Internal Server Error | An error occurred on the server. |
Notes
- Ensure that all required fields are included in the request body.
- Confirm that your access token is valid and has permissions to create customer data.
- This endpoint creates a new customer and returns the newly created customer details on success.