Create a customer
Creates a single customer. Use this when you register customers one at a time, for example from a sign-up form.
To import many customers in one go, use batchCreateCustomers instead.
Every field on the input is optional, so you can start with as little as an email address and fill in the rest later with updateCustomer.
If you provide a password, the response also contains an access token and a refresh token for the new customer, which lets you log them in directly after registration.
note
Ensure that the authorization token with the correct admin privileges are included in the header
Request:
mutation createCustomer {
createCustomer(input: {
email: "[email protected]"
password: "Str0ngPassw0rd!"
firstName: "Erik"
lastName: "Svensson"
externalID: "CRM-4471"
standardAddress: {
firstName: "Erik"
lastName: "Svensson"
streetAddress: "Järnvägsgatan"
houseNumber: "11"
postalCode: "66133"
city: "Säffle"
countryCode: "SE"
phone: "+46730000000"
}
}) {
customer {
id
firstName
lastName
email
externalId
standardAddress {
streetAddress
houseNumber
postalCode
city
}
}
customerTokens {
AccessToken {
token
}
}
}
}
Response:
{
"data": {
"createCustomer": {
"customer": {
"id": 3004,
"firstName": "Erik",
"lastName": "Svensson",
"email": "[email protected]",
"externalId": "CRM-4471",
"standardAddress": {
"streetAddress": "Järnvägsgatan",
"houseNumber": "11",
"postalCode": "66133",
"city": "Säffle"
}
},
"customerTokens": {
"AccessToken": {
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}
}
}
}
}