Managing customers

Edit on GitHub

The Customer API allows creating customers and managing 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 to:

  • Retrieve relevant customer information for any page where it is needed
  • 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 https://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": "https://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, they receive a verfication email. They click the verification link to confirm registration. After that, you can authenticate as a customer to perform requests to the protected resources available to them.

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": "https://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 https://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": "https://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 https://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.

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

Response

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

Possible errors

Code Reason
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 receive 901 instead of 422.

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

Next steps