myparcelnl/sdk
| Install | |
|---|---|
composer require myparcelnl/sdk |
|
| Latest Version: | 10.7.15 |
| PHP: | ^7.4 || ^8.0 |
| License: | MIT |
| Last Updated: | Oct 8, 2026 |
| Links: | GitHub · Packagist |
MyParcel PHP SDK
Requirements
- PHP >=7.4
- Composer
composer require myparcelnl/sdk
Quick start
Most v11 services take an API key in the constructor and wrap the generated API client. MyParcel Connect is the exception, see MyParcel Connect.
use MyParcelNL\Sdk\Collection\ShipmentCollection;
use MyParcelNL\Sdk\Model\Shipment\Shipment;
use MyParcelNL\Sdk\Services\Shipment\ShipmentCreateService;
// Build a shipment
$shipment = (new Shipment())
->setRecipient([
'cc' => 'NL',
'street' => 'Antareslaan',
'number' => 31,
'person' => 'John Doe',
'city' => 'Hoofddorp',
'postal_code' => '2132 JE',
])
->setCarrier(1)
->withPackageType('PACKAGE');
// Create it
$service = new ShipmentCreateService('your-api-key');
$mapping = $service->create((new ShipmentCollection())->push($shipment));
// $mapping = [shipmentId => referenceIdentifier, ...]
Services
| Service | Description |
|---|---|
ShipmentCreateService |
Create shipments (concepts or with labels) |
ShipmentQueryService |
Query, find by ID, find by reference |
ShipmentDeleteService |
Delete concept shipments |
ShipmentPrintService |
Print shipments to a printer group |
ShipmentLabelsService |
Get label PDFs, links or direct downloads |
ShipmentTrackTraceService |
Fetch track & trace data |
ReturnShipmentService |
Create related or unrelated return shipments |
MultiColloShipmentService |
Split a shipment into multiple colli |
CapabilitiesService |
Check carrier capabilities for a shipment |
CarrierContractDefinitionsService |
Fetch account-level carrier contract definitions |
WebhookService |
Subscribe, unsubscribe, list webhooks |
ApiKeyService |
Validate API key, get principal info |
ConnectService |
Connect a shop with MyParcel Connect and keep its access token usable |
See UPGRADE.md for detailed before/after examples per service.
MyParcel Connect
ConnectService authorises a shop in the merchant's browser instead of taking an API key. It is for
integrations you publish and other people install, rather than a single shop you run yourself.
EcommerceApiFactory then builds an e-commerce client that signs every call, which is how orders
are pushed.
Connect covers one call for now, POST /webhook/orders. Every other service in this SDK still takes
an API key.
See PHP SDK v11 on the developer portal for how to use it. dev/connect-poc in this repository is
a page that runs the whole flow.
Value mapping
Use ApiMapperService to convert between delivery-options names, v1 IDs and v2 names.
use MyParcelNL\Sdk\Services\Mapping\ApiMapperService;
$mapper = ApiMapperService::forCarrier();
$mapper->idFromLegacyName('dhlforyou'); // 9
$mapper->v2NameFromId(9); // 'DHL_FOR_YOU'
$mapper->legacyNameFromV2Name('DPD'); // 'dpd'
Use forDeliveryType() or forPackageType() for the other categories. Conversion methods return
null if no mapping exists. Use allRows() for one category or allDomains() for all three.
Shipment option names are handled by Services\Mapping\ShipmentOptionMapper. Its
v2PropertyFromName() method returns the generated capabilities v2 model property, or null.
For example, signature and requiresSignature both map to requires_signature.
Unsupported capabilities options
Capabilities requests omit unknown or unsupported option names. Check the request before sending it so your application can report these options or change the request.
use MyParcelNL\Sdk\Model\Capabilities\CapabilitiesRequest;
$request = CapabilitiesRequest::forCountry('NL')
->withOptions(['signature' => null, 'tracked' => null]);
$request->getUnsupportedOptions(); // ['tracked']
This check validates option names accepted by the request model. It does not validate option values or determine which options a carrier offers.
Legacy services
The following are still available but will be replaced in a future release:
- Web services (@internal):
AccountWebService,CarrierOptionsWebService,PrinterGroupWebService - Order v1 fulfilment:
OrderCollection(@internal),OrderNotesCollection(@internal),Order,OrderLine,OrderNote,Product - Carrier models, shared models, helpers (@internal) — see UPGRADE.md for the full list
Use CarrierContractDefinitionsService for new account-level carrier contract definition lookups instead of
CarrierOptionsWebService.
Testing
# Run all tests
./vendor/bin/phpunit
# Run without live API tests
./vendor/bin/phpunit --exclude-group=live
Tests use two mocking strategies:
- Legacy web services: Mockery via
$this->mockCurl()inTestCase - v11 service wrappers: Constructor injection of a mock API instance
Existing tests serve as examples for both patterns.
Support
For questions and support please contact us via support@myparcel.nl or chat with our developers directly on Slack.
Contribute
- Check for open issues or open a new issue to start a discussion
- Fork the repository and branch off from
main - Write tests for the new feature or bug fix
- Ensure all tests pass:
./vendor/bin/phpunit - Submit a pull request
Related Packages
Powerful PHP database abstraction layer (DBAL) with many features for database s...
Laravel Serializable Closure provides an easy and secure way to serialize closur...
Version History
| Version | Released | PHP | License |
|---|---|---|---|
| 10.7.15 | ^7.4 | | MIT | |
| 10.7.14 | ^7.4 | | MIT | |
| 10.7.13 | ^7.4 | | MIT | |
| 10.7.12 | ^7.4 | | MIT | |
| 10.7.11 | ^7.4 | | MIT | |
| 10.7.10 | ^7.4 | | MIT | |
| 10.7.9 | ^7.4 | | MIT | |
| 10.7.8 | ^7.4 | | MIT | |
| 10.7.7 | ^7.4 | | MIT | |
| 10.7.6 | ^7.4 | | MIT | |
| 10.7.5 | ^7.4 | | MIT | |
| 10.7.4 | ^7.4 | | MIT | |
| 10.7.3 | ^7.4 | | MIT | |
| 10.7.2 | ^7.4 | | MIT | |
| 10.7.1 | ^7.4 | | MIT | |
| 10.7.0 | ^7.4 | | MIT | |
| 10.6.0 | ^7.4 | | MIT | |
| 10.5.0 | ^7.4 | | MIT | |
| 10.4.1 | ^7.4 | | MIT | |
| 10.4.0 | ^7.4 | | MIT | |
| 10.3.6 | ^7.4 | | MIT | |
| 10.3.5 | ^7.4 | | MIT | |
| 10.3.4 | ^7.4 | | MIT | |
| 10.3.3 | ^7.4 | | MIT | |
| 10.3.2 | ^7.4 | | MIT | |
| 10.3.1 | ^7.4 | | MIT | |
| 10.3.0 | ^7.4 | | MIT | |
| 10.2.0 | ^7.4 | | MIT | |
| 10.1.0 | ^7.4 | | MIT | |
| 10.0.1 | ^7.4 | | MIT |
Showing the latest 30 of 198. See every release on Packagist
Pre-releases (67)
| Version | Released | PHP | License |
|---|---|---|---|
| 11.0.0-beta.37 | ^7.4 | | MIT | |
| 11.0.0-beta.36 | ^7.4 | | MIT | |
| 11.0.0-beta.35 | ^7.4 | | MIT | |
| 11.0.0-beta.34 | ^7.4 | | MIT | |
| 11.0.0-beta.33 | ^7.4 | | MIT | |
| 11.0.0-beta.32 | ^7.4 | | MIT | |
| 11.0.0-beta.31 | ^7.4 | | MIT | |
| 11.0.0-beta.30 | ^7.4 | | MIT | |
| 11.0.0-beta.29 | ^7.4 | | MIT | |
| 11.0.0-beta.28 | ^7.4 | | MIT | |
| 11.0.0-beta.27 | ^7.4 | | MIT | |
| 11.0.0-beta.26 | ^7.4 | | MIT | |
| 11.0.0-beta.25 | ^7.4 | | MIT | |
| 11.0.0-beta.24 | ^7.4 | | MIT | |
| 11.0.0-beta.23 | ^7.4 | | MIT | |
| 11.0.0-beta.22 | ^7.4 | | MIT | |
| 11.0.0-beta.21 | ^7.4 | | MIT | |
| 11.0.0-beta.20 | ^7.4 | | MIT | |
| 11.0.0-beta.19 | ^7.4 | | MIT | |
| 11.0.0-beta.18 | ^7.4 | | MIT | |
| 11.0.0-beta.17 | ^7.4 | | MIT | |
| 11.0.0-beta.16 | ^7.4 | | MIT | |
| 11.0.0-beta.15 | ^7.4 | | MIT | |
| 11.0.0-beta.14 | ^7.4 | | MIT | |
| 11.0.0-beta.13 | ^7.4 | | MIT | |
| 11.0.0-beta.12 | ^7.4 | | MIT | |
| 11.0.0-beta.11 | ^7.4 | | MIT | |
| 11.0.0-beta.10 | ^7.4 | | MIT | |
| 11.0.0-beta.9 | ^7.4 | | MIT | |
| 11.0.0-beta.8 | ^7.4 | | MIT |
Showing the latest 30 of 67. See every release on Packagist