Backend API: Update merchant profiles
Edit on GitHubA merchant user updates the profile of the merchant they are assigned to through the merchant-profile resource, and a Back Office user updates the profile of any merchant by its merchant reference through the merchant-profiles resource. Each resource lets its audience change what it can change in its own UI:
- A merchant user can update the same data as on the Merchant Portal profile page: the merchant details (
name,email,registrationNumber,isOpenForRelationRequest), the Storefront URLs, the contact person, the public contact data, the address, and the localized texts. - A Back Office user can update the profile data only. The merchant details, the store status, and the Storefront URLs are managed through the
merchantsresource; if they are sent, they are ignored.
Installation
The endpoints are provided by the MerchantProfile module and require the API Platform integration of the Backend API. For installation instructions, see Install the Merchant Profile Backend API.
Update the profile of your merchant
To update the profile of the merchant the authenticated merchant user is assigned to, send the request:
PATCH /merchant-profile
Request
| HEADER KEY | HEADER VALUE | REQUIRED | DESCRIPTION |
|---|---|---|---|
| Authorization | string | ✓ | Alphanumeric string that authorizes the merchant user to send requests to protected resources. Get it by authenticating as a merchant user. |
| Content-Type | application/vnd.api+json | ✓ | The request body is a JSON:API document. |
The merchant of the authenticated user must be approved. A merchant user of a merchant that is still waiting for approval gets a 403 response, as in the Merchant Portal.
The update is partial: attributes you omit keep their stored values. An attribute set to null clears the stored value; null is rejected with a 422 error for the required attributes listed in the table below. Attributes that hold an object or a list behave as follows:
address: the fields are merged. A field you omit keeps its stored value;nullclears it. The address can’t be removed.merchantUrls: entries are merged bylocaleName. A URL can be replaced but not removed. Send the part of the URL after the locale prefix—for example,spryker. The prefix/{language code}/merchant/is prepended automatically, as on the Merchant Portal profile page; a URL that already starts with it is stored as is. The response always contains the full URL.localizedAttributes: entries are merged bylocaleName, and within an entry by text. A text you omit keeps its stored value;nullremoves the text. Locales you omit stay untouched.
The following rules apply to a merchant user, as on the Merchant Portal profile page:
merchantUrlsandlocalizedAttributesaccept only the locales of the stores the merchant is assigned to. The stores are listed in thestoresattribute of the profile.- A URL must be unique across the shop and must not contain whitespace or backslashes.
- The texts in
localizedAttributesmay contain only the HTML tagsh1toh6,br, andp.
Request sample: update the contact person and the German texts of your merchant
PATCH https://glue-backend.mysprykershop.com/merchant-profile
{
"data": {
"type": "merchant-profile",
"attributes": {
"contactPersonFirstName": "Harald",
"contactPersonLastName": "Schmidt",
"contactPersonPhone": "+49 30 208498350",
"localizedAttributes": [
{
"localeName": "de_DE",
"description": "Spryker ist der führende Anbieter für Unterhaltungselektronik.",
"deliveryTime": "1-3 Werktage"
}
]
}
}
}
Request sample: rename your merchant, set its Storefront URLs, and clear the fax number
PATCH https://glue-backend.mysprykershop.com/merchant-profile
{
"data": {
"type": "merchant-profile",
"attributes": {
"name": "Spryker Systems",
"faxNumber": null,
"merchantUrls": [
{
"localeName": "de_DE",
"url": "spryker-systems"
},
{
"localeName": "en_US",
"url": "spryker-systems"
}
],
"address": {
"city": "Hamburg",
"zipCode": "20095"
}
}
}
}
| ATTRIBUTE | TYPE | REQUIRED | DESCRIPTION |
|---|---|---|---|
| name | String | ✓ | Name of the merchant. Can’t be null. |
| String | ✓ | Contact email of the merchant. Must be unique across merchants. Can’t be null. |
|
| registrationNumber | String | Official business registration number. | |
| isActive | Boolean | ✓ | Defines whether the merchant’s store is online, as the “Store Status” switch of the Merchant Portal. false removes the merchant from the Storefront and makes its offers unavailable; merchant users keep their access. Can’t be null. |
| isOpenForRelationRequest | Boolean | Defines whether the merchant accepts merchant relation requests. | |
| merchantUrls | Array | URLs of the merchant page, merged by localeName. Each entry has localeName and url; url can’t be null. Send the part after the /{language code}/merchant/ prefix; the prefix is prepended automatically. |
|
| contactPersonTitle | String | Title of the contact person: Mr, Mrs, Dr, or Ms. |
|
| contactPersonFirstName | String | ✓ | First name of the contact person. Must not contain :, /, <, or >. Can’t be null. |
| contactPersonLastName | String | ✓ | Last name of the contact person. Must not contain :, /, <, or >. Can’t be null. |
| contactPersonRole | String | Role of the contact person in the merchant company. | |
| contactPersonPhone | String | Phone number of the contact person. | |
| publicEmail | String | Email address shown to customers. | |
| publicPhone | String | Phone number shown to customers. | |
| faxNumber | String | Fax number of the merchant. | |
| logoUrl | String | URL of the merchant logo. Must not contain whitespace or backslashes. | |
| address | Object | Business address, merged field by field: countryIso2Code, zipCode, city, address1, address2, address3, latitude, longitude. countryIso2Code must be a configured country and can’t be null. |
|
| localizedAttributes | Array | Texts to update, merged by localeName and by text. Each entry has localeName and any of description, bannerUrl, deliveryTime, termsConditions, cancellationPolicy, imprint, and dataPrivacy. bannerUrl can’t be null and must not contain whitespace or backslashes. |
merchantReference and stores can’t be changed. Required means the attribute can’t be cleared; you can still omit it to keep the stored value.
Response
The response contains the full profile as it is stored after the update, in the same structure as Retrieve the profile of your merchant.
| ATTRIBUTE | TYPE | DESCRIPTION |
|---|---|---|
| merchantReference | String | Unique reference of the merchant. It is also the resource id. Read-only. |
| name | String | Name of the merchant. |
| String | Contact email of the merchant. Unique across merchants. | |
| registrationNumber | String | Official business registration number of the merchant. |
| isActive | Boolean | Defines whether the merchant’s store is online. An inactive merchant is not published on the Storefront, and its product offers can’t be bought; its merchant users keep their access. |
| isOpenForRelationRequest | Boolean | Defines whether the merchant accepts merchant relation requests. null until it is set. |
| stores | Array | Names of the stores the merchant is assigned to. Read-only. |
| merchantUrls | Array | URLs of the merchant page on the Storefront, one entry per locale. |
| merchantUrls.localeName | String | Locale of the entry—for example, de_DE. |
| merchantUrls.url | String | Relative URL of the merchant page in the locale—for example, /de/merchant/spryker. null if no URL is set for the locale yet—for example, right after a new store is assigned to the merchant. |
| contactPersonTitle | String | Title of the contact person: Mr, Mrs, Dr, or Ms. |
| contactPersonFirstName | String | First name of the contact person. |
| contactPersonLastName | String | Last name of the contact person. |
| contactPersonRole | String | Role of the contact person in the merchant company. |
| contactPersonPhone | String | Phone number of the contact person. |
| publicEmail | String | Email address shown to customers. |
| publicPhone | String | Phone number shown to customers. |
| faxNumber | String | Fax number of the merchant. |
| logoUrl | String | URL of the merchant logo. |
| address | Object | Business address of the merchant. A profile has exactly one address. |
| address.countryIso2Code | String | Two-letter ISO 3166-1 country code of the address. |
| address.zipCode | String | Postal code. |
| address.city | String | City. |
| address.address1 | String | First line of the address, usually the street. |
| address.address2 | String | Second line of the address, usually the house number. |
| address.address3 | String | Third line of the address. |
| address.latitude | String | Latitude of the address in decimal degrees. |
| address.longitude | String | Longitude of the address in decimal degrees. |
| localizedAttributes | Array | Texts of the merchant per locale, with null where a text is not translated. |
| localizedAttributes.localeName | String | Locale of the entry—for example, de_DE. |
| localizedAttributes.description | String | Description of the merchant. |
| localizedAttributes.bannerUrl | String | URL of the merchant banner. null if no banner is set for the locale yet. |
| localizedAttributes.deliveryTime | String | Delivery time information. |
| localizedAttributes.termsConditions | String | Terms and conditions. |
| localizedAttributes.cancellationPolicy | String | Cancellation policy. |
| localizedAttributes.imprint | String | Imprint. |
| localizedAttributes.dataPrivacy | String | Data privacy statement. |
Update a merchant profile
To update the profile of a merchant as a Back Office user, send the request:
PATCH /merchant-profiles/{{merchant_reference}}
| PATH PARAMETER | DESCRIPTION |
|---|---|
| {{merchant_reference}} | Reference of the merchant whose profile to update. |
The merchant does not have to be approved: a Back Office user updates the profile of a merchant that is still waiting for approval, as in the Back Office.
Request
| HEADER KEY | HEADER VALUE | REQUIRED | DESCRIPTION |
|---|---|---|---|
| Authorization | string | ✓ | Alphanumeric string that authorizes the Back Office user to send requests to protected resources. Get it by authenticating as a Back Office user. |
| Content-Type | application/vnd.api+json | ✓ | The request body is a JSON:API document. |
The merge rules for address and localizedAttributes are the same as for Update the profile of your merchant, with the following differences:
name,email,registrationNumber,isActive,isOpenForRelationRequest, andmerchantUrlsare read-only. If they are sent, they are ignored. To change them, use themerchantsresource.localizedAttributesaccepts every locale configured in the project, and the texts are not restricted to a set of HTML tags, as in the Back Office.
Request sample: update the public contact data and the English description of a merchant
PATCH https://glue-backend.mysprykershop.com/merchant-profiles/MER000001
{
"data": {
"type": "merchant-profiles",
"id": "MER000001",
"attributes": {
"publicEmail": "[email protected]",
"publicPhone": "+49 30 208498350",
"localizedAttributes": [
{
"localeName": "en_US",
"description": "Spryker is your partner for consumer electronics."
}
]
}
}
}
| ATTRIBUTE | TYPE | REQUIRED | DESCRIPTION |
|---|---|---|---|
| contactPersonTitle | String | Title of the contact person: Mr, Mrs, Dr, or Ms. |
|
| contactPersonFirstName | String | ✓ | First name of the contact person. Must not contain :, /, <, or >. Can’t be null. |
| contactPersonLastName | String | ✓ | Last name of the contact person. Must not contain :, /, <, or >. Can’t be null. |
| contactPersonRole | String | Role of the contact person in the merchant company. | |
| contactPersonPhone | String | Phone number of the contact person. | |
| publicEmail | String | Email address shown to customers. | |
| publicPhone | String | Phone number shown to customers. | |
| faxNumber | String | Fax number of the merchant. | |
| logoUrl | String | URL of the merchant logo. Must not contain whitespace or backslashes. | |
| address | Object | Business address, merged field by field: countryIso2Code, zipCode, city, address1, address2, address3, latitude, longitude. countryIso2Code must be a configured country and can’t be null. |
|
| localizedAttributes | Array | Texts to update, merged by localeName and by text. Each entry has localeName and any of description, bannerUrl, deliveryTime, termsConditions, cancellationPolicy, imprint, and dataPrivacy. bannerUrl can’t be null and must not contain whitespace or backslashes. |
Response
The response contains the full profile as it is stored after the update, in the same structure as Retrieve a merchant profile.
Possible errors
The request is validated as a whole: if any check fails, nothing is updated and all failed checks are returned in the errors array.
| STATUS | CODE | REASON |
|---|---|---|
| 400 | N/A | The request body is malformed, or data.type doesn’t match the resource: merchant-profile for /merchant-profile, merchant-profiles for /merchant-profiles/{merchant_reference}. |
| 401 | N/A | The Authorization header is missing, or the access token is invalid or expired. |
| 403 | N/A | The authenticated user is a merchant user calling /merchant-profiles/{merchant_reference}, or a Back Office user calling /merchant-profile. |
| 403 | N/A | The access token carries the merchant user scope, but the user is not assigned to a merchant. |
| 403 | N/A | The merchant of the authenticated merchant user is not approved. |
| 404 | N/A | The merchant with the specified reference doesn’t exist. |
| 422 | 901 | An attribute has a wrong type, or a required attribute is set to null. |
| 422 | N/A | A merchantUrls or localizedAttributes entry names a locale that is not configured. |
| 422 | N/A | A merchantUrls or localizedAttributes entry names a locale that doesn’t belong to a store of the merchant. Applies to /merchant-profile only. |
| 422 | N/A | A URL is already used by another merchant or another page. |
| 422 | N/A | A text contains an HTML tag other than h1 to h6, br, or p. Applies to /merchant-profile only. |
| 422 | N/A | address.countryIso2Code is not a configured country. |
| 422 | N/A | email is already used by another merchant. Applies to /merchant-profile only. |
| 422 | N/A | The request body fails validation—for example, contactPersonTitle is not one of Mr, Mrs, Dr, Ms, or a text in localizedAttributes is an empty string. |
To view generic errors and status codes of the Backend API, see Backend API request and response reference.
Thank you!
For submitting the form