Queries and mutations for the signed-in Customer and their address book.
Queries
Get signed-in Customer
query GetMe {
me { id email emailVerified firstName lastName authMode }
}
{
"data": {
"me": {
"id": "AQMAAURFREVERERFpEVERERFREUAAAABAAAAAAABAAEAAAAAAAEAAAABAAEAAA",
"email": "jane.doe@example.com",
"emailVerified": true,
"firstName": "Jane",
"lastName": "Doe",
"authMode": "PASSWORD"
}
}
}
Mutations
Register Customer
Creates a Customer.
POST /{project}/main/session with the password grant, which
also moves the guest Cart to the new Customer.| Arguments | |
|---|---|
input​ | Customer to create. |
mutation Register {
register(
input: {firstName: "Jane", lastName: "Doe", email: "jane.doe@example.com", password: "<password>"}
) {
customer { id email emailVerified firstName lastName authMode }
userErrors { code message field }
}
}
{
"data": {
"register": {
"customer": {
"id": "AQMAAURFREVERERFpEVERERFREUAAAABAAAAAAABAAEAAAAAAAEAAAABAAEAAA",
"email": "jane.doe@example.com",
"emailVerified": false,
"firstName": "Jane",
"lastName": "Doe",
"authMode": "PASSWORD"
},
"userErrors": []
}
}
}
Update Customer profile
Changes the first name, last name, or both, of the signed-in Customer.
| Arguments | |
|---|---|
input​ | Names to change. |
mutation UpdateProfile {
updateProfile(input: {firstName: "Janet"}) {
customer { id firstName lastName }
userErrors { code message field }
}
}
{
"data": {
"updateProfile": {
"customer": {
"id": "AQMAAURFREVERERFpEVERERFREUAAAABAAAAAAABAAEAAAAAAAEAAAABAAEAAA",
"firstName": "Janet",
"lastName": "Doe"
},
"userErrors": []
}
}
}
Set Customer middle name
Sets the middle name of the signed-in Customer.
| Arguments | |
|---|---|
middleName​String​ | Middle name to set. Pass null to remove the existing value. |
mutation SetMiddleName {
setMiddleName(middleName: "Rose") {
customer { id firstName middleName lastName }
userErrors { code message field }
}
}
{
"data": {
"setMiddleName": {
"customer": {
"id": "AQMAAURFREVERERFpEVERERFREUAAAABAAAAAAABAAEAAAAAAAEAAAABAAEAAA",
"firstName": "Jane",
"middleName": "Rose",
"lastName": "Doe"
},
"userErrors": []
}
}
}
Set Customer title
Sets the title of the signed-in Customer.
| Arguments | |
|---|---|
title​String​ | Title to set. Pass null to remove the existing value. |
mutation SetTitle {
setTitle(title: "Dr.") {
customer { id title }
userErrors { code message field }
}
}
{
"data": {
"setTitle": {
"customer": {
"id": "AQMAAURFREVERERFpEVERERFREUAAAABAAAAAAABAAEAAAAAAAEAAAABAAEAAA",
"title": "Dr."
},
"userErrors": []
}
}
}
Set Customer salutation
Sets the salutation of the signed-in Customer.
| Arguments | |
|---|---|
salutation​String​ | Salutation to set. Pass null to remove the existing value. |
mutation SetSalutation {
setSalutation(salutation: "Ms.") {
customer { id salutation }
userErrors { code message field }
}
}
{
"data": {
"setSalutation": {
"customer": {
"id": "AQMAAURFREVERERFpEVERERFREUAAAABAAAAAAABAAEAAAAAAAEAAAABAAEAAA",
"salutation": "Ms."
},
"userErrors": []
}
}
}
Set Customer date of birth
Sets the date of birth of the signed-in Customer.
| Arguments | |
|---|---|
dateOfBirth​Date​ | Date of birth to set, for example 1990-05-15. Pass null to remove the existing
value. |
mutation SetDateOfBirth {
setDateOfBirth(dateOfBirth: "1990-05-15") {
customer { id dateOfBirth }
userErrors { code message field }
}
}
{
"data": {
"setDateOfBirth": {
"customer": {
"id": "AQMAAURFREVERERFpEVERERFREUAAAABAAAAAAABAAEAAAAAAAEAAAABAAEAAA",
"dateOfBirth": "1990-05-15"
},
"userErrors": []
}
}
}
Set Customer company name
Sets the company name of the signed-in Customer.
| Arguments | |
|---|---|
companyName​String​ | Company name to set. Pass null to remove the existing value. |
mutation SetCompanyName {
setCompanyName(companyName: "Acme Corp") {
customer { id companyName }
userErrors { code message field }
}
}
{
"data": {
"setCompanyName": {
"customer": {
"id": "AQMAAURFREVERERFpEVERERFREUAAAABAAAAAAABAAEAAAAAAAEAAAABAAEAAA",
"companyName": "Acme Corp"
},
"userErrors": []
}
}
}
Set Customer VAT ID
Sets the individual VAT ID of the signed-in Customer.
| Arguments | |
|---|---|
vatId​String​ | VAT ID to set. Pass null to remove the existing value. |
mutation SetVatId {
setVatId(vatId: "GB123456789") {
customer { id vatId }
userErrors { code message field }
}
}
{
"data": {
"setVatId": {
"customer": {
"id": "AQMAAURFREVERERFpEVERERFREUAAAABAAAAAAABAAEAAAAAAAEAAAABAAEAAA",
"vatId": "GB123456789"
},
"userErrors": []
}
}
}
Change Customer password
Changes the password of the signed-in Customer.
This ends the session. Changing the password invalidates every token issued to the Customer, so the next request with this session is rejected. Sign in again with the new password.
| Arguments | |
|---|---|
currentPassword​String​ | Current password of the Customer. A wrong value returns
INVALID_CURRENT_PASSWORD. |
newPassword​String​ | Password to set. |
mutation ChangePassword {
changePassword(
currentPassword: "<current-password>"
newPassword: "<new-password>"
) {
customer { id email }
userErrors { code message field }
}
}
{
"data": {
"changePassword": {
"customer": {
"id": "AQMAAURFREVERERFpEVERERFREUAAAABAAAAAAABAAEAAAAAAAEAAAABAAEAAA",
"email": "jane.doe@example.com"
},
"userErrors": []
}
}
}
Change Customer email
changePassword, the
session stays valid.| Arguments | |
|---|---|
input​ | Email change to apply. |
mutation ChangeEmail {
changeEmail(input: {newEmail: "jane.doe@example.co.uk"}) {
customer { id email emailVerified }
userErrors { code message field }
}
}
{
"data": {
"changeEmail": {
"customer": {
"id": "AQMAAURFREVERERFpEVERERFREUAAAABAAAAAAABAAEAAAAAAAEAAAABAAEAAA",
"email": "jane.doe@example.co.uk",
"emailVerified": false
},
"userErrors": []
}
}
}
Add Customer address
Adds an address to the address book of the signed-in Customer. The new address isn't marked for shipping or billing.
country code returns SHIPPING_COUNTRY_NOT_SUPPORTED.| Arguments | |
|---|---|
input​ | Address to add. |
mutation AddAddress {
addAddress(
input: {name: "Jane Doe", line1: "10 Market Street", city: "London", postalCode: "EC2A 4NE", country: "GB"}
) {
address { id name line1 city postalCode country }
userErrors { code message field }
}
}
{
"data": {
"addAddress": {
"address": {
"id": "ARIDAURFREVERERFpEVERERFREUBCHBQMnJTNHRUAAEAAAAAAAEAAAABAAEAAA",
"name": "Jane Doe",
"line1": "10 Market Street",
"city": "London",
"postalCode": "EC2A 4NE",
"country": "GB"
},
"userErrors": []
}
}
}
Update Customer address
addressId
that isn't in the address book returns ADDRESS_NOT_FOUND, and an unrecognized
country code returns SHIPPING_COUNTRY_NOT_SUPPORTED.| Arguments | |
|---|---|
input​ | Address to update and its new values. |
mutation UpdateAddress {
updateAddress(
input: {addressId: "ARIDAURFREVERERFpEVERERFREUBCGFDM2RFNWZGAAEAAAAAAAEAAAABAAEAAA", address: {name: "Jane Doe", line1: "1 Example Street", line2: "Flat 2", city: "London", postalCode: "SW1A 1AA", country: "GB"}}
) {
address { id line1 line2 city postalCode }
userErrors { code message field }
}
}
{
"data": {
"updateAddress": {
"address": {
"id": "ARIDAURFREVERERFpEVERERFREUBCGFDM2RFNWZGAAEAAAAAAAEAAAABAAEAAA",
"line1": "1 Example Street",
"line2": "Flat 2",
"city": "London",
"postalCode": "SW1A 1AA"
},
"userErrors": []
}
}
}
Remove Customer address
id that
isn't in the address book returns ADDRESS_NOT_FOUND.| Arguments | |
|---|---|
id​ID​ | id of the SavedAddress to remove. |
mutation RemoveAddress {
removeAddress(
id: "ARIDAURFREVERERFpEVERERFREUBCHBQMnJTNHRUAAEAAAAAAAEAAAABAAEAAA"
) {
address { id line1 city }
userErrors { code message field }
}
}
{
"data": {
"removeAddress": {
"address": {
"id": "ARIDAURFREVERERFpEVERERFREUBCHBQMnJTNHRUAAEAAAAAAAEAAAABAAEAAA",
"line1": "10 Market Street",
"city": "London"
},
"userErrors": []
}
}
}
Set default Customer address
addressId that isn't in the address book returns
ADDRESS_NOT_FOUND.| Arguments | |
|---|---|
addressId​ID​ | id of the SavedAddress to make the default. |
use​AddressUse​ | Whether to make it the default shipping or the default billing address. Can beSHIPPING, or BILLING​ |
mutation SetDefaultAddress {
setDefaultAddress(
addressId: "ARIDAURFREVERERFpEVERERFREUBCGFDM2RFNWZGAAEAAAAAAAEAAAABAAEAAA"
use: BILLING
) {
address { id line1 isDefaultBilling usableForBilling }
userErrors { code message field }
}
}
{
"data": {
"setDefaultAddress": {
"address": {
"id": "ARIDAURFREVERERFpEVERERFREUBCGFDM2RFNWZGAAEAAAAAAAEAAAABAAEAAA",
"line1": "1 Example Street",
"isDefaultBilling": true,
"usableForBilling": true
},
"userErrors": []
}
}
}
Output types
Customer
Account of the signed-in Customer.
id​ID​ | Unique identifier of the Customer. |
key​String​ | User-defined unique identifier of the Customer. |
firstName​String​ | Given name (first name) of the Customer. Empty string if not set. |
lastName​String​ | Family name (last name) of the Customer. Empty string if not set. |
middleName​String​ | Middle name of the Customer. |
title​String​ | Title of the Customer, for example Dr.. |
salutation​String​ | Salutation of the Customer, for example Mr. or Ms.. |
dateOfBirth​Date​ | Date of birth of the Customer, for example 1990-05-15. |
companyName​String​ | Company name of the Customer. |
vatId​String​ | Individual VAT ID of the Customer. |
customerNumber​String​ | Customer number assigned in the platform. No mutation in this API sets it. |
email​String​ | Email address of the Customer. |
emailVerified​Boolean​ | Whether the email address of the Customer is
verified. |
authMode​AuthMode​ | Authentication mode of the Customer. Can bePASSWORD, or EXTERNAL_AUTH​ |
addresses​Array of SavedAddress​ | Addresses in the address book of the Customer. |
_ctId​ID​ | Platform identifier (UUID) of the Customer, for extensions that key an external
system such as a CRM by it. The public
id is an opaque global identifier, so
don't parse it.Not part of the public API: an extension can read it with @requires, and it is
removed from the composed API schema. |
Saved Address
An entry in an address book: the signed-in Customer's own address book, or the address book of the selected Business Unit.
UPDATE_BUSINESS_UNIT_DETAILS permission.id​ID​ | Unique identifier of the address. |
name​String​ | Name of the contact, made of the first and last name. If neither is set, contains
the company value. |
title​String​ | Title of the contact, for example Dr.. |
salutation​String​ | Salutation of the contact, for example Mr. or Ms.. |
company​String​ | Name of the company. |
line1​String​ | Street name and street number. |
line2​String​ | Further information on the street address. |
additionalAddressInfo​String​ | Further information on the address. |
poBox​String​ | Post office box number. |
building​String​ | Number or name of the building. |
apartment​String​ | Number or name of the apartment. |
department​String​ | Name of the department. |
city​String​ | Name of the city. |
state​String​ | Name of the state or province, for example Colorado. In a country that taxes by
state, tax selection matches on this value. |
region​String​ | Name of the region, for locales that use a region that is not a state. |
postalCode​String​ | Postal code. |
country​String​ | Two-letter country code as per ISO 3166-1
alpha-2, for example GB. |
phone​String​ | Phone number of the contact. |
mobile​String​ | Mobile phone number of the contact. |
fax​String​ | Fax number of the contact. |
isDefaultShipping​Boolean​ | Whether this address is the default shipping address of the address book. |
isDefaultBilling​Boolean​ | Whether this address is the default billing address of the address book. |
usableForShipping​Boolean​ | Whether the address is marked for shipping. The mark does not restrict anything: checkout accepts any address in the address
book. setDefaultAddress marks the address for the use it makes it the default
for, so a default address always reports true. If no address is marked, every
address reports false. |
usableForBilling​Boolean​ | Whether the address is marked for billing. Same rules as usableForShipping. |
Auth Mode
PASSWORD- The Customer signs in with an email address and password.
EXTERNAL_AUTH- The Customer is authenticated by an external system and has no password in the platform.
Address Use
Use that a saved address can be the default for.
SHIPPING- The address is used for shipping.
BILLING- The address is used for billing.
Customer Result
Saved Address Result
Result of a mutation on an address book.
address​SavedAddress​ | The address the mutation acted on. For removeAddress, the removed address as it
was. null if the mutation is refused, and after a successful
removeBusinessUnitAddress. Check userErrors to tell these cases apart. |
userErrors​Array of UserError​ | Reasons the mutation was refused. Empty on success. |
Input types
Register Input
Profile and credentials of a new Customer.
firstName​String​ | Given name (first name) of the Customer. |
lastName​String​ | Family name (last name) of the Customer. |
email​String​ | Email address of the Customer. An address already used by another Customer returns
EMAIL_ALREADY_IN_USE. |
password​String​ | Password of the Customer. An empty password returns FORBIDDEN_ACTION. |
Update Profile Input
Names to change on the signed-in Customer. Fields you omit or pass as null keep their current value.
firstName​String​ | New given name (first name) of the Customer. |
lastName​String​ | New family name (last name) of the Customer. |
Change Email Input
Email change for the signed-in Customer.
newEmail​String​ | Email address to set. An address already used by another Customer returns
EMAIL_ALREADY_IN_USE. |
Address Book Input
Address to save in an address book.
company or phone, keep their stored values. Omitting line2, state, or
region clears them.name​String​ | Name of the contact. |
line1​String​ | Street name and street number. |
line2​String​ | Further information on the street address. |
city​String​ | Name of the city. |
state​String​ | Name of the state or province, for example Colorado. In a country that taxes by
state, tax selection matches on this value. |
region​String​ | Name of the region, for locales that use a region that is not a state. |
postalCode​String​ | Postal code. |
country​String​ | Two-letter country code as per ISO 3166-1
alpha-2, for example GB. |
Update Address Input
Identifies a saved address and carries its new values.
addressId​ID​ | id of the SavedAddress to update. |
address​ | New values for the address. |