Create parcel labels with FileMaker and the DHL API
The connection of FileMaker to the DHL REST API enables the automated creation of parcel labels for shipping. In this guide you will learn step by step how to program FileMaker so that your FileMaker solution communicates with the DHL REST API to request and download parcel labels.
The DHL API can be used to automate a wide range of shipping and tracking processes. In addition to creating parcel labels (shipping labels), users can also automate tracking to monitor the status of their parcels in real time. The API also enables the creation of return labels to simplify the return process for customers. Furthermore, important shipping documents such as customs declarations for international shipments can be created directly and integrated into the shipping process. In addition, shipments can be prioritized or certain shipping options such as cash on delivery or insurance can be added. The DHL API thus offers a comprehensive solution for optimizing the entire shipping process and fully integrating it into existing systems such as FileMaker. In this guide, we will show you how to create parcel labels with the API.
Four FileMaker ERP platforms with CRM and merchandise management for optimal operating processes.
Request information
Prerequisites
- A DHL business customer account with access to the DHL Business Customer API.
- The access data for the DHL REST API, i.e. API key, user name and password.
- FileMaker Pro version 16 or higher, as these versions natively support the required HTTP requests.
1. set up DHL business customer account and API access
Before you can integrate the DHL API into FileMaker, you need access to the DHL API:
- Go to the DHL Developer Portal page: DHL Developer Portal.
- Register with your business customer account.
- Request the API access data (API key, user name, password).
- Verify your access and activate the "DHL Shipping API" service.
2. first steps with the DHL API
The DHL API uses HTTP requests to send and receive data. The most important functions for creating a parcel label are:
- AuthenticationBasic authentication with user name and password.
- Creating a label (parcel label)Send the shipping data and receive the label as a PDF.
- Retrieving the labelThe return is in binary PDF format, which can be saved and used in a container field in FileMaker.
3. FileMaker scripts for accessing the DHL API
FileMaker uses the command Insert from URL in combination with cURL options to send HTTP requests to the API and receive responses.
3.1 Prepare authentication
DHL uses basic authentication. In FileMaker, this is achieved by providing the user name and password in Base64 format. Below you will find an example of how you can prepare the authentication:
Base64Encode("Username:Password")
In FileMaker, you can enter this string directly in the Insert from URL-command with the corresponding cURL options.
3.2 Create dispatch bills
The API requires certain information such as sender address, recipient address, weight, shipping method, etc. The following is a simple example of a request to the DHL API to create a label.
Script: Create parcel label
- Open the Script Workspace window in FileMaker.
- Create a new script, e.g. "Create package label".
- Add the following variables to save the shipping data:
Set variable [ $url; value: "https://cig.dhl.de/services/production/rest/sendungsverfolgung/v2/paketmarken" ]
Set variable [ $auth; Value: "Base64Encode(username:password)" ]
Set variable [ $payload; Value: "{ 'Version': '2.0', 'shipmentDetails': {...} }" ]
# Insert the shipping data in JSON format here
Example of the JSON request (payload) that you send to DHL:
{
"Version": "2.0",
"ShipmentOrder": [
{
"sequenceNumber": "1",
"Shipment": {
"Shipper": {
"Name": "Your company",
"Address": {
"StreetName": "Street",
"BuildingNumber": "1",
"PostalCode": "12345",
"City": "town",
"CountryCode": "DE"
}
},
"Receiver": {
"name": "recipient",
"Address": {
"StreetName": "Recipient street",
"BuildingNumber": "10",
"PostalCode": "54321",
"City": "recipient city",
"CountryCode": "DE"
}
},
"ShipmentDetails": {
"ProductCode": "V01PAK", # Shipping method (e.g. national parcel)
"WeightInKG": "2.5", # Weight of the package
"CustomerReference": "123456", # Reference number
"ShipmentDate": "2023-09-01"
}
},
"LabelResponseType": "URL"
}
]
}
Use the Insert from URL-command to send the request to DHL and create the label:
Insert from URL [ Selection ; Target: $response ; URL: $url ; cURL options:
"-X POST --header \"Authorization: Basic " & $auth & "\"" &
"--header \"Content-Type: application/json\"" &
"--data " & $payload ]
3.3 Download and save label
The created label is returned by the API in the form of a PDF file. You can save it in a FileMaker container field.
- Insert a container field in your FileMaker database to save the PDF file.
- Change your script so that the PDF file is downloaded into this container field:
Insert from URL [ Selection ; Target: Table::Container field ; URL: "response-PDF-URL" ]
The response-PDF-URL field is returned by the DHL API after the label has been successfully created and contains the URL where the PDF can be downloaded.
FileMaker Crash Course
Fast and effective FileMaker
learning in 20 chapters.
Participate free of charge
4. create JSON payload with FileMaker
Below is a FileMaker script that shows how you can build the JSON payload with data from FileMaker fields. In this example, we assume that the fields in your FileMaker database contain information about the sender, recipient and shipping details and call your table "Table" with the corresponding field names, which you must adapt accordingly in your FileMaker solution. The JSON structure corresponds to the one you can send to the DHL API.
Example script in FileMaker:
# Set variables for JSON structure
Set variable [ $jsonSender; Value: JSONSetElement ( "{}" ;
[ "Name" ; Table::SenderCompany ; JSONString ] ;
[ "Address.StreetName" ; Table::SenderStreet ; JSONString ] ;
[ "Address.BuildingNumber" ; Table::SenderHouseNumber ; JSONString ] ;
[ "Address.PostalCode" ; Table::SenderPLZ ; JSONString ] ;
[ "Address.City" ; Table::SenderCity ; JSONString ] ;
[ "Address.CountryCode" ; Table::SenderCountry ; JSONString ]
)]
Set variable [ $jsonReceiver; Value: JSONSetElement ( "{}" ;
[ "Name" ; Table::RecipientName ; JSONString ] ;
[ "Address.StreetName" ; Table::RecipientStreet ; JSONString ] ;
[ "Address.BuildingNumber" ; Table::RecipientHouseNumber ; JSONString ] ;
[ "Address.PostalCode" ; Table::RecipientPLZ ; JSONString ] ;
[ "Address.City" ; Table::RecipientCity ; JSONString ] ;
[ "Address.CountryCode" ; Table::RecipientCountry ; JSONString ]
)]
Set variable [ $jsonShippingDetails; Value: JSONSetElement ( "{}" ;
[ "ProductCode" ; Table::ProductCode ; JSONString ] ;
[ "WeightInKG" ; Table::Shipping weight ; JSONNumber ] ;
[ "CustomerReference" ; Table::ReferenceNumber ; JSONString ] ;
[ "ShipmentDate" ; Table::ShipmentDate ; JSONString ]
)]
# Structure of the entire JSON document
Set variable [ $payload; Value: JSONSetElement ( "{}" ;
[ "Version" ; "2.0" ; JSONString ] ;
[ "ShipmentOrder[0].sequenceNumber" ; "1" ; JSONString ] ;
[ "ShipmentOrder[0].Shipment.Shipper" ; $jsonSender ; JSONObject ] ;
[ "ShipmentOrder[0].Shipment.Receiver" ; $jsonEmpfänger ; JSONObject ] ;
[ "ShipmentOrder[0].Shipment.ShipmentDetails" ; $jsonVersanddetails ; JSONObject ] ;
[ "ShipmentOrder[0].LabelResponseType" ; "URL" ; JSONString ]
)]
The generated JSON payload is saved in the variable $payload which you can use as the definition of the variable $payload in the Create package label script above.
Customizable FileMaker ERP with merchandise management and logistics interfaces.
More information
Frequently asked questions about FileMaker and the DHL API
- What is the DHL interface and how can it be integrated with FileMaker?
- The DHL interface enables the automated sending of parcel data to DHL and the retrieval of parcel labels and tracking data. In FileMaker, you can use this interface to automate shipping processes and generate parcel labels directly from your database.
- What are the advantages of integrating the DHL interface into FileMaker?
- The integration allows you to save time and avoid errors, as shipping data is transferred directly from the FileMaker database to DHL. You can also generate parcel labels automatically and integrate shipment tracking into your system, which increases efficiency in the shipping process.
- What information do I need to use the DHL interface in FileMaker?
- You need access data for the DHL API (customer number, user name, password) as well as the endpoints of the DHL API. This information will be provided by DHL after you have registered for access to the interface.
- How do I generate parcel labels via the DHL interface in FileMaker?
- Once you have entered the shipping data such as recipient address, weight and shipping method in FileMaker, you can send this information to the DHL interface via an API script. In return, you will receive a parcel number and a printable label that can be saved in FileMaker or printed out directly.
- Can I integrate shipment tracking into FileMaker?
- Yes, with the DHL interface you can retrieve the tracking number and save it in FileMaker. You can use the API to query the current status of a parcel in real time and display this information directly in your database.
- Is the DHL interface in FileMaker only suitable for national shipments?
- No, the DHL interface supports both national and international shipments. Depending on the shipping destination and shipping type, you can transfer various parameters to the DHL API in FileMaker in order to generate labels and shipping information for different countries.
- How secure is the use of the DHL API with FileMaker?
- Communication with the DHL API takes place via HTTPS, which ensures secure data transmission. In FileMaker, you should ensure that sensitive data such as API access data and customer information is stored and protected in encrypted fields.
- Can I create automated processes for the DHL interface in FileMaker?
- Yes, you can create scripts in FileMaker that automatically send shipping data to DHL, retrieve parcel labels and regularly update shipment tracking. These processes can also be run on a scheduled basis to enable full automation of the shipping process.
- What requirements does DHL have for the integration of the interface in FileMaker?
- DHL requires that the API is implemented correctly, including compliance with the API specifications described in the DHL API documentation. You must also ensure that your application is released for productive use after DHL has checked the implementation.
- What do I do if a problem occurs when using the DHL interface in FileMaker?
- If problems occur when communicating with the DHL API, you should first check the responses to the API requests in FileMaker. The error codes and messages from DHL often provide detailed information about the problem. If difficulties persist, you can consult DHL support or the technical documentation of the API to solve the problem.
Summary
By connecting FileMaker to the DHL REST API, you can efficiently automate the creation of parcel labels. The most important steps are summarized below:
- Request and configure API access data.
- Create scripts in FileMaker to send shipping data to DHL.
- Receive and save PDF labels.
- Integrate error handling to monitor API responses.
This setup allows you to fully integrate the shipping process into FileMaker and create parcel labels directly from your database.
