InPost ShipX API step by step: shipment, label and statuses

You create a locker or courier shipment, wait for the offer to be paid, download the label and receive status changes by webhook. TypeScript code on Node.js, checked against the InPost documentation and sandbox.

What you will do

InPost is a Polish parcel locker network. An order in your store turns into an InPost shipment by itself, to a parcel locker or by courier. The warehouse gets a label ready to print, and the customer sees the parcel status without visiting the carrier's site.

ShipX is asynchronous: after a shipment is created, InPost prepares offers, selects and pays the offer for the chosen service, and only then does the shipment reach confirmed and get a tracking number. Most integration bugs come from fetching the label before that happens.

Level
intermediate
Code
TypeScript
Steps
8 steps
  1. Order Shipment A POST with the receiver, size and service.
  2. ShipX Offer and payment Asynchronous: created to confirmed.
  3. Warehouse Label PDF, ZPL or EPL from confirmed onwards.
  4. Customer Statuses A webhook on every change.

What you need

  • An account on the Parcel Manager sandbox

    On sandbox-manager.paczkomaty.pl you create a separate account: production credentials do not work there. You generate the token and organisation ID under My account > API, after filling in all details, including invoice data.

  • Funds on the test account

    A parcel locker shipment needs funds on the account. On the sandbox you top up virtually under Payments.

  • Node.js 18 or newer

    The code uses the built-in fetch. We ran it on Node.js 22 with tsx. For the webhook any HTTP server will do; the example uses Express.

  • The recipient's locker code

    For a locker shipment the customer picks a point, for example in the InPost map widget, and you pass its name in target_point.

Locker sizes (inpost_locker_standard)

TemplateDimensionsWeight and size
small8 x 38 x 64 cmup to 25 kg, size A
medium19 x 38 x 64 cmup to 25 kg, size B
large41 x 38 x 64 cmup to 25 kg, size C
xlarge50 x 50 x 80 cmup to 25 kg, size D, inpost_courier_c2c only

Step by step

Each step with commands to copy. The list on the left shows where you are.

01

Write the API client

Every request carries the token in an Authorization: Bearer header. The sandbox is sandbox-api-shipx-pl.easypack24.net, production api-shipx-pl.easypack24.net. The X-User-Agent header is optional and helps InPost diagnose when you report a problem.

shipx.ts
const API = process.env.SHIPX_URL ?? 'https://sandbox-api-shipx-pl.easypack24.net';const TOKEN = process.env.SHIPX_TOKEN ?? '';const ORG = process.env.SHIPX_ORG ?? '';export async function shipx<T>(method: string, path: string, body?: unknown): Promise<T> { const response = await fetch(`${API}${path}`, { method, headers: { Authorization: `Bearer ${TOKEN}`, 'Content-Type': 'application/json', 'X-User-Agent': 'shop-example', }, body: body === undefined ? undefined : JSON.stringify(body), }); if (!response.ok) { throw new Error(`ShipX ${method} ${path}: ${response.status} ${await response.text()}`); } return response.json() as Promise<T>;}
02

Check the organisation and its services

GET /v1/organizations/:id returns the name and the services available to your organisation. You can create shipments only in an organisation you belong to, and only for a service on that list.

shipx.ts
interface Organization { id: number; name: string; services: string[] }const org = await shipx<Organization>('GET', `/v1/organizations/${ORG}`);console.log(org.name, org.services);// ["inpost_locker_standard", "inpost_courier_standard", ...]
03

Create a locker shipment

In simplified mode you send the service right away. A locker shipment needs the receiver's phone and email, a size template and the target locker in custom_attributes.target_point. sending_method says how you hand the parcel over: parcel_locker is a drop at a locker, dispatch_order is a courier pickup.

You do not have to give the sender: it defaults to the organisation. The response has status created and an empty tracking_number.

shipx.ts
interface Shipment { id: number; status: string; tracking_number: string | null }export const lockerShipment = (order: { email: string; phone: string; point: string; ref: string }) => shipx<Shipment>('POST', `/v1/organizations/${ORG}/shipments`, { receiver: { email: order.email, phone: order.phone }, parcels: { template: 'small' }, custom_attributes: { target_point: order.point, sending_method: 'parcel_locker' }, service: 'inpost_locker_standard', reference: order.ref, });const created = await lockerShipment({ email: 'customer@example.com', phone: '888000000', point: 'KRA010', ref: 'order-1042',});// { id: 12345, status: "created", tracking_number: null, ... }
04

