Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 6 Next »

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.

On this page

 

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:

{
  "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.


Note! Debit clients

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

Creating multiple shipments

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  (Paying for shipment).
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  Creating a shipment in the simplified mode

The attribute is not required.

• Minimum 1

• Maximum               

2500


Sample request


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",
	  "reference": "Test",
      "custom_attributes": {
        "target_point": "KRA012"
      },
      "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",
	  "reference": "Test",
      "custom_attributes": {
        "target_point": "KRA012"
      },
      "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 

HTTP/1.1 201 Created
Content-Type: application/json
{
"href": "https://api-shipx-pl.easypack24.net/v1/batches/1672413",
"id": 1672413,
"status": "in_progress",
"shipments": [],
"created_at": "2021-08-11T13:12:50.325+02:00",
"updated_at": "2021-08-11T13:12:50.325+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

GET /v1/batches/:id

Sample request

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

Response

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


  • No labels