data-src=../../../../includes/paas-only.md
createCustomer mutation
data-variant=warning
data-slots=text
The createCustomer mutation creates a new customer.
In keeping with current security and privacy best practices, if you include the date_of_birth input attribute, be sure you are aware of any potential legal and security risks associated with the storage of customers' full date of birth (month, day, year) along with other personal identifiers, such as full name, before collecting or processing such data.
To return or modify information about a customer, we recommend you use customer tokens in the header of your GraphQL calls. However, you also can use session authentication.
Syntax
mutation: {createCustomer(input: CustomerInput!) {CustomerOutput}}
Reference
The createCustomer reference provides detailed information about the types and fields defined in this mutation.
Example usage
The following call creates a new customer.
Request:
mutation {
createCustomer(
input: {
firstname: "Bob"
lastname: "Loblaw"
email: "bobloblaw@example.com"
password: "b0bl0bl@w"
is_subscribed: true
}
) {
customer {
firstname
lastname
email
is_subscribed
}
}
}
Response:
{
"data": {
"createCustomer": {
"customer": {
"firstname": "Bob",
"lastname": "Loblaw",
"email": "bobloblaw@example.com",
"is_subscribed": true
}
}
}
}
Errors
A customer with the same email address already exists in an associated website.input.email argument belongs to an existing customer."Email" is not a valid email address.input.email argument has an invalid format.Field CustomerInput.email of required type String! was not providedinput.email argument was omitted.Field "xxx" is not defined by type CustomerInput.input.xxx argument is undefined.Required parameters are missing: First Nameinput.firstname argument was omitted or contains an empty value.