smart-dato/dhl-parcel-sdk

Laravel SDK for the DHL Parcel DE Shipping v2 API
5,923 1
Install
composer require smart-dato/dhl-parcel-sdk
Latest Version:v0.0.11
PHP:^8.4
Laravel:11 · 12 · 13
License:MIT
Last Updated:Sep 23, 2026
Links: GitHub  ·  Packagist
Maintainer: smart-dato

DHL Parcel DE Shipping SDK for Laravel

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

A Laravel package for the DHL Parcel DE Shipping v2 API. Create shipments, retrieve labels, manage manifests, and more. Built on Saloon and Spatie Laravel Data.

Installation

composer require smart-dato/dhl-parcel-sdk

Publish the config file:

php artisan vendor:publish --tag="dhl-parcel-sdk-config"

Add your credentials to .env:

# OAuth2 (recommended — Basic Auth is deprecated by DHL):
DHL_PARCEL_API_KEY=your-client-id
DHL_PARCEL_CLIENT_SECRET=your-client-secret
DHL_PARCEL_USERNAME=your-business-customer-username
DHL_PARCEL_PASSWORD=your-business-customer-password

# Or legacy API key only:
# DHL_PARCEL_API_KEY=your-api-key

# Or legacy Basic Auth:
# DHL_PARCEL_USERNAME=your-username
# DHL_PARCEL_PASSWORD=your-password

# Enable sandbox for testing:
# DHL_PARCEL_SANDBOX=true

OAuth2 mode is enabled automatically when DHL_PARCEL_CLIENT_SECRET is set together with the API key, username and password. The SDK then exchanges the credentials for a Bearer token against the DHL ROPC token endpoint and caches the token in memory until it expires.

Usage

Create a shipment

use SmartDato\DhlParcel\Data\Orders\ContactAddressData;
use SmartDato\DhlParcel\Data\Orders\ShipmentData;
use SmartDato\DhlParcel\Data\Orders\ShipmentDetailsData;
use SmartDato\DhlParcel\Data\Orders\ShipmentOrderRequestData;
use SmartDato\DhlParcel\Data\Orders\ShipperData;
use SmartDato\DhlParcel\Data\Orders\WeightData;
use SmartDato\DhlParcel\Enums\DocFormat;
use SmartDato\DhlParcel\Enums\Product;
use SmartDato\DhlParcel\Enums\WeightUom;
use SmartDato\DhlParcel\Facades\DhlParcel;

$response = DhlParcel::orders()->create(
    data: new ShipmentOrderRequestData(
        profile: 'STANDARD_GRUPPENPROFIL',
        shipments: [
            new ShipmentData(
                product: Product::V01PAK,
                billingNumber: '33333333330102',
                details: new ShipmentDetailsData(
                    weight: new WeightData(WeightUom::Grams, 500),
                ),
                shipper: new ShipperData(
                    name1: 'My Online Shop GmbH',
                    addressStreet: 'Sträßchensweg 10',
                    city: 'Bonn',
                    country: 'DEU',
                    postalCode: '53113',
                ),
                consignee: new ContactAddressData(
                    name1: 'Maria Musterfrau',
                    addressStreet: 'Kurt-Schumacher-Str. 20',
                    city: 'Bonn',
                    country: 'DEU',
                    postalCode: '53113',
                ),
            ),
        ],
    ),
    docFormat: DocFormat::Pdf,
);

// Access the label
$label = $response->items[0]->label;

Validate a shipment (dry run)

$response = DhlParcel::orders()->validate(
    data: $shipmentOrderRequest,
);

Retrieve existing labels

$response = DhlParcel::orders()->get(
    shipments: ['340434310428091700'],
);

Delete shipments

$response = DhlParcel::orders()->delete(
    profile: 'STANDARD_GRUPPENPROFIL',
    shipments: ['340434310428091700'],
);

Manifests

use SmartDato\DhlParcel\Data\Manifests\ManifestRequestData;

// Get daily manifest
$manifest = DhlParcel::manifests()->get(date: '2025-01-15');

// Close out shipments
$response = DhlParcel::manifests()->create(
    data: new ManifestRequestData(
        profile: 'STANDARD_GRUPPENPROFIL',
        shipmentNumbers: ['340434310428091700'],
    ),
);

Download a label PDF

$pdfContent = DhlParcel::labels()->download(token: 'label-token-from-response');

Using without the Facade

You can create a DhlParcel instance directly using DhlParcel::make(). This is useful when you prefer not to use the facade, need different credentials per request, or want to support multi-tenant setups:

use SmartDato\DhlParcel\DhlParcel;

// With OAuth2 (recommended)
$dhl = DhlParcel::make([
    'api_key' => 'your-client-id',
    'client_secret' => 'your-client-secret',
    'username' => 'your-business-customer-username',
    'password' => 'your-business-customer-password',
    'sandbox' => true,
]);

// Or with legacy API key
$dhl = DhlParcel::make([
    'api_key' => 'your-api-key',
    'sandbox' => true,
]);

// Or with legacy Basic Auth
$dhl = DhlParcel::make([
    'username' => 'your-username',
    'password' => 'your-password',
]);

$response = $dhl->orders()->create($data);

You can also optionally pass a custom base_url if needed:

$dhl = DhlParcel::make([
    'api_key' => 'your-api-key',
    'base_url' => 'https://api-eu.dhl.com/parcel/de/shipping/v2',
]);

Available products

Enum Product
Product::V01PAK DHL Paket
Product::V53WPAK DHL Paket International
Product::V54EPAK DHL Europaket
Product::V62WP Warenpost
Product::V62KP DHL Kleinpaket
Product::V66WPI Warenpost International

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

Related Packages

smart-dato/dhl-parcel-returns-sdk

Laravel SDK for the DHL Parcel DE Returns API

5,549 0
smart-dato/mondial-relay-shipping-sdk

Laravel SDK for the Mondial Relay Dual Carrier API V2 (shipments & labels)

5,478 0
abishekrsrikaanth/aftership-laravel

Laravel 4 package to integrate with After-Ship API

219 7
smart-dato/post-it-sdk

Poste Italiane (POST_IT) shipping API SDK for Laravel — Saloon-based client with...

5,619 0
smart-dato/gls-italy

Fluent PHP SDK for the GLS Italy carrier web services: label service, pickups, t...

3,906 0

Version History

Version Released PHP Laravel License
v0.0.11 ^8.4 ^11.0||^12.0||^13.0 MIT
v0.0.10 ^8.4 ^11.0||^12.0||^13.0 MIT
v0.0.9 ^8.4 ^11.0||^12.0 MIT
v0.0.8 ^8.4 ^11.0||^12.0 MIT
v0.0.7 ^8.4 ^11.0||^12.0 MIT