Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The Batch resource is used to create and view multiple shipments. In the asynchronous mode, after validation, each shipment is processed in a separate thread, and consequently, feedback is sent to WebHooks separately for each shipment.


Panel
bgColor#f0f0f0
titleBGColor#f0f0f0
titleOn this page

Table of Contents
minLevel2
 


The Batch resource has the following attributes:

AttributeTypeDescription
idIntegerObject ID
statusStringShipment processing status
shipmentsArray[Shipment]Shipments
created_atDateTimeDate created
updated_atDateTime Date updated

Sample Batch resource in the JSON format:

Code Block
{
  "href": "https://api-shipx-pl.easypack24.net/v1/batches/16",
  "id": 16,
  "status": "done",
  "shipments": [
    {
      "href": "https://api-shipx-pl.easypack24.net/v1/shipments/151",
      "id": 151,
      "status": "confirmed",
      "tracking_number": "633100159730624319900067"
    },
    {
      "href": "https://api-shipx-pl.easypack24.net/v1/shipments/150",
      "id": 150,
      "status": "confirmed",
	  "tracking_number": "633100159730624319900068"
    }
  ],
  "created_at": "2017-06-08T14:17:25.675+02:00",
  "updated_at": "2017-06-08T14:17:25.675+02:00"
}


Authentication

Access to the resource requires provision of the correct and valid access token.


Info
titleNote! Debit clients

After creating a shipment, we do not return prices for debit clients.
The rate attribute takes the null value


Creating multiple shipments

Code Block
POST /v1/organizations/:organization_id/batches

Parameters

ParameterTypeDescriptionValidation
only_choice_of_offerBoolean

Setting the parameter to true makes the offer in all shipments being selected for the stated service, but it will not be automatically paid.
Such shipment has to be paid for before the end of the offer's validity term by completing the operations  (Opłacanie przesyłki).
This parameter can also be set separately for each shipment (in such a case the parameter set in the shipment has a higher priority).

The attribute
is not
required.

• Default
value

false

shipmentsArray[Hash]


ParameterTypeDescription
idStringRequired. Unique ID of the given shipment, which allows for returning to the user the information about any validation errors assigned to the particular shipment. The ID is not saved in the database and is not returned as an attribute of the created shipment.
......The other parameters of a simplified shipment described at  Uproszczone tworzenie przesyłki Creating a shipment in the simplified mode


The attribute is not required.

• Minimum 1

• Maximum               

2500


Sample request


Code Block
curl -X POST https://api-shipx-pl.easypack24.net/v1/organizations/1/batches -H 'Authorization: Bearer token' -H 'content-type: application/json' -d '{ 
  "only_choice_of_offer": false,
  "shipments": [
    {
      "id": 1,
      "service": "inpost_locker_standard",
      "custom_attributes": {
        "target_point": "KRA010"
      },
      "parcels":{
        "template": "small"
      },
      "receiver": {
        "company_name": "Company name 1",
        "email": "sklep@inpost.pl",
        "phone": "888888888",
        "address": {
          "line1": "Zawila 65L",
          "city": "Krakow",
          "post_code": "30-390",
          "country_code": "PL"
        }
      },
      "sender": {
       "company_name": "Company name 2",
        "email": "sklep@inpost.pl",
        "phone": "999999999",
        "address": {
          "line1": "Zawila 65L",
          "city": "Krakow",
          "post_code": "30-390",
          "country_code": "PL"
        }
      },
      "cod": {
        "amount": 1,
        "currency": "PLN"
      },
      "insurance": {
        "amount": 23,
        "currency": "PLN"
      }
    },
    {
      "id": 2,
      "service": "inpost_locker_standard",
      "custom_attributes": {
        "target_point": "KRA010"
      },
      "parcels":{
        "template": "small"
      },
      "receiver": {
        "company_name": "Company name 1",
        "email": "sklep@inpost.pl",
        "phone": "888888888",
        "address": {
          "line1": "Zawila 65L",
          "city": "Krakow",
          "post_code": "30-390",
          "country_code": "PL"
        }
      },
      "sender": {
       "company_name": "Company name 2",
        "email": "sklep@inpost.pl",
        "phone": "999999999",
        "address": {
          "line1": "Zawila 65L",
          "city": "Krakow",
          "post_code": "30-390",
          "country_code": "PL"
        }
      },
      "cod": {
        "amount": 1,
        "currency": "PLN"
      },
      "insurance": {
        "amount": 23,
        "currency": "PLN"
      }
    }
  ]
}'

Response 

Code Block
HTTP/1.1 201 Created
Content-Type: application/json
{
  "href": "https://api-shipx-pl.easypack24.net/v1/batches/35",
  "id": 35,
  "status": "in_progress",
  "shipments": [
    {
      "href": "https://api-shipx-pl.easypack24.net/v1/shipments/195",
      "id": 195,
      "status": "confirmed",
      "tracking_number": "520000017830390003337439"
    },
    {
      "href": "https://api-shipx-pl.easypack24.net/v1/shipments/195",
      "id": 195,
      "status": "offer_selected",
      "tracking_number": "520000017830390003337439"
    },
    {
      "href": "https://api-shipx-pl.easypack24.net/v1/shipments/196",
      "id": 196,
      "status": "create",
      "tracking_number": null
    }
  ],
  "created_at": "2017-06-12T14:19:20.432+02:00",
  "updated_at": "2017-06-12T14:19:20.432+02:00"
}

Information about errors

The server may return the following errors

  • validation_failed - validation error
  • forbidden - the action is unavailable for the token provided
  • token_invalid - the user does not have access rights to the specified organization


Viewing multiple shipments

Code Block
GET /v1/batches/:id

Sample request

Code Block
curl -X GET https://api-shipx-pl.easypack24.net/v1/batches/16 -H 'Authorization: Bearer token' -H 'content-type: application/json' 

Response

Code Block
HTTP/1.1 200 OK
Content-Type: application/json
{
  "href": "https://api-shipx-pl.easypack24.net/v1/batches/16",
  "id": 16,
  "status": "done",
  "shipments": [
    {
      "href": "https://api-shipx-pl.easypack24.net/v1/shipments/151",
      "id": 151,
      "status": "confirmed",
      "tracking_number": "633100159730624319900067"
    },
    {
      "href": "https://api-shipx-pl.easypack24.net/v1/shipments/150",
      "id": 150,
      "status": "confirmed",
      "tracking_number": "633100159730624319900068"
    }
  ],
  "created_at": "2017-06-08T14:17:25.675+02:00",
  "updated_at": "2017-06-08T14:17:25.675+02:00"
}

Information about errors


The server may return the following errors


• resource_not_found - in the event that to the batch does not exist
• token_invalid - the user does not have access rights to the specified organization