createCustomerV2 mutation

The createCustomerV2 mutation creates a customer account. Use the createCustomerAddress mutation to complete the customer profile and define billing and shipping addresses.

The createCustomerV2 mutation supersedes the createCustomer mutation as the means to create a customer account. The input objects differ between these two mutations. The createCustomer mutation required the CustomerInput object, as did the updateCustomer mutation. The attributes required for creating a customer are different than those for updating a customer, but you could not determine this by looking at the schema. The createCustomerV2 mutation requires the CustomerCreateInput object, which it does not share with the updateCustomerV2 mutation.

Syntax

mutation: {createCustomerV2(input: CustomerCreateInput!) {CustomerOutput}}

Example usage

The following call creates a new customer.

Request:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
mutation {
  createCustomerV2(
    input: {
      firstname: "Bob"
      lastname: "Loblaw"
      email: "bobloblaw@example.com"
      password: "b0bl0bl@w"
      is_subscribed: true
    }
  ) {
    customer {
      firstname
      lastname
      email
      is_subscribed
    }
  }
}

Response:

1
2
3
4
5
6
7
8
9
10
11
12
{
  "data": {
    "createCustomer": {
      "customer": {
        "firstname": "Bob",
        "lastname": "Loblaw",
        "email": "bobloblaw@example.com",
        "is_subscribed": true
      }
    }
  }
}

Input attributes

The following table lists the attributes you can use as input for the createCustomerV2 mutation.

Attribute Data Type Description
date_of_birth String The customer’s date of birth
dob String Deprecated. Use date_of_birth instead. The customer’s date of birth
email String! The customer’s email address
firstname String! The customer’s first name
gender Int The customer’s gender (Male - 1, Female - 2)
is_subscribed Boolean Indicates whether the customer subscribes to the store’s newsletter
lastname String! The customer’s last name
middlename String The customer’s middle name
password String The customer’s password
prefix String An honorific, such as Dr., Mr., or Mrs.
suffix String A value such as Sr., Jr., or III
taxvat String The customer’s Tax/VAT number (for corporate customers)

Output attributes

The CustomerOutput object contains the Customer object.

The following table lists the top-level attributes of the customer object. See the customer query for complete details about this object.

Attribute Data Type Description
addresses CustomerAddress An array containing the customer’s shipping and billing addresses
created_at String Timestamp indicating when the account was created
date_of_birth String The customer’s date of birth
default_billing String The ID assigned to the billing address
default_shipping String The ID assigned to the shipping address
dob String Deprecated. Use date_of_birth instead. The customer’s date of birth
email String The customer’s email address
firstname String The customer’s first name
gender Int The customer’s gender (Male - 1, Female - 2)
group_id Int Deprecated. This attribute is not applicable for GraphQL. The group assigned to the user. Default values are 0 (Not logged in), 1 (General), 2 (Wholesale), and 3 (Retailer)
id Int Deprecated. This attribute is not applicable for GraphQL.The ID assigned to the customer
is_subscribed Boolean Indicates whether the customer is subscribed to the company’s newsletter
lastname String The customer’s family name
middlename String The customer’s middle name
orders(<FilterCriteria>) [CustomerOrders] A list of the customer’s placed orders
prefix String An honorific, such as Dr., Mr., or Mrs.
reviews(pageSize: Int = 20 currentPage: Int = 1) ProductReviews! The list of reviews of the product
reward_points RewardPoints Details about the customer’s reward points
suffix String A value such as Sr., Jr., or III
taxvat String The customer’s Tax/VAT number (for corporate customers)
wishlist Wishlist! Contains the contents of the customer’s wish lists

Errors

Error Description
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.