Skip to content

Customer Webhook Notifications

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 payload follows a structured format defined by a JSON schema. Here's an overview of the payload structure:

json
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "newCustomers": {
      "type": "array",
      "items": { "$ref": "#/definitions/CustomerSyncDTO" }
    },
    "updatedCustomers": {
      "type": "array",
      "items": { "$ref": "#/definitions/CustomerSyncDTO" }
    },
    "deletedCustomers": {
      "type": "array",
      "items": { "$ref": "#/definitions/CustomerSyncDTO" }
    }
  },
  "definitions": {
    "CustomerSyncDTO": {
      "type": "object",
      "properties": {
        "id": { "$ref": "#/definitions/IdDTO" },
        "isLegalEntity": { "type": "boolean" },
        "name": { "type": "string" },
        "firstName": { "type": "string" },
        "lastName": { "type": "string" },
        "taxNumber": { "type": "string" },
        "emailAddresses": {
          "type": "array",
          "items": { "type": "string" }
        },
        "phoneNumbers": {
          "type": "array",
          "items": { "type": "string" }
        },
        "billingAddress": { "$ref": "#/definitions/AddressDTO" },
        "postalAddress": { "$ref": "#/definitions/AddressDTO" },
        "categoryDiscounts": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "categoryId": { "type": "integer" },
              "discountPercentage": { "type": "number" }
            },
            "required": ["categoryId", "discountPercentage"]
          }
        },
        "partnerTypes": {
          "type": "array",
          "items": { "$ref": "#/definitions/IdDTO" },
        },
        "customerGroup": { "$ref": "#/definitions/IdDTO" },
      },
      "required": ["id", "isLegalEntity", "name", "firstName", "lastName", "taxNumber", "emailAddresses", "phoneNumbers", "billingAddress", "postalAddress", "categoryDiscounts"]
    },
    "AddressDTO": {
      "type": "object",
      "properties": {
        "countryCode": { "type": "string" },
        "city": { "type": "string" },
        "zipCode": { "type": "string" },
        "street": { "type": "string" },
        "streetType": { "type": "string" },
        "addressNumber": { "type": "string" },
        "building": { "type": "string" },
        "floor": { "type": "string" },
        "door": { "type": "string" },
        "fullStreetAddress": { "type": "string" }
      },
      "required": ["countryCode", "city", "zipCode", "street", "streetType", "addressNumber", "building", "floor", "door", "fullStreetAddress"]
    },
    "IdDTO": {
      "type": "object",
      "properties": {
        "mylionId": { "type": "integer" },
        "externalId": { "type": "string" }
      },
      "required": ["mylionId", "externalId"]
    }
  },
  "required": ["newCustomers", "updatedCustomers", "deletedCustomers"]
}
  • newCustomers: An array containing details of new customer registrations.
  • updatedCustomers: An array containing details of updated customer profiles.
  • deletedCustomers: An array containing details of deleted customer records.

Each customer object within these arrays conforms to the CustomerSyncDTO schema, which includes the following properties:

  • id: The unique identifier of the customer, including both MyLION ID and external ID.
  • isLegalEntity: A boolean value indicating whether the customer is a legal entity.
  • name: The name of the customer.
  • firstName: The first name of the customer.
  • lastName: The last name of the customer.
  • taxNumber: The tax identification number of the customer.
  • emailAddresses: An array of email addresses associated with the customer.
  • phoneNumbers: An array of phone numbers associated with the customer.
  • billingAddress: The billing address of the customer, conforming to the AddressDTO schema.
  • postalAddress: The postal address of the customer, conforming to the AddressDTO schema.
  • categoryDiscounts: An array of category discounts applicable to the customer, including category ID and discount percentage.
  • partnerTypes: An array of partner types associated with the customer.
  • customerGroup: The customer group to which the customer belongs.

The AddressDTO schema defines the structure of address information, including country code, city, zip code, street, street type, address number, building, floor, door, and full street address.

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/customers

When 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"
  }
]
java
@Data
public class MLProductResponseListDTO extends ArrayList<MLProductResponseDTO>{
}

@Data
public class MLProductResponseDTO {
  private Integer myLionId;
  private String externalId;
}