Creating a Customer
5 min
Use the customer.create mutation to create a customer.
⚠️ WARNING
Search first. Run Customer Identification with the phone number and create the customer only when no customer matches. A duplicate splits the history of the same person.
Query
mutation CreateCustomer($payload: CustomerCreateInputType!) {
customer {
create(payload: $payload) {
result {
publicKey
firstName
lastName
active
mobilePhone
category { publicKey name active }
}
errorCode
errorMessage
errorData
}
}
}Variables
{
"payload": {
"category": "<customer category key>",
"firstName": "Jane",
"lastName": "Doe",
"mobilePhone": "0700000001"
}
}cURL
curl --location 'https://sandbox.expressoft.eu/connect/api/interopgql' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <token>' \
--data '{"query": "mutation CreateCustomer($payload: CustomerCreateInputType!) { customer { create(payload: $payload) { result { publicKey firstName lastName active mobilePhone category { publicKey name active } } errorCode errorMessage errorData } } }", "variables": {"payload": {"category": "<customer category key>", "firstName": "Jane", "lastName": "Doe", "mobilePhone": "0700000001"}}}'Response
{
"data": {
"customer": {
"create": {
"result": {
"publicKey": "00000000-0000-0000-0000-000000000001",
"firstName": "Jane",
"lastName": "Doe",
"active": true,
"mobilePhone": "0700000001",
"category": {
"publicKey": "00000000-0000-0000-0000-000000000010",
"name": "Gold customers",
"active": true
}
},
"errorCode": null,
"errorMessage": null,
"errorData": null
}
}
}
}Take category from the customer categories (see Customer Identification). Keep the publicKey of the new customer.
Fields of a customer
Field | Type | Required | Default | Description |
|---|---|---|---|---|
category | Guid! | yes | | Customer category key. |
firstName | String! | yes | | Customer first name. |
lastName | String! | yes | | Customer last name. |
code | String | no | | Customer code/reference. |
String | no | | Customer email. | |
mobilePhone | String! | yes | | Mobile phone (mandatory). |
workPhone | String | no | | Work phone. |
homePhone | String | no | | Home phone. |
birthDate | DateTime | no | | Customer date of birth (optional). |
Add an address
An address needs a street. Get the street key from the Setup Queries of the Delivery API (Get Streets by County), then use customer.createAddress. See Editing a Customer.
ℹ️ INFO
The error codes of customer.create are InvalidCustomerCategory (2) and InvalidEmailFormat (4). The full list is in Errors & Troubleshooting.