PHPackages                             smart-dato/inpost-sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. smart-dato/inpost-sdk

ActiveLibrary[API Development](/categories/api)

smart-dato/inpost-sdk
=====================

A Laravel SDK for the InPost API — Shipping, Points, Tracking, Returns, and Pickups

v0.0.4(1mo ago)0142↓50%[1 PRs](https://github.com/smart-dato/inpost-sdk/pulls)MITPHPPHP ^8.4CI passing

Since Mar 5Pushed 1mo agoCompare

[ Source](https://github.com/smart-dato/inpost-sdk)[ Packagist](https://packagist.org/packages/smart-dato/inpost-sdk)[ Docs](https://github.com/smart-dato/inpost-sdk)[ GitHub Sponsors](https://github.com/smart-dato)[ RSS](/packages/smart-dato-inpost-sdk/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (30)Versions (8)Used By (0)

InPost SDK for Laravel
======================

[](#inpost-sdk-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/262b5d5ebd1da576d7acba9f61dde8450c912ccf0668661925e6faf6b4d68b44/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f736d6172742d6461746f2f696e706f73742d73646b2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/smart-dato/inpost-sdk)[![GitHub Tests Action Status](https://camo.githubusercontent.com/c4f1cdacf024cb7524568c7ea950f809ed9f5ec4144ed63f4c3df2b1abd921b3/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f736d6172742d6461746f2f696e706f73742d73646b2f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/smart-dato/inpost-sdk/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/1a7ac13dc8f5adb35ed23a767375d9d575d1957b922e4e46a4e36e61cff4e4e4/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f736d6172742d6461746f2f696e706f73742d73646b2f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/smart-dato/inpost-sdk/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/4f834f84362f362bb2693dc3dddf6886ae9210e0b4d95818779a7abe6805b6f7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f736d6172742d6461746f2f696e706f73742d73646b2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/smart-dato/inpost-sdk)

A Laravel SDK for the InPost API, covering Shipping, Points, Tracking, Returns, and One-Time Pickups. Built with [Saloon v3](https://docs.saloon.dev) and [Spatie Laravel Data](https://spatie.be/docs/laravel-data).

Requirements
------------

[](#requirements)

- PHP 8.4+
- Laravel 11 or 12

Installation
------------

[](#installation)

```
composer require smart-dato/inpost-sdk
```

Publish the config file:

```
php artisan vendor:publish --tag="inpost-sdk-config"
```

Configuration
-------------

[](#configuration)

Add the following to your `.env` file:

```
INPOST_CLIENT_ID=your-client-id
INPOST_CLIENT_SECRET=your-client-secret
INPOST_ORGANIZATION_ID=your-organization-id
```

For staging environments, override the token and base URLs:

```
INPOST_TOKEN_URL=https://stage-api.inpost-group.com/oauth2/token
INPOST_SHIPPING_URL=https://stage-api.inpost-group.com/shipping/v2
INPOST_POINTS_URL=https://stage-api.inpost-group.com/location/v1
INPOST_TRACKING_URL=https://stage-api.inpost-group.com/tracking/v1
INPOST_RETURNS_URL=https://stage-api.inpost-group.com/returns/v1
INPOST_PICKUPS_URL=https://stage-api.inpost.pl/pickups/v1
INPOST_PICKUPS_TOKEN_URL=https://stage-account.inpost-group.com/oauth2/token
```

Published config (`config/inpost-sdk.php`):

```
return [
    'client_id' => env('INPOST_CLIENT_ID', ''),
    'client_secret' => env('INPOST_CLIENT_SECRET', ''),
    'organization_id' => env('INPOST_ORGANIZATION_ID', ''),
    'token_url' => env('INPOST_TOKEN_URL', 'https://api.inpost-group.com/oauth2/token'),
    'pickups_token_url' => env('INPOST_PICKUPS_TOKEN_URL', 'https://account.inpost-group.com/oauth2/token'),
    'base_urls' => [
        'shipping' => env('INPOST_SHIPPING_URL', 'https://api.inpost-group.com/shipping/v2'),
        'points'   => env('INPOST_POINTS_URL', 'https://api.inpost-group.com/location/v1'),
        'tracking' => env('INPOST_TRACKING_URL', 'https://api.inpost-group.com/tracking/v1'),
        'returns'  => env('INPOST_RETURNS_URL', 'https://api.inpost-group.com/returns/v1'),
        'pickups'  => env('INPOST_PICKUPS_URL', 'https://api.inpost.pl/pickups/v1'),
    ],
];
```

Usage
-----

[](#usage)

Access the SDK via the `InPost` facade or by injecting `Smartdato\InPost\InPost`.

### Shipping

[](#shipping)

```
use Smartdato\InPost\Facades\InPost;
use Smartdato\InPost\Data\Shipping\CreateShipmentData;
use Smartdato\InPost\Data\Shipping\SenderData;
use Smartdato\InPost\Data\Shipping\RecipientData;
use Smartdato\InPost\Data\Shipping\OriginData;
use Smartdato\InPost\Data\Shipping\DestinationData;
use Smartdato\InPost\Data\Shipping\ParcelData;
use Smartdato\InPost\Data\Shared\DimensionsData;
use Smartdato\InPost\Data\Shared\WeightData;
use Smartdato\InPost\Enums\LabelFormat;

// Create a shipment
$shipment = InPost::shipping()->create(new CreateShipmentData(
    sender: new SenderData(name: 'Jan Kowalski', email: 'jan@example.com', phone: '+48123456789'),
    recipient: new RecipientData(name: 'Anna Nowak', email: 'anna@example.com', phone: '+48987654321'),
    origin: new OriginData(pointId: 'KRA01A'),
    destination: new DestinationData(pointId: 'WAW02B'),
    parcels: [
        new ParcelData(
            type: 'standardParcel',
            dimensions: new DimensionsData(length: 200, width: 150, height: 100),
            weight: new WeightData(amount: 2.5),
        ),
    ],
));

echo $shipment->trackingNumber; // "6340012345678901234"

// Get a shipment
$shipment = InPost::shipping()->get('6340012345678901234');

// Get a shipment label (PDF or ZPL)
$label = InPost::shipping()->label('6340012345678901234', LabelFormat::PDF);
echo $label->contentType; // "application/pdf"
// $label->content contains the base64-encoded label
```

### Points

[](#points)

```
use Smartdato\InPost\Facades\InPost;

// List points with optional filters
$points = InPost::points()->list(['type' => 'APM', 'city' => 'Krakow']);

foreach ($points->items as $point) {
    echo "{$point->id} — {$point->name}\n";
}

// Get a specific point
$point = InPost::points()->get('KRA01A');
echo $point->coordinates->latitude;

// Search by location
$nearby = InPost::points()->searchByLocation(
    latitude: 50.0647,
    longitude: 19.945,
    distance: 5000, // meters
);
```

### Tracking

[](#tracking)

```
use Smartdato\InPost\Facades\InPost;

// Track up to 10 parcels at once
$result = InPost::tracking()->track(['6340012345678901234', '6340098765432101234']);

foreach ($result->parcels as $parcel) {
    echo "{$parcel->trackingNumber}: {$parcel->status}\n";

    foreach ($parcel->events as $event) {
        echo "  [{$event->datetime}] {$event->description}\n";
    }
}
```

### Returns

[](#returns)

```
use Smartdato\InPost\Facades\InPost;
use Smartdato\InPost\Data\Returns\CreateReturnShipmentData;

// Create a return shipment
$return = InPost::returns()->create(new CreateReturnShipmentData(
    senderName: 'Anna Nowak',
    senderEmail: 'anna@example.com',
    senderPhone: '+48987654321',
    originPointId: 'WAW02B',
    destinationPointId: 'KRA01A',
    reference: 'RET-2026-001',
));

echo $return->trackingNumber;

// Get a return shipment
$return = InPost::returns()->get('ret_456');

// Get a return label
$label = InPost::returns()->label('ret_456');
```

### Pickups

[](#pickups)

```
use Smartdato\InPost\Facades\InPost;
use Smartdato\InPost\Data\Pickups\CreateOneTimePickupData;
use Smartdato\InPost\Data\Pickups\ContactPersonData;
use Smartdato\InPost\Data\Pickups\PickupTimeData;
use Smartdato\InPost\Data\Shared\AddressData;

// Create a one-time pickup
$pickup = InPost::pickups()->create(new CreateOneTimePickupData(
    address: new AddressData(
        street: 'ul. Testowa',
        buildingNumber: '5',
        city: 'Warszawa',
        postalCode: '00-001',
        countryCode: 'PL',
    ),
    contactPerson: new ContactPersonData(
        name: 'Jan Kowalski',
        email: 'jan@example.com',
        phone: '+48123456789',
    ),
    pickupTime: new PickupTimeData(
        date: '2026-03-06',
        timeFrom: '10:00',
        timeTo: '14:00',
    ),
    parcelCount: 3,
));

echo $pickup->id;

// List pickups
$pickups = InPost::pickups()->list();

// Get a pickup
$pickup = InPost::pickups()->get('pickup_789');

// Cancel a pickup
InPost::pickups()->cancel('pickup_789');

// Check cutoff time for a postal code
$cutoff = InPost::pickups()->cutoffTime('00-001');
echo "Order by {$cutoff->cutoffTime} for pickup on {$cutoff->pickupDate}";
```

Error Handling
--------------

[](#error-handling)

The SDK throws typed exceptions for API errors:

```
use Smartdato\InPost\Exceptions\InPostApiException;
use Smartdato\InPost\Exceptions\InPostValidationException;
use Smartdato\InPost\Exceptions\InPostNotFoundException;

try {
    $shipment = InPost::shipping()->get('invalid-tracking-number');
} catch (InPostNotFoundException $e) {
    // 404 — resource not found
    echo $e->getMessage();
} catch (InPostValidationException $e) {
    // 400 — validation errors
    echo $e->detail;
    foreach ($e->errors as $field => $messages) {
        echo "$field: " . implode(', ', $messages) . "\n";
    }
} catch (InPostApiException $e) {
    // Other API errors (RFC 7807 problem details)
    echo $e->title;
    echo $e->detail;
    echo $e->response->status();
}
```

Authentication
--------------

[](#authentication)

The SDK uses OAuth2 Client Credentials flow. Tokens are automatically cached in Laravel's cache store and refreshed when expired. No manual token management is needed.

### Using Different Credentials

[](#using-different-credentials)

You can create an SDK instance with custom credentials on the fly using `InPost::make()`, bypassing the service container entirely. This is useful for multi-tenant applications or when you need to connect to different InPost accounts:

```
use Smartdato\InPost\InPost;

$client = InPost::make([
    'client_id' => 'other-client-id',
    'client_secret' => 'other-client-secret',
    'organization_id' => 'other-org-id',
]);

// Use it like normal
$shipment = $client->shipping()->create($data);
$points = $client->points()->list();
```

You can also override URLs (e.g. for staging):

```
$client = InPost::make([
    'client_id' => 'staging-client-id',
    'client_secret' => 'staging-client-secret',
    'organization_id' => 'staging-org-id',
    'token_url' => 'https://stage-api.inpost-group.com/oauth2/token',
    'shipping_url' => 'https://stage-api.inpost-group.com/shipping/v2',
    'points_url' => 'https://stage-api.inpost-group.com/location/v1',
    'tracking_url' => 'https://stage-api.inpost-group.com/tracking/v1',
    'returns_url' => 'https://stage-api.inpost-group.com/returns/v1',
    'pickups_url' => 'https://stage-api.inpost.pl/pickups/v1',
    'pickups_token_url' => 'https://stage-account.inpost-group.com/oauth2/token',
]);
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [SmartDato](https://github.com/smart-dato)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance91

Actively maintained with recent releases

Popularity15

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 76.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~9 days

Total

4

Last Release

42d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c3006db55caec62526937fa2d941da32fc5e69e2ca86a52e87c8046da5958d82?d=identicon)[smart-dato](/maintainers/smart-dato)

---

Top Contributors

[![tschigo](https://avatars.githubusercontent.com/u/344100?v=4)](https://github.com/tschigo "tschigo (10 commits)")[![michael-tscholl](https://avatars.githubusercontent.com/u/178569346?v=4)](https://github.com/michael-tscholl "michael-tscholl (2 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")

---

Tags

laravelsmart-datoinpost-sdk

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/smart-dato-inpost-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/smart-dato-inpost-sdk/health.svg)](https://phpackages.com/packages/smart-dato-inpost-sdk)
```

###  Alternatives

[scalar/laravel

Render your OpenAPI-based API reference

6183.9k2](/packages/scalar-laravel)[njoguamos/laravel-plausible

A laravel package for interacting with plausible analytics api.

208.8k](/packages/njoguamos-laravel-plausible)[ryangjchandler/bearer

Minimalistic token-based authentication for Laravel API endpoints.

8129.8k](/packages/ryangjchandler-bearer)[codebar-ag/laravel-docuware

DocuWare integration with Laravel

1221.1k](/packages/codebar-ag-laravel-docuware)[combindma/laravel-facebook-pixel

Meta pixel integration for Laravel

4956.9k](/packages/combindma-laravel-facebook-pixel)[stechstudio/laravel-hubspot

A Laravel SDK for the HubSpot CRM Api

2971.0k](/packages/stechstudio-laravel-hubspot)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
