Edit in GitHubLog an issue

createCustomer mutation

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:

Copied to your clipboard
mutation {
createCustomer(
input: {
firstname: "Bob"
lastname: "Loblaw"
email: "bobloblaw@example.com"
password: "b0bl0bl@w"
is_subscribed: true
}
) {
customer {
firstname
lastname
email
is_subscribed
}
}
}

Response:

Copied to your clipboard
{
"data": {
"createCustomer": {
"customer": {
"firstname": "Bob",
"lastname": "Loblaw",
"email": "bobloblaw@example.com",
"is_subscribed": true
}
}
}
}

Errors

ErrorDescription
A customer with the same email address already exists in an associated website.
The email provided in the input.email argument belongs to an existing customer.
"Email" is not a valid email address.
The value provided in the input.email argument has an invalid format.
Field CustomerInput.email of required type String! was not provided
The input.email argument was omitted.
Field "xxx" is not defined by type CustomerInput.
The input.xxx argument is undefined.
Required parameters are missing: First Name
The input.firstname argument was omitted or contains an empty value.
  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2024 Adobe. All rights reserved.