Package State Transition Shipment
Trigger chain
A shipment is created when the PKG_STATE_TRANSITION command runs on a package and "create shipment" is enabled in the transition's settings. This setting is disabled by default.
1. The request arrives
The store app, ERP, or Omnitron interface sends a command request for the package.
The request specifies which transition to run (transition ID or slug) and the transition's parameters.
OMS finds the command the transition is bound to:
PKG_STATE_TRANSITION.
2. Pre-checks run
Are the conditions defined on the transition met? (e.g., "click & collect orders only")
If barcode or unit weight validation is configured, the submitted values are validated.
The package is locked so that no other process can modify it at the same time.
Does the package's current state match the transition's source state?
Is there an active transfer linked to the package? (
waiting,in_transit,ready_to_shipment,out_of_stock) If so, the command returns an error.
3. The package moves forward
The package moves to the destination state:
preparingorwaiting_remote_action.If the destination is
preparing, the items in the package also move topreparing.Submitted barcodes and unit weights are saved (if the related setting is enabled and validation passed).
4. The shipment is created ◄ critical step
Runs only if "create shipment" is enabled on the transition.
The shipment and cargo label are created using the order's tracking number.
If the setting is disabled, the package still moves to the destination state, but no shipment is created.
5. Omnitron is updated
If the destination state is
preparingand "send status to Omnitron" is enabled, the order items in Omnitron are updated topreparing.For a
waiting_remote_actiontransition, nothing is sent to Omnitron even if this setting is enabled.
6. Final check
OMS verifies that the package is actually in the destination state.
All of these steps run as a single transaction: if any step fails, no changes are saved.
How the shipment is created
If the package already has a shipment, a new one is not created; only the label is completed if it is missing.
The cargo company is selected:
the cargo company of the first order item in the package,
otherwise, the order's cargo company,
if that is also missing or inactive, the first active cargo company in the system.
The cargo company is called:
If the order already has a tracking number (the shipment was opened outside OMS, e.g., in Omnitron or on the sales channel side), no new shipment is opened with the cargo company. The shipment is created with this number and marked as "registered externally". Since there is no label, only the label is requested from the cargo company.
If there is no tracking number, a shipment is opened with the cargo company. When selecting the cargo company's integration, a different integration/setting may be used if rules are defined by sales channel, click & collect package, or transfer. The returned tracking number and query number are always saved. The label and return barcode are saved only if the cargo company also returned the label link; if it did not, the label is requested separately in the next step.
The shipment is created in the "waiting for pickup by the cargo company" (
waiting_for_pick_up) state. After the operation completes successfully, a "shipment created" notification (webhook) is sent to external systems.If there is still no label, the label is requested from the cargo company. If the cargo company does not return a label, no error is raised; the shipment remains without a label.
Which transitions create a shipment
Command
Typical transition
create_shipment default
PKG_STATE_TRANSITION
waiting / accepted / waiting_remote_action → preparing / waiting_remote_action
false — must be explicitly set to true
COMPLETE_PACKAGING, CHANNEL_BASED_COMPLETE_PACKAGING
→ packed / waiting_cargo_label
true
SHIP_THE_PACKAGE_ADVANCED
packed → shipped / waiting_cargo_label
true
SHIP_THE_PACKAGE_BASIC
packed → shipped
Ignores the config and always creates one; the cargo API is not called, and a shipment without a label is created with an AWB number generated by OMS
RECREATE_SHIPMENT_OF_THE_PACKAGE
packed / shipped / delivery_failed / attempted_delivery (state does not change)
Ignores the config and recreates the shipment
COMPLETE_PACKAGING_WITHOUT_SHIPMENT
→ packed
Does not create a shipment
Only PKG_STATE_TRANSITION and CHANNEL_BASED_COMPLETE_PACKAGING pass order.tracking_number to shipment creation. COMPLETE_PACKAGING does not pass a tracking number, and SHIP_THE_PACKAGE_ADVANCED passes the tracking_number parameter from the request; for these two commands, the cargo API is called even if the order already has a tracking number.
In other words, without configuration, the shipment is created at the packaging (COMPLETE_PACKAGING) step at the latest. If the shipment should be created when preparation starts (preparing), create_shipment: true must be added to the PKG_STATE_TRANSITION transition.
Configuration keys related to PKG_STATE_TRANSITION
Read from StateTransition.configuration (JSON):
create_shipment
false
If true, a shipment and label are created during the transition
sync_remote_order_status
false
If true and the destination state is preparing, Omnitron order items are updated to preparing
barcode_validation
none
Validates the barcodes parameter using look_ups (product fields) and enforce_unique_selected_barcode; if the key is absent, barcodes are not saved
save_unit_weight
false
If true, the unit_weights parameter is validated and saved
How to enable / disable create_shipment
The setting is stored in the configuration field of the state transition (StateTransition) record the command runs on. The command reads this field every time it runs, so updating the relevant transition record is enough to change the setting; it is not defined anywhere else. If the key is missing, PKG_STATE_TRANSITION treats it as false.
It can be changed in two ways:
Omnitron interface: Open the relevant
PKG_STATE_TRANSITIONtransition on the OMS state transitions screen and enter{"create_shipment": true}in the configuration field.API: Follow the steps below.
In the examples, replace <OMS_HOST> with the environment's address (OMS is served under the Omnitron host at the /api/v1/oms/ path) and <TOKEN> with an Omnitron user token.
1. Find the transition
Find the id of the transition the store uses in the results. If the list is long, you can narrow it down by slug: &slug=preparing.
2. Read the current setting
Sample response (abbreviated):
3. Enable create_shipment
Add create_shipment while keeping the existing keys in configuration:
4. To disable it
Send the same request with "create_shipment": false, or remove the key from the JSON:
Last updated
Was this helpful?