Or a courier shipment

A courier needs the receiver's address and a first and last name or a company name. Instead of a template you give the parcel dimensions and weight. With cash on delivery (cod), courier services also require insurance.

shipx.ts
export const courierShipment = (order: CourierOrder) => shipx<Shipment>('POST', `/v1/organizations/${ORG}/shipments`, { receiver: { first_name: order.firstName, last_name: order.lastName, email: order.email, phone: order.phone, address: { street: order.street, building_number: order.building, city: order.city, post_code: order.postCode, country_code: 'PL', }, }, parcels: [{ dimensions: { length: '300', width: '200', height: '100', unit: 'mm' }, weight: { amount: '2', unit: 'kg' }, }], service: 'inpost_courier_standard', reference: order.ref, });
05

Wait until the shipment is paid

After creation InPost prepares offers, selects one and pays it in the background. A label can be fetched only for a shipment in confirmed or a later status. In code you poll the shipment; in production you are better off waiting for the shipment_confirmed webhook.

shipx.ts
export async function waitForConfirmed(id: number): Promise<Shipment> { for (let attempt = 0; attempt < 30; attempt++) { const shipment = await shipx<Shipment>('GET', `/v1/shipments/${id}`); if (shipment.status === 'confirmed' || shipment.tracking_number) return shipment; await new Promise(resolve => setTimeout(resolve, 2000)); } throw new Error(`Shipment ${id} was not paid`);}
06

Download the label

GET /v1/shipments/:id/label returns a file: PDF, ZPL or EPL. Type normal or A6; for courier services you get A6 when no type is given. Several labels at once come from /v1/organizations/:id/shipments/labels, up to 100 shipments.

shipx.ts
import { writeFile } from 'node:fs/promises';export async function label(id: number): Promise<Buffer> { const response = await fetch(`${API}/v1/shipments/${id}/label?format=pdf&type=A6`, { headers: { Authorization: `Bearer ${TOKEN}` }, }); if (!response.ok) throw new Error(`Label ${id}: ${response.status} ${await response.text()}`); return Buffer.from(await response.arrayBuffer());}const confirmed = await waitForConfirmed(created.id);await writeFile(`label-${confirmed.tracking_number}.pdf`, await label(confirmed.id));
07

Receive status changes by webhook

You add the webhook address in the Parcel Manager under My account > API. It must answer 200 to GET. InPost sends shipment_confirmed, shipment_status_changed and offers_prepared events from 91.216.25.0/24, for both production and sandbox.

The webhook carries no signature. Restrict it to that address range and do not trust the body: after an event fetch the shipment from the API and store its status from there.

webhook.ts
import express from 'express';const app = express();// InPost requires the address to answer 200 to GET.app.get('/inpost/webhook', (_req, res) => res.sendStatus(200));app.post('/inpost/webhook', express.json(), async (req, res) => { res.sendStatus(200); // reply at once, process afterwards const { event, payload } = req.body as { event: string; payload: { shipment_id: number } }; if (event !== 'shipment_status_changed' && event !== 'shipment_confirmed') return; // The webhook is unsigned: treat it as a signal and fetch the shipment from the API. const shipment = await shipx<Shipment>('GET', `/v1/shipments/${payload.shipment_id}`); await saveShipmentStatus(shipment.id, shipment.status, shipment.tracking_number);});
08

Show the customer a human status

GET /v1/statuses needs no token and returns every status with its name, a short title and a description, in Polish or English (lang=pl_PL or en_GB). Instead of translating names yourself, show the customer the title from this list.

statuses.ts
const response = await fetch(`${API}/v1/statuses?lang=pl_PL`); // no token neededconst { items } = await response.json() as { items: { name: string; title: string; description: string }[] };const titles = new Map(items.map(status => [status.name, status.title]));titles.get('ready_to_pickup'); // the title of that status in the language you asked for

How to check it works

We ran the client on the sandbox. The status list came back without a token with 53 entries, and creating a shipment without a token returned 401 with code token_invalid. That confirms the API address and the authorisation error handling. With a token from the Parcel Manager you get a shipment in status created at this point.

Environment
ShipX sandbox, Node.js and tsx
Result
The API address and authorisation error handling confirmed without a token

