Shipments

Example PostNL Standaard zending (NL)

Minimal example to create a PostNL Standaard shipment

<?php

require 'vendor/autoload.php';

const CLIENT_ID = '';
const CLIENT_SECRET = '';

$shipToContact = new \Boekuwzending\Resource\Contact();
$shipToContact->setName('Rik Balder');
$shipToContact->setCompany('Boekuwzending.com');
$shipToContact->setEmailAddress('info@boekuwzending.com');

$shipToAddress = new \Boekuwzending\Resource\Address();
$shipToAddress->setStreet('Bennebroekerweg');
$shipToAddress->setNumber('267');
$shipToAddress->setPostcode('1435CJ');
$shipToAddress->setCity('Rijsenhout');
$shipToAddress->setCountryCode('NL');

$dispatchInstruction = new DispatchInstruction();
$dispatchInstruction->setEoriNumber('987162786');
$dispatchInstruction->setVatNumber('659183695');
$dispatchInstruction->setDate(new DateTime());

$item = new \Boekuwzending\Resource\Item();
$item->setType(\Boekuwzending\Resource\Item::TYPE_PACKAGE);
$item->setQuantity(1);
$item->setLength(10);
$item->setWidth(10);
$item->setHeight(10);
$item->setWeight(10);
$item->setDescription('Dog food');

$shipment = new \Boekuwzending\Resource\Shipment();
$shipment->setService('postnl-3085');
$shipment->setShipToContact($shipToContact);
$shipment->setShipToAddress($shipToAddress);
$shipment->setDispatch($dispatchInstruction);
$shipment->addItem($item);

$shipment->setTransportType(\Boekuwzending\Resource\Shipment::TRANSPORT_TYPE_ROAD);

$client = \Boekuwzending\ClientFactory::build(CLIENT_ID, CLIENT_SECRET);
$client->shipment->create($shipment);
By adding true as the second parameter to the create method the generated labels will be included in the response.
ACCESS_TOKEN= # The Access Token from the token request

curl 'https://api.boekuwzending.com/shipments' \
--request POST \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $ACCESS_TOKEN" \
--data-raw '{
    "service": "postnl-3085",
    "shipTo": {
        "contact": {
            "name": "Rik Balder",
            "company": "Boekuwzending.com",
            "emailAddress": "info@boekuwzending.com"
        },
        "address": {
            "street": "Bennebroekerweg",
            "number": "267",
            "postcode": "1435CJ",
            "city": "Rijsenhout",
            "country": "NL",
            "accessibleWithTrailer": false
        }
    },
    "items": [
        {
            "quantity": 1,
            "type": "package",
            "dimensions": {
                "length": 10,
                "width": 10,
                "height": 10
            },
            "weight": 10
        }
    ]
}'
accessibleWithTrailer is currently required, but in the near future this property will become optional.
By adding ?withLabelPdfData to the URL the generated labels will be included in the response.
{
    "service": "postnl-3085",
    "shipTo": {
        "contact": {
            "name": "Rik Balder",
            "company": "Boekuwzending.com",
            "emailAddress": "info@boekuwzending.com"
        },
        "address": {
            "street": "Bennebroekerweg",
            "number": "267",
            "postcode": "1435CJ",
            "city": "Rijsenhout",
            "country": "NL",
            "accessibleWithTrailer": false
        }
    },
    "items": [
        {
            "quantity": 1,
            "type": "package",
            "dimensions": {
                "length": 10,
                "width": 10,
                "height": 10
            },
            "weight": 10
        }
    ]
}
accessibleWithTrailer is currently required, but in the near future this property will become optional.
By adding ?withLabelPdfData to the URL the generated labels will be included in the response.

Example PostNL PickupPoint

Minimal example to create a PostNL Standaard Shipment to a PickupPoint

{
  "service": "postnl-3533",
  "shipTo": {
    "contact": {
      "name": "Rik Balder",
      "company": "Boekuwzending.com",
      "emailAddress": "info@boekuwzending.com"
    },
    "address": {
      "street": "Bennebroekerweg",
      "number": "267",
      "postcode": "1435CJ",
      "city": "Rijsenhout",
      "country": "NL",
      "accessibleWithTrailer": false
    }
  },
  "items": [
    {
      "quantity": 1,
      "type": "package",
      "dimensions": {
        "length": 10,
        "width": 10,
        "height": 10
      },
      "weight": 10
    }
  ],
  "pickupPoint": {
    "identifier": "postnl-162528",
    "distributorCode": "postnl",
    "name": "Spar",
    "country": "NL",
    "postcode": "2481AR",
    "city": "Woubrugge",
    "street": "Batehof",
    "number": "1"
  }
}
accessibleWithTrailer is currently required, but in the near future this property will become optional.
By adding ?withLabelPdfData to the URL the generated labels will be included in the response.

Example DPD Classic (GB)

Minimal example to create a DPD Classic shipment to Great Britain.

Item value and tariffNumber are mandatory for international shipments outside the EU.
For shipments to Great Britain the EORI-number for the sender (dispatch) and receiver (delivery) are required.
{
    "service": "buz-dpd-classic",
    "shipTo": {
        "contact": {
            "name": "Example",
            "emailAddress": "info@boekuwzending.com",
            "phoneNumber": "+44-3447369000",
            "company": "H&M Oxford Circus"
        },
        "address": {
            "number": "261-271",
            "street": "Regent Street",
            "postcode": "W1B 2ES",
            "city": "London",
            "country": "GB",
            "accessibleWithTrailer": false
        }
    },
    "items": [
        {
            "quantity": 1,
            "type": "package",
            "dimensions": {
                "length": 25,
                "height": 20,
                "width": 40
            },
            "weight": 1.5,
            "description": "Pakket",
            "value": 250,
            "tariffNumber": "00640411"
        }
    ],
    "dispatch": {
        "eoriNumber": "ABC123123123"
    },
    "delivery": {
        "eoriNumber": "ABC123123123"
    }
}
accessibleWithTrailer is currently required, but in the near future this property will become optional.
By adding ?withLabelPdfData to the URL the generated labels will be included in the response.

For an overview of available services see Available services