myparcelnl/sdk
Larablocks Analysis
myparcelnl/sdk works with any PHP project: the latest release (11.4.0, Dec 1, 2026) doesn't depend on Laravel.
Recommendation checks
Solid choiceSolid choice: maintained and up to date, meets 2 of 3 checks; below the bar for Recommended on use.
- Released in the last 12 months (Dec 1, 2026)
- 31,028 downloads a month (at least 10,000)
- 31 GitHub stars (needs 100)
State
Actively maintained- Last stable release: Dec 1, 2026.
- 76 releases in the last 12 months.
- First released: Aug 22, 2016.
- Monthly downloads: 31,028, up 136% from six months ago.
- 16 open issues on GitHub.
Data from Packagist and GitHub, checked by Larablocks on Dec 2, 2026.
| Install | |
|---|---|
composer require myparcelnl/sdk |
|
| Latest Version: | 11.4.0 |
| PHP: | ^7.4 || ^8.0 |
| License: | MIT |
| Last Updated: | Dec 1, 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.
Pushing orders
Every order needs a status: Order::STATUS_OPEN or Order::STATUS_CANCELED. The e-commerce service
refuses the whole request with HTTP 400 when one order has no status.
use MyParcelNL\Sdk\Client\Generated\EcommerceApi\Model\Order;
use MyParcelNL\Sdk\Services\Ecommerce\EcommerceApiFactory;
$order = new Order([
'ordered_at' => new DateTime('now'),
'source_id' => 'ORDER-2026-01042',
'status' => Order::STATUS_OPEN,
]);
$api = EcommerceApiFactory::make($connect);
$results = $api->webhookOrdersPost([$order]);
To update an order, push it again with the same source_id. For example, when the merchant cancels
the order in the shop:
$order->setStatus(Order::STATUS_CANCELED);
$results = $api->webhookOrdersPost([$order]);
MyParcel accepts the update, but does not act on it yet.
When the connection expires
Show the merchant a notice from about one month before the connection expires, so they reconnect in time. When the refresh token expires, the next refresh fails and the shop has to connect again.
A refresh token lasts about a year. MyParcel sends its lifetime as refreshExpiresIn in the answers
of /connect/token and /connect/refresh, and the SDK stores the expiry with the installation.
ConnectService::getRefreshTokenExpiresAt() returns it as a UTC DateTimeImmutable, read from
storage without a request. It returns null when the shop is not connected, or connected with an
SDK version that did not store the expiry yet. The first refresh after an update stores it.
$expiresAt = $connect->getRefreshTokenExpiresAt();
if (null !== $expiresAt && $expiresAt < new DateTimeImmutable('+1 month')) {
// Show the reconnect notice.
}
ConnectService::getAccessTokenExpiresAt() does the same for the access token, which lasts about an
hour. The SDK refreshes the access token itself, so you only need this date for display.
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.
v1NameFromV2Property() maps the other way, to the v1 option name of the shipments endpoint:
requires_signature gives signature. It returns null when the shipments endpoint has no such option.
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.
Capabilities that the shipments endpoint does not have
The capabilities API can return a value that this SDK version cannot send to the shipments endpoint,
such as a new carrier. A shipment with that value fails when the request goes out.
SupportedCapabilitiesFilter::filter() removes these carriers, delivery types, package types and
options from a capabilities or contract definitions response, and returns copies. The services do not
call it, so their responses stay complete.
use MyParcelNL\Sdk\Services\Capabilities\SupportedCapabilitiesFilter;
$definitions = SupportedCapabilitiesFilter::filter($service->getContractDefinitions());
To check one value, use isCarrierSupported(), isDeliveryTypeSupported(),
isPackageTypeSupported() or isOptionSupported().
Storing a response
jsonSerialize() throws on an enum value that this SDK version does not know, such as a new carrier
in a capabilities response. To store a response, for example in a cache, use
CoreApiModels::toArray(). It keeps such a value as it is and gives the fields with their API names.
use MyParcelNL\Sdk\Client\CoreApiModels;
$cached = array_map([CoreApiModels::class, 'toArray'], $service->getContractDefinitions());
A request with an unknown enum value still throws.
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 |
|---|---|---|---|
| 11.4.0 | ^7.4 || | MIT | |
| 11.3.3 | ^7.4 || | MIT | |
| 11.3.2 | ^7.4 || | MIT | |
| 11.3.1 | ^7.4 || | MIT | |
| 11.3.0 | ^7.4 || | MIT | |
| 11.2.1 | ^7.4 || | MIT | |
| 11.2.0 | ^7.4 || | MIT | |
| 11.1.0 | ^7.4 || | MIT | |
| 11.0.2 | ^7.4 || | MIT | |
| 11.0.1 | ^7.4 || | MIT | |
| 11.0.0 | ^7.4 || | MIT | |
| 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 |
Showing the latest 30 of 209. See every release on Packagist
Pre-releases (77)
| Version | Released | PHP | License |
|---|---|---|---|
| 12.0.0-beta.10 | ^8.3 | MIT | |
| 12.0.0-beta.9 | ^8.3 | MIT | |
| 12.0.0-beta.8 | ^8.3 | MIT | |
| 12.0.0-beta.7 | ^8.3 | MIT | |
| 12.0.0-beta.6 | ^8.3 | MIT | |
| 12.0.0-beta.5 | ^8.3 | MIT | |
| 12.0.0-beta.4 | ^8.3 | MIT | |
| 12.0.0-beta.3 | ^8.3 | MIT | |
| 12.0.0-beta.2 | ^8.3 | MIT | |
| 12.0.0-beta.1 | ^8.3 | MIT | |
| 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 |
Showing the latest 30 of 77. See every release on Packagist