What you should see

  • GET /v1/organizations/:id returns your organisation and its services.
  • A new shipment has status created, and shortly after confirmed with a tracking_number.
  • The label downloads as a PDF only after confirmed.
  • The webhook answers 200 to GET and receives shipment_status_changed.
npx tsx shipx.ts, sandbox
Command
npx tsx shipx.ts
Output
statuses 53 created: Przesyłka utworzona. offers_prepared: Przygotowano oferty. offer_selected: Oferta wybrana.ShipX POST /v1/organizations/1/shipments: 401 {"error":"token_invalid","message":"Token is missing or invalid."}
  1. 2
    The status list

    The status dictionary comes without a token and has 53 entries.

  2. 3-5
    The first shipment statuses

    created, offers_prepared and offer_selected: InPost prepares and picks an offer before the shipment reaches confirmed. The titles are in Polish because the example asks for lang=pl_PL: "Shipment created", "Offers prepared", "Offer selected".

  3. 6-7
    A shipment without a token

    Without a token ShipX returns 401 with token_invalid. With a token from the Parcel Manager you get a shipment in status created here.

A webhook is a signal, not proof

How it looks in our project

In Flaem we accept webhooks from the Tebex and CraftingStore stores. Both sign the body with HMAC-SHA256, so we first compute the expected signature and compare it in constant time before anything reaches the queue.

InPost does not sign its webhooks, so this function cannot be used there. The same principle works another way: restrict the endpoint to the 91.216.25.0/24 range and take the shipment's state from the API, not from the event body.

See the project
The InPost integration log with webhooks and the allowed sender address pool
the InPost integration log in a store panel: a webhook is accepted only from the 91.216.25.0/24 pool, other addresses get 403
webhooks.rs
pub fn verify( provider: &str, secret: &str, body: &[u8], presented: &str,) -> Result<(), WebhookError> { let expected = expected_signature(provider, secret, body); let presented = presented.trim().to_ascii_lowercase(); if expected.len() == presented.len() && expected .bytes() .zip(presented.bytes()) .fold(0u8, |acc, (a, b)| acc | (a ^ b)) == 0 { Ok(()) } else { Err(WebhookError::BadSignature) }}

Common errors

Symptom, cause and fix, with the number of the step where the error shows up.

StepSymptomCauseFix
01 401 token_invalid No token, or a production token on the sandbox, or the other way round. The sandbox has a separate account and a separate token from sandbox-manager.paczkomaty.pl.
06 invalid_action when downloading the label The shipment is not paid yet; its status is earlier than confirmed. Wait for confirmed or for the shipment_confirmed webhook.
03 A locker shipment fails on the sandbox No funds on the test account. Top up the account virtually under Payments.
04 Validation error on a courier shipment with COD No insurance, which courier services require with COD. Add insurance with an amount and currency.
07 InPost will not save the webhook address The address does not answer 200 to GET or cannot be reached. Add a GET handler that returns 200 and check the address works from the internet.

Frequently asked questions

The questions that come up with this setup.

Is the InPost webhook signed?
No. The documentation gives the address range it comes from: 91.216.25.0/24. Restrict your endpoint to it and verify state through the API.
When do I get the tracking number?
Once the shipment is paid, at status confirmed. At creation the tracking_number field is empty.
Which label format should I choose?
PDF for an ordinary printer, ZPL or EPL for label printers. With EPL, courier shipments get EPL and locker and Allegro shipments get EPL2.
How many statuses can a shipment have?
On the sandbox the /v1/statuses list had 53 statuses. Fetch it from the API instead of hard-coding it, because InPost extends it.

Sources

The documentation and specifications we compared the commands with.

Other guides

  • Przelewy24 REST APIRegistering a transaction, the SHA-384 sign, the notification and verifying the payment in PHP.
  • KSeF API 2.0 step by stepThe KSeF token, an online session, encryption and the invoice's KSeF number, with Python code.

Tools

  • JSON formatter and validatorJSON is a text data format with strict syntax. Paste yours to format or minify it, or to find the exact line and column of an error. Free, in your browser.
  • Unix timestamp converterConvert a Unix timestamp to a date in any time zone and a date back to a timestamp, with ISO 8601, HTTP and SQL output. Seconds or milliseconds. Free.

Glossary terms

Tell us what you want to build.

A free quote comes back within an hour during working hours. You talk to the person who writes the code.