Business Partners: Customer / Client
Customers and clients are referred to as business partners in X4Fleet. New business partners are automatically imported and created when posting a shipment (POST Shipment). However, if orders are entered manually or if the business partner catalogue is to be synchronised between the upstream system and X4Fleet, the following API endpoints can be used.
Endpoints
POST /x4gateway/v1/import/client
and
GET /x4gateway/v1/import/client/{id} --> standard GET request by ID
GET /x4gateway/v1/import/client --> GET request by RefID
PUT /x4gateway/v1/import/client/{id} --> UPDATE request by ID
DELETE /x4gateway/v1/import/client/{id} --> standard DELETE request by ID
Request
{
"refId": "string",
"organisation": "string",
"contactName": "string",
"name2": "string",
"clientNumber": "string",
"roles": 0, //role of the business partner (customer, client, both), new business partners without a value: customer (1)
"vat": 0,
"invoicingVatDisplay": 0,
"priority": {},
"invoicingMails": [],
"creditRating": 0,
"daysForPayment": 0,
"skontoDaysForPayment": 0,
"skontoDiscountPercent": 0,
"generalPositionsDiscount": 0,
"guSurchargePercent": 0,
"guFuelSurchargePercent": 0,
"guLoadingToolSurchargePercent": 0,
"guLoadingToolSurchargeFix": 0,
"phone1": "string",
"phone2": "string",
"email": "string",
"location": {}, //address / coordinates
"profilePix": "string",
"language": "string",
"paymentType": 0,
"notes": "string",
"contacts": [ //contact persons, see fields below
{
"id": 0, //assigned by the system
"refId": "string", //reference to the contact person in the upstream system
"contactName": "string",
"organisation": "string",
"...": "..."
}
],
"poBox": "string", //PO box
"fax": "string",
"web": "string", //website
"assignedLocations": [{}], //assigned locations
}
Used enums: Role, Creditworthiness, Payment type.
Import and Update Rules
Business Partners
- A POST with a
refIdthat is already assigned to another business partner is rejected. Existing business partners are updated with PUT. - Fields that are omitted or sent as
nullkeep their stored value. For text fields, an empty string""overwrites the stored value with an empty value. invoicingMailsis only overwritten if at least one non-empty address is sent.- If
rolesis not sent, the stored role is kept. New business partners sent without a role receive the role customer (1).
Contacts
A contact (contacts) has the following fields: id, refId, contactName, organisation, phone1, phone2, email, location, fax, poBox, birthday, notes, isMainContact.
- A contact is only accepted if at least one of the fields
contactName,organisation,email,phone1orphone2is filled in. Contacts without any of these details are ignored. - Existing contacts are matched first by
idand then byrefId. Special characters in therefId(e.g. "Łódź") are supported. - Fields that are omitted or sent as
nullkeep their stored value. An empty string""overwrites the stored value with an empty value. Exception: therefIdof a contact cannot be cleared. - The
refIdof a contact can be changed. To do so, identify the contact by itsidand send the newrefId. - A
refIdthat is empty or consists only of spaces is treated as not sent. - Contacts sent with neither
idnorrefIdare, by default, not reliably matched to an existing contact and are usually created anew, which can lead to duplicates. To avoid this, matching by content can be enabled (see below). - A contact without its own
refIdis returned with a system-generated numericrefId. For contacts created via the API without arefId, this value is also stored. ThisrefIdis not a reference from the upstream system, can change between calls and must not be used for identification. Use theid, your ownrefIdor matching by content instead.
Matching Contacts by Content
With the setting Match gateway contacts without refId by content, contacts sent without id and without refId are matched to an existing contact by their content. The setting is disabled by default and takes effect when it is enabled in the main group. It is located in the settings on the Import tab, Import shipment settings section, and is only visible to super administrators. To have the setting enabled, please contact support.
- Matching order: first by
id, then by arefIdthat was sent, and only then by content. Contacts withidorrefIdare never matched by content. organisation,contactNameandphone1are compared. If all three are empty,emailandphone2are compared instead.- For
organisation,contactNameandemail, upper/lower case, leading and trailing spaces and multiple spaces are ignored. Forphone1andphone2, only the digits are compared; dialling codes are not normalised, so+41 52 …and052 …are treated as different. - An existing contact is only found if at least one of the following fields is sent exactly as it is stored (except for upper/lower case):
contactNameorphone1(if onlyorganisationis filled among the three fields:organisation), oremailorphone2if these are compared. - The search covers the contacts of the main group. If several contacts match, the contact with the lowest
idis used. - Identical contacts within the same request are merged into one contact.
- Matching also applies to site contacts and to the contacts in orders.
Response
The response structure is analogous to the request structure; all information sent in the POST as well as system-added information is returned.
The ID / business partner ID is important information that should ideally be stored in the upstream system.
Common Error Messages
GET:
- {"code":5,"messages":["Client with this id or refNr does not exist"],"RequestId":null,"Id":0}