Shipment creation in offer mode
The shipment object is used to obtain available offers, and at the same time it represents the physical pack (or parcels) which will be sent between the stated addresses.
Shipment creation in offer mode
In order to create a shipment within an organization the user has to be its member.
Attention! Debit customers
After creating a shipment we do not return prices for debit clients. The rate
attribute is null
Attention! Asynchronous operation
After creation of the shipment, the asynchronous process of preparing offers, manifesting and buying the offer will be triggered.
POST /v1/organizations/:organization_id/shipments
Parameters
All the following attributes should be included in the shipment
object.
Parametr | Typ | Opis | Walidacja |
---|---|---|---|
| Receiver details | The attribute is required.
| |
| Sender details. | The attribute is optional.
| |
| Array[ParcelsSimpleForm] | Details of parcels in the shipment. |
|
| Additional shipment attributes, e.g.
| The attribute is optional.
| |
| Cash collection amount. | The attribute is optional.
| |
| Shipment insurance amount. | The attribute is required for the following services:
| |
| String | Additional shipment description, e.g. order number. | The attribute is optional.
|
| Bool | Determines whether the shipment is a return shipment. | The attribute is optional.
|
| Array[String] | Additional services. Available additional services: | The attribute is optional.
|
| String | ID of the broker generating shipments within a different organization. | The attribute is optional. |
| Boolean | Setting the parameter to | The attribute is optional.
|
| String | Name of cost center. | The attribute is optional.
The cost center must first be added to the organization in order to assign it to the shipment. |
| String | Any comment | The attribute is optional.
|
Example request with one parcel:
curl -X POST https://api-shipx-pl.easypack24.net/v1/organizations/1/shipments -H 'Authorization: Bearer token' -H 'Content-Type: application/json' -d '{
"mpk":"miejsce_powstania_kosztow",
"comments": "dowolny komentarz",
"external_customer_id": "8877xxx",
"receiver": {
"first_name": "Jan",
"last_name": "Kowalski",
"name": "Nazwa",
"email": "receiver@example.com",
"phone": "888000000",
"address": {
"id": "123",
"street": "Malborska",
"building_number": "130",
"city": "Kraków",
"post_code": "30-624",
"country_code": "PL"
}
},
"parcels": [
{
"id": "small package",
"template": "small",
"dimensions": {
"length": "80",
"width": "360",
"height": "640",
"unit": "mm"
},
"weight": {
"amount": "25",
"unit": "kg"
},
"tracking_number": null,
"is_non_standard": false
}
],
"custom_attributes": {
"target_point": "KRA010"
},
"insurance": {
"amount": 25,
"currency": "PLN"
},
"cod": {
"amount": 12.50,
"currency": "PLN"
},
"additional_services": ["email", "sms"]
}'
Response
HTTP/1.1 201 CREATED
Content-Type: application/json
{
"href": "https://api-shipx-pl.easypack24.net/v1/organizations/1/shipments/1234567890",
"id": "1234567890",
"status": "created",
"parcels": [
{
"id": "small package",
"template": "small",
"dimensions": {
"length": "80",
"width": "360",
"height": "640",
"unit": "mm"
},
"weight": {
"amount": "25",
"unit": "kg"
},
"tracking_number": null,
"is_non_standard": false
}
],
"external_customer_id": "8877xxx",
"mpk": {
"id": 1,
"name": "miejsce_powstania_kosztow"
},
"comments": "dowolny komentarz",
"custom_attributes": {
"target_point": "KRA010",
"open_code": null,
"dropoff_point": null,
"sending_method": "parcel_locker"
},
"sender": {
"id": "123",
"name": "Nazwa",
"company_name": "InPost S.A.",
"first_name": "Jan",
"last_name": "Nowak",
"email": "sender@email.com",
"phone": "888000000",
"address": {
"id": "123",
"street": "Malborska",
"building_number": "130,
"city": "Kraków",
"post_code": "30-624",
"country_code": "PL"
}
},
"receiver": {
"id": "1234",
"name": "Nazwa",
"company_name": null,
"first_name": "Jan",
"last_name": "Kowalski",
"email": "sender@email.com",
"phone": "888000000",
"address": null
},
"created_at": "2015-09-06T19:21:00.000+02:00",
"created_by_id": 3,
"cod_amount": {
"amount": 12.50,
"currency": "PLN"
},
"insurance": {
"amount": 25,
"currency": "PLN"
},
"additional_services": ["email", "sms"],
"reference": "Order No. 12345",
"is_return": false,
"tracking_number": null,
"offers": [],
"selected_offer": null,
"transactions": [],
"mpk": {
"id": 1,
"name": "Nazwa miejsca powstania kosztów."
}
}
Example request for multiple parcels in a single shipment (available only for inpost_courier):
Error information
Errors that may appear when creating a shipment (the following errors are returned as a response to the shipment creation request, not via webhooks):
validation_failed
- request parameters are incorrect. Details are available in thedetails
,resource_not_found
- Organization for which the shipments creation was requested either doesn't exist or the user has no access to it.no_carriers
- In case the organization has no carriers contracted,carrier_unavailable
- In case the organization has no carriers contracted providing the requestedservice
Asynchronous offer preparation
After creating a shipment an asynchronous offer preparation process starts. The offer expires after 5 minutes and they won't be buyable anymore. To generate a new offer, an empty edit request to the shipment should be made.
To receive information about the offers preparation process finishing, a url address should be added to the organization configuration to receive the offers_prepared
events. Thanks to that ShipX will send the following information to the url on offers preparation process finishing: