Appearance
Customer Webhook Notifications
v1 Only
This webhook has no v2 version. v1 is the current and only version.
The Customer Updates Webhook from MyLION provides notifications about changes to customer information within the MyLION ERP system. By subscribing to this webhook, you can stay informed about new customer registrations, updated customer profiles, and deleted customer records. This article will explore the payload structure of the webhook notification and how to interpret the data to keep your customer records synchronized with MyLION.
Payload Structure
The Customer Updates Webhook sends a single JSON object with three arrays. Each array contains customers of one change type. Every customer object follows the CustomerSyncDTO structure described below.
json
{
"newCustomers": [
{
"id": {
"myLionId": 1001,
"externalId": "CUST-0001"
},
"legalEntity": true,
"name": "Example Trading Ltd.",
"firstName": null,
"lastName": null,
"taxNumber": "HU12345678",
"groupTaxNumber": "HU12345678-1-41",
"euTaxNumber": "HU12345678",
"emailAddresses": ["info@example-trading.com"],
"phoneNumbers": ["+36 1 234 5678"],
"billingAddress": {
"countryCode": "HU",
"city": "Budapest",
"zipCode": "1051",
"street": "Example",
"streetType": "utca",
"addressNumber": "12",
"building": "B",
"floor": "2",
"door": "5",
"fullStreetAddress": "Budapest, Example utca 12. B lph. 2/5"
},
"postalAddress": {
"countryCode": "HU",
"city": "Budapest",
"zipCode": "1051",
"street": "Example",
"streetType": "utca",
"addressNumber": "12",
"building": "",
"floor": "",
"door": "",
"fullStreetAddress": "Budapest, Example utca 12."
},
"categoryDiscounts": [
{
"categoryId": 15,
"discountPercentage": 10.00
}
],
"partnerTypes": [
{
"myLionId": 3,
"externalId": "PT_RESELLER"
}
],
"customerGroup": {
"myLionId": 7,
"externalId": "GRP_B2B"
},
"contacts": [
{
"identifiers": {
"myLionId": 2001,
"externalId": "CONT-0001"
},
"firstName": "Anna",
"lastName": "Kovacs",
"emails": ["anna.kovacs@example-trading.com"],
"phones": ["+36 30 123 4567"],
"registeredToNewsletters": true,
"language": {
"myLionId": 1,
"externalId": "hu"
}
}
]
}
],
"updatedCustomers": [],
"deletedCustomers": []
}{
"newCustomers": [
{
"id": {
"myLionId": 1001,
"externalId": "CUST-0001"
},
"legalEntity": true,
"name": "Example Trading Ltd.",
"firstName": null,
"lastName": null,
"taxNumber": "HU12345678",
"groupTaxNumber": "HU12345678-1-41",
"euTaxNumber": "HU12345678",
"emailAddresses": ["info@example-trading.com"],
"phoneNumbers": ["+36 1 234 5678"],
"billingAddress": {
"countryCode": "HU",
"city": "Budapest",
"zipCode": "1051",
"street": "Example",
"streetType": "utca",
"addressNumber": "12",
"building": "B",
"floor": "2",
"door": "5",
"fullStreetAddress": "Budapest, Example utca 12. B lph. 2/5"
},
"postalAddress": {
"countryCode": "HU",
"city": "Budapest",
"zipCode": "1051",
"street": "Example",
"streetType": "utca",
"addressNumber": "12",
"building": "",
"floor": "",
"door": "",
"fullStreetAddress": "Budapest, Example utca 12."
},
"categoryDiscounts": [
{
"categoryId": 15,
"discountPercentage": 10.00
}
],
"partnerTypes": [
{
"myLionId": 3,
"externalId": "PT_RESELLER"
}
],
"customerGroup": {
"myLionId": 7,
"externalId": "GRP_B2B"
},
"contacts": [
{
"identifiers": {
"myLionId": 2001,
"externalId": "CONT-0001"
},
"firstName": "Anna",
"lastName": "Kovacs",
"emails": ["anna.kovacs@example-trading.com"],
"phones": ["+36 30 123 4567"],
"registeredToNewsletters": true,
"language": {
"myLionId": 1,
"externalId": "hu"
}
}
]
}
],
"updatedCustomers": [],
"deletedCustomers": []
}Top-level fields
| Field | Type | Description |
|---|---|---|
newCustomers | Array of CustomerSyncDTO | Customers created since the last notification. |
updatedCustomers | Array of CustomerSyncDTO | Customers changed since the last notification. |
deletedCustomers | Array of CustomerSyncDTO | Customers deleted since the last notification. |
The arrays are always present. An array without changes is empty ([]).
CustomerSyncDTO
| Field | Type | Description |
|---|---|---|
id | IdDTO | Identifier of the customer in MyLION and in the external system. |
legalEntity | Boolean | true if the customer is a legal entity (company), false if it is a private person. |
name | String | Name of the customer. Used for legal entities. |
firstName | String | First name of the customer. Used for private persons. |
lastName | String | Last name of the customer. Used for private persons. |
taxNumber | String | Tax number of the customer. |
groupTaxNumber | String | Group tax number of the customer. |
euTaxNumber | String | EU VAT number of the customer. |
emailAddresses | Array of String | E-mail addresses of the customer. |
phoneNumbers | Array of String | Phone numbers of the customer. |
billingAddress | AddressDTO | Billing address of the customer. |
postalAddress | AddressDTO | Postal address of the customer. |
categoryDiscounts | Array of CategoryDiscount | Discounts granted to the customer per product category. |
partnerTypes | Array of IdDTO | Partner types assigned to the customer. |
customerGroup | IdDTO | Customer group the customer belongs to. |
contacts | Array of EmployeeDTO | Contact persons of the customer. |
IdDTO
| Field | Type | Description |
|---|---|---|
myLionId | Integer | Internal MyLION identifier. |
externalId | String | Identifier of the record in the external system. |
AddressDTO
Used by billingAddress and postalAddress.
| Field | Type | Description |
|---|---|---|
countryCode | String | Country code of the address. |
city | String | City. |
zipCode | String | Postal code. |
street | String | Street name. |
streetType | String | Street type, for example utca or út. |
addressNumber | String | House number. |
building | String | Building. Empty if not applicable. |
floor | String | Floor. Empty if not applicable. |
door | String | Door. Empty if not applicable. |
fullStreetAddress | String | Complete street address as one string. |
CategoryDiscount
Used by categoryDiscounts.
| Field | Type | Description |
|---|---|---|
categoryId | Integer | Identifier of the product category. |
discountPercentage | Decimal | Discount in percent for this category. |
EmployeeDTO
Used by contacts.
| Field | Type | Description |
|---|---|---|
identifiers | GenericIdentifiersDTO | Identifiers of the contact person (externalId and myLionId). |
firstName | String | First name of the contact person. |
lastName | String | Last name of the contact person. |
emails | Array of String | E-mail addresses of the contact person. |
phones | Array of String | Phone numbers of the contact person. |
registeredToNewsletters | Boolean | true if the contact person subscribed to newsletters. |
language | IdDTO | Preferred language of the contact person. |
Receiving and Processing
To process the Customer Webhook Notification from MyLION, you need to set up a receiving endpoint in your application. The endpoint URL should follow this format:
bash
https://<your_base_url>/rest/mylion/v1/customershttps://<your_base_url>/rest/mylion/v1/customersWhen MyLION sends a webhook notification, it will make a POST request to the specified endpoint with the payload containing the updated customers. The expected response is HTTP OK (200).
Response payload
The response should be in the following format:
json
[
{
"myLionId": 123,
"externalId": "EXT_PROD_123"
}
][
{
"myLionId": 123,
"externalId": "EXT_PROD_123"
}
]java
@Data
public class MLProductResponseListDTO extends ArrayList<MLProductResponseDTO>{
}
@Data
public class MLProductResponseDTO {
private Integer myLionId;
private String externalId;
}@Data
public class MLProductResponseListDTO extends ArrayList<MLProductResponseDTO>{
}
@Data
public class MLProductResponseDTO {
private Integer myLionId;
private String externalId;
}