Managing customers

Edit on GitHub

The Customer API allows creating customers and manage their account data. This includes the possibility to maintain a set of customer addresses as separate resources. In the checkout process, you can retrieve and use these address resources to speed up the buying process. The API supports authentication via OAuth 2.0 and password restoration.

In your development, these resources can help you:

  • Retrieve relevant customer information. for any page where it is needed.
  • Retrieve customer subscriptions to availability notifications.
  • Enable customer registration.
  • Allow customer login and authentication.
  • Enrich customer profiles with additional data such as addresses.

Installation

For details on the modules that provide the API functionality and how to install them, see Glue API: Customer Access Feature Integration.

Create a customer

To create a customer, send the request:


POST /customers


Request

Request sample: POST http://glue.mysprykershop.com/customers

{
  "data": {
    "type": "customers",
    "attributes": {
        "salutation": "Mrs",
        "firstName":"Sonia",
        "lastName":"Wagner",
        "email":"sonia@spryker.com",
        "password":"change123",
        "confirmPassword":"change123",
        "acceptedTerms":true
    }
  }
}
ATTRIBUTE TYPE REQUIRED DESCRIPTION
acceptedTerms Boolean Specifies whether the customer has accepted the terms of service. For a new customer to be created, this parameter needs to be set to true.
confirmPassword String Specifies a password confirmation for the account of the new customer.
email String Specifies customer’s last email address. The address must be unique in the system.
firstName String Specifies customer’s first name.
lastName String Specifies customer’s last name.
password String Specifies a password (7 characters or more) for the account of the new customer. This password will be used by the customer to access their account.
salutation String Specifies a salutation for a new customer.

Response

Response sample
{
	"data": {
		"type": "customers",
		"id": "DE--25",
		"attributes": {
			"firstName": "Sonia",
			"lastName": "Wagner",
			"gender": null,
			"dateOfBirth": null,
			"salutation": "Mr",
			"createdAt": "2018-11-06 08:15:02.694668",
			"updatedAt": "2018-11-06 08:15:02.694668"
		},
		"links": {
			"self": "http://glue.mysprykershop.com/customers/DE--25"
		}
	}
}

ATTRIBUTE TYPE DESCRIPTION
firstName String Customer’s first name.
lastName String Customer’s last name.
gender String Gender of the customer.
dateOfBirth String Customer’s date of birth.
salutation String Salutation to use when addressing the customer.
createdAt String Account creation date.
updatedAt String Date of the last update.

After creating a customer, users receive a verification email. The email contains a link with the token that confirms and finalizes the customer registration process. Customers click the verification link from the email and finish the registration. Alternatively, you can confirm the customer registration via API (see Confirming customer registration). After confirmation, you can authenticate as a customer to perform requests to the protected resources.

Retrieve customers

To retrieve customers, send the request:


GET /customers/


Request

HEADER KEY HEADER VALUE REQUIRED DESCRIPTION
Authorization string Alphanumeric string that authorizes the customer to send requests to protected resources. Get it by authenticating as a customer.

Request sample: GET https://glue.mysprykershop.com/customers

Response

Response sample
{
    "data": [
        {
            "type": "customers",
            "id": "DE--21",
            "attributes": {
                "firstName": "Sonia",
                "lastName": "Wagner",
                "email": "sonia@spryker.com",
                "gender": "Female",
                "dateOfBirth": null,
                "salutation": "Ms",
                "createdAt": "2020-10-07 07:02:32.683823",
                "updatedAt": "2020-10-07 07:02:32.683823"
            },
            "links": {
                "self": "https://glue.mysprykershop.com/customers/DE--21"
            }
        }
    ],
    "links": {
        "self": "http://glue.mysprykershop.com/customers"
    }
}

See Create a customer to learn about the response attributes.

Retrieve a customer

To retrieve information about a customer, send the request:


GET /customers/{{customerReference}}


PATH PARAMETER DESCRIPTION
{{customerReference}} Unique identifier of the customer to get information for. This parameter is returned as the id attribute when creating a customer.

Request

HEADER KEY HEADER VALUE REQUIRED DESCRIPTION
Authorization string Alphanumeric string that authorizes the customer to send requests to protected resources. Get it by authenticating as a customer.

Request sample: GET http://glue.mysprykershop.com/customers/DE-25

Response

Response sample
{
		"data": {
			"type": "customers",
			"id": "DE--25",
			"attributes": {
				"firstName": "John",
				"lastName": "Doe",
				"gender": null,
				"dateOfBirth": null,
				"salutation": "Mr",
				"createdAt": "2018-11-06 08:15:02.694668",
				"updatedAt": "2018-11-06 08:15:02.694668"
			},
			"links": {
				"self": "http://glue.mysprykershop.com/customers/DE--25"
			}
		}
	}
