Library to connect to PostNL's SOAP service called CIF

v2.0.2 2021-10-15 07:45 UTC


Latest Stable Version Total Downloads Latest Unstable Version License

This is a library to interface with the SOAP services offered by PostNL, called CIF.

New authorization

Since version 2.0 of this library, the new authorization method (using tokens instead of username/password) is used.


Install the latest version with

composer require dividebv/postnl

Implementation Status

This library is not complete. This table lists which services are implemented and which aren't. The list of existing services is taken from PostNL's developer center.

Service Implemented Version
Addresses €
Adrescheck Nationaal N/A
Adrescheck Basis Nationaal N/A
Adrescheck Internationaal N/A
Persoon op Adrescheck Basis N/A
Geo Adrescheck Nationaal N/A
Creditworthiness & Business information €
Bedrijfscheck Nationaal N/A
Fraudepreventie Check Basis N/A
IBANcheck Nationaal N/A
Kredietcheck Consument Basis N/A
Kredietcheck Consument Premium N/A
Kredietcheck Zakelijk N/A
Send & Track
Barcode webservice 1_1
Confirming webservice 1_9
Labelling webservice 2_0
Shippingstatus webservice 1_6
Delivery options
Deliverydate webservice 2_1
Location webservice 2_1
Timeframe webservice 2_0
Bulkmail webservice N/A


use DivideBV\Postnl\Postnl;
use DivideBV\Postnl\ComplexTypes;

// Create client class using credentials received from PostNL.
$client = new Postnl(
    12345678,   // Customer number
    'ABCD',     // Customer code
    'Acme BV',  // Customer name
    'xxxxxxxx', // API key
    123456,     // Collection location
    'CD1234',   // Globalpack
    true        // Whether to use PostNL's sandbox environment.

 * Jan Smit
 * Smit & Zonen
 * Hoofdstraat 1A
 * 1234 AB Heikant
 * The Netherlands
$receiverAddress = ComplexTypes\Address::create()
    ->setCompanyName('Smit & Zonen')

$senderAddress = ComplexTypes\Address::create()
    ->setCompanyName('Jansen & Janssen')

// Request a barcode from PostNL.
$barcode = $client->generateBarcodeByDestination($receiverAddress->getCountryCode());

// Create a shipment.
$shipment = ComplexTypes\Shipment::create()
    ->setAddresses(new ComplexTypes\ArrayOfAddress([
        ->setWeight(5000) // Weight in g
        ->setWidth(215)   // Width in mm
        ->setLength(305)  // Length in mm
        ->setHeight(280)  // Height in mm

// Generate label and confirm shipment.
$result = $client->generateLabel($shipment);

// Save the label PDF locally.
$label = $result->getLabels()[0];
$file = new \SplFileObject("label.pdf", 'w');