REST API - Customer resource

Introduction

In this part of the documentation you can learn more about the API's customer resource. With this resource, it is possible to retrieve, update and delete any customer of your shop. We will also have a look at the associated data structures.

General Information

This resource supports the following operations:

Access URL GET GET (List) PUT PUT (Batch) POST DELETE DELETE (Batch)
/api/customers Yes Yes Yes No Yes Yes No

If you want to access this resource, simply append your shop URL with

  • http://my-shop-url/api/customers

GET

Required Parameters

It is required to parametrize this API call. The following parameters are available:

Identifier Parameter DB column Example call
Customer Id id s_user.id /api/customers/2
Customer number number s_user_billingaddress.number /api/customers/20003?useNumberAsId=true
  • useNumberAsId=true - This tells the API to query the customer's data by its number, instead of its actual identifier. Otherwise, the syntax is just /api/customers/id. It's not possible to provide both parameters at the same time.

Return Value

Model Table
Shopware\Models\Customer\Customer s_user
Field Type Original Object
id integer (primary key)
paymentId integer (foreign key) Payment
groupKey string (foreign key) CustomerGroup
shopId string (foreign key) Shop
priceGroupId integer (foreign key) PriceGroup
encoderName string
hashPassword string
active boolean
email string
doubleOptInConfirmDate date/time
doubleOptInEmailSentDate date/time
doubleOptInRegister boolean
firstLogin (date of creation) date/time
lastLogin date/time
accountMode integer
confirmationKey string
sessionId string
newsletter boolean
validation string
affiliate boolean
paymentPreset integer
languageId integer (foreign key)
referer string
internalComment string
failedLogins integer
lockedUntil date/time
attribute object CustomerAttribute
billing object Billing
paymentData array PaymentData
shipping object Shipping
debit object Debit

GET (List)

For this operation no parameters are required. To get a list of all customers, simply query:

  • http://my-shop-url/api/customers/
Model Table
Shopware\Models\Customer\Customer s_user

This API call returns an array of elements, one for each customer. Each of these elements has the following structure:

Field Type Original Object
id integer (primary key)
paymentId integer (foreign key) Payment
groupKey string (foreign key) CustomerGroup
shopId string (foreign key) Shop
priceGroupId integer (foreign key) PriceGroup
encoderName string
hashPassword string
active boolean
email string
doubleOptInConfirmDate date/time
doubleOptInEmailSentDate date/time
doubleOptInRegister boolean
firstLogin (date of creation) date/time
lastLogin date/time
accountMode integer
confirmationKey string
sessionId string
newsletter boolean
validation string
affiliate boolean
paymentPreset integer
languageId integer (foreign key)
referer string
internalComment string
failedLogins integer
lockedUntil date/time

Appended to the above-mentioned list, you will also find the following data:

Field Type Comment
total integer The total number of category resources
success boolean Indicates if the call was successful or not.

POST (create) and PUT (update)

To POST or PUT content, use the same data as provided in the GET operation. Only exceptions are for POST as following:

Field Type Comment
sendOptinMail boolean Used to decide if an necessary opt-in confirmation mail will be sent

DELETE

To delete a customer's data, simply call the specified resource with the DELETE operation, as the following example shows:

  • (DELETE) http://my-shop-url/api/customers/id

Replace the id with the specific customer id.

Top