ATTRIBUTE TYPE DESCRIPTION
firstName String Customer’s first name.
lastName String Customer’s last name.
email String Customer’s email address.
gender String Customer’s gender.
dateOfBirth String Customer’s date of birth.
salutation String Salutation to use when addressing the customer.
createdAt String Account creation date.
updatedAt String Date of the last update.

Edit a customer

To edit a customer account, send the request:


PATCH /customers/{{customerReference}}


PATH PARAMETER DESCRIPTION
{{customerReference}} Unique identifier of the customer to edit. This parameter is returned as the id attribute when creating a customer. If you’ve already created a customer, retrieve customers to get it.

Request

HEADER KEY HEADER VALUE REQUIRED DESCRIPTION
Authorization string Alphanumeric string that authorizes the customer which you want to edit. Get it by authenticating as a customer.

Request sample: PATCH http://glue.mysprykershop.com/customers/DE-25

{
		"data" : {
			"type": "customers"
			"attributes": {
					"lastName": "Sonia",
					"email": "sonia@spryker.com",
				}
		}
	}

Response

Response sample
{
		"data": {
			"type": "customers",
			"id": "DE--25",
			"attributes": {
				"firstName": null,
				"lastName": "Johnson",
				"salutation": null,
				"email": "sonia@spryker.com"
			},
			"links": {
				"self": "http://mysprykershop.com/customers/DE--25"
			}
		}
	}
ATTRIBUTE TYPE DESCRIPTION
firstName String Customer’s first name.
lastName String Customer’s last name.
email String Customer’s email address.
gender String Customer’s gender.
dateOfBirth String Customer’s date of birth.
salutation String Salutation to use when addressing the customer.
createdAt String Account creation date.
updatedAt String Date of the last update.

Anonymize a customer

To anonymize a customer, send the request:


DELETE /customers/{{customerReference}}


PATH PARAMETER DESCRIPTION
{{customerReference}} Unique identifier of the customer to anonimyze. This parameter is returned as the id attribute when creating a customer. If you’ve already created a customer, retrieve customers to get it.

Request

HEADER KEY HEADER VALUE REQUIRED DESCRIPTION
Authorization string Alphanumeric string that authorizes the customer which you want to anonymize. Get it by authenticating as a customer.

Sample request: DELETE http://mysprykershop.com/customers/DE-25

Response

If the customer is anonymized successfully, the endpoint returns the 204 No Content status code.

Retrieve subscriptions to availability notifications

To retrieve subscriptions to availability notifications, send the following:

This request is available for registered customers only.

GET /customers/{{customerReference}}/availability-notifications


PATH PARAMETER DESCRIPTION
{{customerReference}} Unique identifier of the customer to retrieve the subscriptions of. This parameter is returned as the id attribute when creating a customer or retrieving a customer.
HEADER KEY HEADER VALUE REQUIRED DESCRIPTION
Authorization string Alphanumeric string that authorizes the customer or company user to send requests to protected resources. Get it by [authenticating as a customer]

Request

Request sample: GET https://glue.mysprykershop.com/customers/DE--21/availability-notifications

Response

Response sample
{
    "data": [
        {
            "type": "availability-notifications",
            "id": "d634981b8d1930f7db6e2780b7d5600a",
            "attributes": {
                "localeName": "en_US",
                "email": "sonia@spryker.com",
                "sku": "190_25111746"
            },
            "links": {
                "self": "https://glue.69.demo-spryker.com:80/availability-notifications/d634981b8d1930f7db6e2780b7d5600a"
            }
        }
    ],
    "links": {
        "self": "https://glue.69.demo-spryker.com:80/customers/DE--21/availability-notifications"
    }
}
ATTRIBUTE TYPE DESCRIPTION
localeName string Locale of the subscribed customer.
email string Customer email where the product availability email notifications are sent to.
sku string SKU of the product the user receives notifications about.

Other management options

There is an alternative way to retrieve existing subscriptions, for details see Retrieving subscriptions to availability notifications.

Possible errors

CODE REASON
001 Access token is invalid.
002 Access token is missing.
400 Customer with the same email address already exists.
402 Customer with the specified ID was not found.
405 Customer reference is missing.
410 Failed to save changes.
414 Provided gender is invalid.
422 Terms of service were not accepted. Note that if you have the REST Request Format validation enabled, then you will recieve 901 instead of 422.
4606 Request is unauthorized.

To view generic errors that originate from the Glue Application, see Reference information: GlueApplication errors.

Next steps