Best for:
- Creating your barcode labels (GS1 or ANSIFACT)
- Creating other documents e.g. CMR, shipment list
All documents are returned in base64 that you need to convert into PDF.
Print API enables creating and printing transport documents that are related to relevant shipment bookings.
Use Cases
There are 2 supported use cases for the Print API, especially with regards to creating barcode labels.
- Creating labels after you have created your bookings via the Booking API (preferred)
Either use the shipment id (/print/printdocumentsbyid) or the complete response information (/print/printdocuments) from the Booking API in your request to the Print API.
When using /print/printdocuments, you can copy the full segment shipment: { .....} from the Booking API into the shipment segment of the Print API and do not need to remove any non-matching fields that the Print API does not require. - Creating standalone only labels, as your company transferred the bookings to DHL Freight via other means (e.g. EDI).
In this case, provide all details in your request (/print/printdocuments) to the Print API.
Important: You must provide your own GS1 or ANSIFACT license plates as DHL Freight will not generate these for you. This use case assumes that you e.g. already created your bookings via EDI and have generated your own company license plates. You must provide your own license plates in your request to the Print API.
Document Types
Following document types can be created:
- Label, with license plate barcode types GS1 or Code128.
For each piece a label is created)
Page type options:- Label (standard 1 label per page)
- Label2xPortraitA4
- Label3xLandscapeA4
- LabelCompact
- Shipment List, containing one or multiple shipments you provided.
The Shipment List provides 2 copies, one for the consignor and one for the driver/chauffeur.
Also note that shipments are grouped per consignor per Shipment List. - Waybill / CMR
- Guarantee (only for Sweden and certain products)
- Return Label (only for Sweden Parcel and certain products)
Print API Response
The Print API provides your requested document types in base64. You'll need to convert this base64 into PDF on your side.
Note: In future the barcode label may also be returned directly in ZPL (Zebra Printer Language) . Contact us if you require this.
Available Methods for above use cases
You can use following methods for your use case.
- POST /print/printdocumentsbyid
This method is very easy to implement and strongly preferred to use, but is off course only available when you also created your bookings prior to the printing! You can simply provide an array of shipment id's and provide the relevant (print) options.
Precondition: you previously already created bookings and now provide your shipment id(s) to the Print API.
Note that the response time will increase with large numbers of shipments and requesting multiple document types at the same time. Also the payload of the response in base64 will become larger. - POST /print/printdocuments
You can provide an array of shipments with all required shipment details for which you need to create e.g. labels or other documents. Note that the response time will increase with large numbers of shipments and requesting multiple document types at the same time. Also the payload of the response in base64 will become larger.
You can also use this method if you did not previously create bookings via the Booking API (= standalone usage of Print API), but you must provide your own generated license plates that you've already sent to DHL Freight via EDI.
For additional information, please contact api4freight@dhl.com
Get Access
You must request credentials for any applications you develop. Please check below the options to request your access:
Internal DHL developer:
|
|
|
|
The “Add App” form appears. |
|
Authentication
Every call to the API requires a subscription key. This key needs to be either passed through a query string parameter or specified in the request header (DHL-API-Key).
The Print API requires a two step authentication where you first need to get access to the Print API (see below) and as a second step you need to retrieve a Bearer Token.
To view your API subscription keys:
- From the My Apps screen, click on the name of your app.
The Details screen appears. - If you have access to more than one API, click the name of the relevant API.
Note: The APIs are listed under the “Credentials” section. - Click the Show link below the asterisks that is hiding the Consumer Key.
The Consumer Key appears.
With your obtained API Key and API Secret you need to obtain a bearer token via the DHL Group Authentication API.
Set username with your API Key
Set Password with your API Secret.
The obtained Bearer Token now can be used for accessing the API products in your APP.
Environments
The addressable API base URL/URI environments are:
Environment | Description |
https://api-sandbox.dhl.com/freight/shipping/labels/v1 | Sandbox environment |
https://api.dhl.com/freight/shipping/labels/v1 | Production environment |
Rate limits
Rate limits protect the DHL infrastructure from suspicious requests that exceed defined thresholds.
The table below details the main request limits:
Service Level | Maximum calls per second | Maximum calls per day |
---|---|---|
Standard |
- | 250 |
Please contact api4freight@dhl.com if you need a different service level.
When the limit is reached, you will receive an HTTP Status code:
429: Too many requests.
Specifics for the use of Freight Print API
- The Print (DHL Freight) API enables creation of transport related documents and barcode labels.
- For the purposes of these Legal Terms, “you”/”your” or “registrant/user” means the (natural) person or entity holding a (transportation) contract with a DHL Freight entity.
- The Print (DHL Freight) API provides the possibility to generate DHL shipment labels using DHL’s shipment number (e.g. Waybill number and DHL Shipment ID). Please be aware that the generation of the shipment label by use of the Print (DHL Freight) API does not constitute the contract of carriage. The contract of carriage will only be concluded when the shipment is handed over or picked up and accepted by DHL.
- If you engage an external developer or other IT services provider to represent you and to develop Your Application according to the General Developer Portal Terms of Use and these special API terms & conditions (also referred to as “Legal Terms”), you are liable for the acts or omissions of such third party in connection with the usage of the Print (DHL Freight) API and the API Services.
- These Legal Terms and the General Developer Portal Terms of Use govern your usage of Print (DHL Freight) API including the API Service and, unless otherwise stated herein, do not replace and/or modify any other DHL Freight terms and conditions, DHL Freight transportation services agreements and/or any other agreements, contracts or SOWs with a specific DHL Freight entity or any of its affiliates, which govern services or products provided to you (separately, each an “Agreement”). Notwithstanding the foregoing, you expressly acknowledge and agree that solely with respect to your use of Print (DHL Freight) API including the API Service these Legal Terms and the General Developer Portal Terms of Use shall have preference over the terms and conditions in an Agreement, unless any terms and conditions in an Agreement specifically address the use of the Print (DHL Freight) API or the API Service by you, in which case the specific terms and conditions of the Agreement shall prevail with respect to Your use of the Print (DHL Freight) API/the API Service.
- The API Productive Key for the Print (DHL Freight) API is a private and individual key for you. it shall not be used by or for other external customers. You may not allow your developer or IT services provider to use your API Productive Key for potential other DHL Freight (transportation) customers.
- Neither DHL Freight nor any other affiliate within DHL Group, is responsible for storing a record of any data (API-call or -request data or the actual contents of the data sets), that has been exchanged via the Print (DHL Freight) API, unless expressly agreed upon in writing (e.g. in the Agreement).
- You shall use the services and/or data that you receive via the Print (DHL Freight) API only for the legitimate business purposes, only in connection with DHL Freight's transportation and/or other services, and in compliance with all applicable laws and regulations, including but not limited to, laws regarding the use of personal data.
- You acknowledge that material and information you may acquire, including (but not limited to) transportation methods, booking information, financial or other accounting information and other procedures and processes relating to the Print (DHL Freight) API and the API Service (“Materials”) are proprietary, confidential, and owned by DHL Freight. Other than described herein, you shall have no additional rights to the Materials.
- For the purposes of the use of the Print (DHL Freight) API and the API Service, these Legal Terms and the General Developer Portal Terms of Use are governed by the law and jurisdiction defined in the Agreement. Should no law or jurisdiction be defined in the Agreement or otherwise, these Legal Terms shall be governed according to the law and jurisdiction of the principal place of business of the according DHL Freight entity/division providing the transportation services.
1.1
- Initial release