Documentation for the Parcelspot API

  • REST API Parcelspot is free and can be used by any registered customer
  • production API is located at https://www.parcelspot.com/api/v1
  • test API is available at https://test.parcelspot.com/api/v1
  • all sent and received data is in UTF-8 encoding
  • data is transmitted in JSON format
  • all calls are made using HTTP method POST or GET
  • communication is performed using secure HTTPS protocol

Documentation will be further improved. In the near future, we will add model situations and sample source code for PHP.

If you have any question, suggestion, suggestion for improvement, or you have found a mistake, do not hesitate to contact our IT department at admin@parcelspot.com.

Authentication

Each request is authenticated using the API key provided in your account settings. The API key is added as a parameter x-apikey to the request header for each called API method.

Response to request

The response to each request is identified by an HTTP status code corresponding to the parameter status in the response body and an action message message. There are two types of response according to the processing status: ok (code 200 OK) or error (any other code).

In case of error processing, an error message and an error object with a list of incorrect parameters can be returned in response to the corresponding status code.

If processing is successful, the response is returned with an optional parameter corresponding to the particular method being called .

Response structure
Parameter Type Description Required
status integer response status code yes
message string action report yes
errors string|array error message or array of error objects listing individual errors no
<parameter> array array of objects or values ‚Äč‚Äčaccording to a specific method no
Example of success response
    {
        "status": 200,
        "message": "Contact succesfully deleted"
    }
Example of an error response
    {
        "status": 401,
        "message": "Unauthorized request"
    }

    {
        "status": 400,
        "message": "Contact validation error"
        "errors": [{
            "message": "Address line cannot be empty"
        }]
    }

Methods

Offer shipping, prices and delivery dates

Description of the Method

To determine the offer of transport, the method is used, which based on the parameters sent from where, where, the specification of packages and possible additional services, returns the offer of available shipping companies together with the price and expected delivery date. The price for the services and the available shipping companies correspond to the current price group and the authorized carriers for the given customer account.

Request

POST https://www.parcelspot.com/api/v1/rates/get

Body Request
Parameter Type Description Required
currency string ISO 4217 currency code in which to return service prices no
type enum shipment type type (mode) of collection according to shipment type dictionary no
pickup_date date required pickup date (YYYY-MM-DD) no
pickup_branch string parcelPoint code collection point code no
delivery_branch string parcelPoint code drop-off point code no
from object contact only the "state" field is required yes
to object contact only the "state" field is required yes
services array of services array of service objects with additional services no
packages array of packages array of package objects with individual packages yes
Response
Parameter Type Description Required
status integer response status code yes
message string action report yes
errors array array of error objects with error messages no
rates array of rates array of rate objects with carrier offers no
Example Call
curl -v https://www.parcelspot.com/api/v1/rates/get \
-X "POST" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-Apikey: secret-api-key" \
-d '{
        "currency": "ZAR",
        "pickup_date": "2016-07-10",
        "from": {
            "country": "ZA"
        },
        "to": {
            "country": "ZA"
        },
        "services": [{
            "code": "cod",
            "data": {
                "value": {
                    "value": 1500,
                    "currency": "ZAR"
                }
            }
        }],
        "packages": [{
            "weight": 1,
            "width": 10,
            "height": 20,
            "length": 30
        }]
    }'
Response Example
    {
        "status": 200,
        "message": "Found 3 offers",
        "rates": [{
            "carrier": "UPS",
            "service": "Export SK",
            "service_id": 21,
            "pickup_date": "2016-07-10",
            "delivery_date": "2016-07-12",
            "price": {
                "value": 178.51,
                "currency": "ZAR"
            },
            "price_vat": {
                "value": 216,
                "currency": "ZAR"
            }
        },{
            ...
        }]
    }

Shipment Operations

A set of methods for handling shipments.

Create a new order

Description of the Method

Create a new order with one or more shipments.

Request

POST https://www.parcelspot.com/api/v1/shipments/create

Body
Parameter Type Description Required
currency string ISO 4217 currency code in which to place the order no*)
payment_type enum payment_type form of payment for this batch / order no*)
shipments array of shipments array of shipment objects yes

*) If not specified, the default settings for the customer account will be used

Response
Parameter Type Description Required
status integer response status code yes
message string action report yes
errors array array of errors no
Example Call
curl -v https://www.parcelspot.com/api/v1/shipments/create \
-X "POST" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-ApiKey: secret-api-key" \
-d '{
        "currency": "ZAR",
        "payment_type": "online",
        "shipments": [{
            "carrier": "UPS",
            "pickup_date": 2016-07-11,
            "from": {
                "id": 1001
            },
            "to": {
                "firstname": "David",
                "surname": "Williams",
                "company": "Parcelspot Ltd.",
                "street": "4447 Sheffield Rd",
                "city": "Cape Town",
                "zip": "7750",
                "country": "ZA",
                "phone": "+27115689759",
                "email": "williams@dummymail.com"
            },
            "services": [{
                "code": "cod",
                "data": {
                    "value": {
                        "value": 1500,
                        "currency": "ZAR"
                    }
                }
            }, {
                "code": "ins",
                "data": {
                    "value": 12500,
                    "currency": "ZAR"
                }
            }],
            "packages": [{
                "weight": 1,
                "width": 10,
                "height": 20,
                "length": 30
            }, {
                ... second package ...
            }]
        }, {
            ... second shipment ...
        }]
    }'
Response Example
    {
        "status": 200,
        "message": "Order was successfully created",
        "data": {
            "shipments": ["IZ0123456789", "IZ1234567890"]
        }
    }

    {
        "status": 401,
        "message": "You are not allowed to use invoice payment method"
    }

Print shipping labels

Description of the Method

Get labels for specified shipments. This method is intended only for users who have regular package collection.

Request

POST https://www.parcelspot.com/api/v1/shipments/label

Body
Parameter Type Description Requried
shipments array array of shipment identifiers yes
position integer [1 to 4] first label position no*)
format string [pdf, url] return value format containing labels no**)

*) If not specified, the default value is 1

**) If not specified, default value is used pdf

Response
Parameter Type Description Requried
status integer response status code yes
message string action report yes
errors array array of errors no
data string link to download label (for format url) or base64 encoded label file (for format pdf) no
Example Call
curl -v https://www.parcelspot.com/api/v1/shipments/label \
-X "POST" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-Apikey: secret-api-key" \
-d '{
        "shipments": ["IZ0123456789", "IZ1234567890"],
        "position": 2,
        "format": "pdf"
    }'
Response Example
    {
        "status": 200,
        "message": "OK. Found 2 label(s).",
        "data": "data:application/pdf;base64,ZGF0YTphcHBsaWNhdGlvbi9wZGY7YmFz..."
    }
    
    {
        "status": 404,
        "message": "No shipments with specified identificators were found."
    }

List of shipments

Description of the Method

Get a list of shipments. The method always returns a maximum of 100 results sorted by date in descending order.

Request

GET https://www.parcelspot.com/api/v1/shipments/list

The method call address can be further extended with optional parameters:

Parameter Type Description Required
status string(20) shipment status; ACTIVE, DELIVERED options no
offset int move results to view older shipments no
Response
Parameter Type Description Required
status integer response status code yes
message string action report yes
errors array array of errors no
data array of shipments array of shipment objects with shipment information no
Example Call
curl -v https://www.parcelspot.com/api/v1/shipments/list \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-Apikey: secret-api-key"
Response Example
    {
        "status": 200,
        "message": "OK. Found 10 shipment(s).",
        "data": {
            "IZ076151CA1F": {
                "carrier": "UPS",
                "service_id": "7",
                "pickup_date": "2017-02-02 10:24:17",
                "delivery_date": "2017-02-03 10:24:17",
                "status": "INTRANSIT",
                "from": {
                    "firstname": "Joshua",
                    "surname": "Williams",
                    ...
                },
                "to": {
                    "firstname": "Ethan",
                    "surname": "Williams",
                    ...
                },
                "packages": [{
                    "status": "INTRANSIT",
                    "weight": 1,
                    "width": 10,
                    "height": 20,
                    "length": 30
                },
                    ... second package ...
                }]
            },
            "IZ1234567890": {
                ... second shipment ...
            }
        }
    }

Shipment detail

Description of the Method

Get shipment details.

Request

POST https://www.parcelspot.com/api/v1/shipments/detail

Body
Parameter Type Description Required
shipments array of strings array of shipment identifiers yes
Response
Parameter Type Description Required
status integer response status code yes
message string action report yes
errors array array of errors no
data array of shipments array of shipment objects with shipment information no
Example Call
curl -v https://www.parcelspot.com/api/v1/shipments/detail \
-X "POST" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-Apikey: secret-api-key" \
-d '{
        "shipments": ["IZ076151CA1F", "IZ1234567890"]
    }'
Response Example
    {
        "status": 200,
        "message": "OK. Found 10 shipment(s).",
        "data": {
            "IZ076151CA1F": {
                "carrier": "UPS",
                "service_id": "21",
                "pickup_date": "2017-02-02 10:24:17",
                "delivery_date": "2017-02-03 10:24:17",
                "status": "INTRANSIT",
                "from": {
                    "firstname": "Joshua",
                    "surname": "Williams",
                    ...
                },
                "to": {
                    "firstname": "Ethan",
                    "surname": "Williams",
                    ...
                },
                "packages": [{
                    "status": "INTRANSIT",
                    "weight": 1,
                    "width": 10,
                    "height": 20,
                    "length": 30
                },
                    ... second package ...
                }],
                "services": [{
                    "code": "ins",
                    "data": {
                        "value": 12000,
                        "currency": "ZAR"
                    }
                }]
            },
            "IZ1234567890": {
                ... second shipment ...
            }
        }
    }

Shipment Tracking

Description of the Method

Track delivery status.

Request

POST https://www.parcelspot.com/api/v1/shipments/tracking

Body
Parameter Type Description Required
shipments array of strings array of shipment identifiers yes
Response
Parameter Type Description Required
status integer response status code yes
message string action report yes
errors array array of errors no
data array of shipments array of shipment objects with shipment information no
Example Call
curl -v https://www.parcelspot.com/api/v1/shipments/tracking \
-X "POST" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-Apikey: secret-api-key" \
-d '{
        "shipments": ["IZ076151CA1F", "IZ1234567890"]
    }'
Response Example
    {
        "status": 200,
        "message": "OK. Found 1 shipment(s).",
        "data": {
            "IZ076151CA1F": {
                "status": "INTRANSIT",
                "packages": [
                    [
                        {
                            "date": "2016-07-04",
                            "time": "15:00:00",
                            "name": "The package was received by the UPS.",
                            "status": "INTRANSIT",
                            "location": "South Africa"
                        }, {
                            "date": "2016-07-02",
                            "time": "12:00:00",
                            "name": "The package data has been entered into the UPS system.",
                            "status": "EXPORTED"
                        }
                    ], [
                        ... second package ...
                    ]
                ]
            },
            "IZ1234567890": {
                ... second shipment ...
            }
        }
    }

Collection Request

You can also track and create collection requests via the API.

List of collection requests

Description of the Method

Get a list of collection requests.

Request

GET https://www.parcelspot.com/api/v1/pickups/list

Response
Parameter Type Description Required
status integer response status code yes
message string action report yes
errors array array of errors no
data array of pickups array of pickup objects no
Example Call
curl -v https://www.parcelspot.com/api/v1/pickups/list \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-Apikey: secret-api-key"
Response Example
    {
        "status": 200,
        "message": "OK. Found 4 pickup(s).",
        "data": {
            "16": {
                "id": 16,
                "date": "2017-01-31",
                "carrier": "UPS",
                "address_id": 1001
            }, {
            ...
            }
        }
    }

Create a new collection request

Description of the Method
Request

POST https://www.parcelspot.com/api/v1/pickups/add

Body
Parameter Type Description Required
pickups array of pickups array of pickup objects yes
Response
Parameter Type Description Required
status integer response status code yes
message string action report yes
errors array array of errors no
data array of integers array of identifiers of newly created contacts no
Example Call
curl -v https://www.parcelspot.com/api/v1/pickups/add \
-X "POST" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-Apikey: secret-api-key" \
-d '{
        "pickups": [{
            "date": "2017-02-10",
            "carrier": "UPS",
            "address_id": 1001
        }, {
          ...
        }]
    }'
Response Example
    {
        "status": 200,
        "message": "2 pickups successfuly added.",
        "data": [35, 36]
    }

Drop-off Points

A list of drop-off points can be obtained through the API.

Seznam sbńõrn√Ĺch/v√Ĺdejn√≠ch m√≠st

Description of the Method

Obtain a list of drop-off points.

Request

GET https://www.parcelspot.com/api/v1/parcelpoints/list

Response
Parameter Type Description Required
status integer response status code yes
message string action report yes
errors array array of errors no
data array of parcelPoints array of parcelPoint of parcelPoint objects no
Example Call
curl -v https://www.parcelspot.com/api/v1/parcelpoints/list \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-Apikey: secret-api-key"
Response Example
    {
        "status": 200,
        "message": "OK. Found 148 item(s).",
        "data": {
            "60500-ABZKNIHYAS": {
                "code": "7780-Plumblink",
                "name": "Plumblink Lansdowne",
                "street": "11 Blomvlei Rd",
                "city": "Cape Town",
                "zip": "7780",
                "country": "ZA",
                "coords": "-33.993227|18.511108",
                "contact_name": "Michelle Daniels",
                "contact_phone": "+27115689759",
                "opening_hours": {
                    "1": "10:00-17:00",
                    "2": "10:00-19:00",
                    "3": "10:00-19:00",
                    "4": "10:00-17:00",
                    "5": "10:00-17:00",
                    "6": null,
                    "7": null
                }
            }, {
            ...
            }
        }
    }

Address Book

The address book can also be managed via the API. The sender or recipient of the shipment can then select the selected contact from the address book identified by a unique ID. When entering a shipment, there is no need to enter addresses and contact details.

Address book list

Description of the Method

Get contact list from address book.

Request

GET https://www.parcelspot.com/api/v1/contacts/list

Response
Parameter Type Description Required
status integer response status code yes
message string action report yes
errors array array of errors no
data array of contacts array of contact objects no
Example Call
curl -v https://www.parcelspot.com/api/v1/contacts/list \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-Apikey: secret-api-key"
Response Example
    {
        "status": 200,
        "message": "OK. Found 25 contact(s).",
        "data": {
            "1002": {
                "id": 1002,
                "firstname": "Samantha",
                "surname": "Smith",
                "street": "5 Well St, Riviera",
                "city": "Pretoria",
                "zip": "0084",
                "country": "ZA",
                "phone": "+27115689759",
                "email": "smith.samantha@dummymail.com"
            }, {
            ...
            }
        }
    }

Create a new contact in the address book

Description of the Method

Add one or more contacts to the address book.

Request

POST https://www.parcelspot.com/api/v1/contacts/add

Body
Parameter Type Description Required
contacts array of contacts array of contact objects to add to the address book yes
Response
Parameter Type Description Required
status integer response status code yes
message string action report yes
errors array array of errors no
data array of integers array of identifiers of newly created contacts no
Example Call
curl -v https://www.parcelspot.com/api/v1/contacts/add \
-X "POST" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-Apikey: secret-api-key" \
-d '{
        "contacts": [{
          "firstname": "David",
          "surname": "Williams",
          "company": "Parcelspot Ltd.",
          "street": "4447 Sheffield Rd",
          "city": "Cape Town",
          "zip": "7750",
          "country": "ZA",
          "phone": "+27115689759",
          "email": "williams@dummymail.com"
        }, {
          ...
        }]
    }'
Response Example
    {
        "status": 200,
        "message": "2 contacts successfuly added.",
        "data": [1000, 1001]
    }

Edit contact in address book

Description of the Method

Edit one or more contacts to the address book.

Request

POST https://www.parcelspot.com/api/v1/contacts/edit

Body
Parameter Type Description Required
contacts array of contacts array of contact objects to add to the address boo yes
Response
Parameter Type Description Required
status integer response status code yes
message string action report yes
errors array array of errors no
data array of integers array of identifiers of modified contacts no
Example Call
curl -v https://www.parcelspot.com/api/v1/contacts/edit \
-X "POST" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-Apikey: secret-api-key" \
-d '{
        "contacts": [{
          "id": 1234,
          "firstname": "David",
          "surname": "Williams",
          "company": "Parcelspot Ltd.",
          "street": "4447 Sheffield Rd",
          "city": "Cape Town",
          "zip": "7750",
          "country": "ZA",
          "phone": "+27115689759",
          "email": "williams@dummymail.com"
        }, {
          ...
        }]
    }'
Response Example
    {
        "status": 200,
        "message": "2 contacts successfuly updated.",
        "data": [1000, 1001]
    }

Delete contacts from address book

Description of the Method

Delete one or more contacts from the address book.

Request

POST https://www.parcelspot.com/api/v1/contacts/delete

Body
Parameter Type Description Required
contacts array of integers array with contact IDs to delete yes
Response
Parameter Type Description Required
status integer response status code yes
message string action report yes
errors array array of errors no
Example Call
curl -v https://www.parcelspot.com/api/v1/contacts/delete \
-X "POST" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-Apikey: secret-api-key" \
-d '{
        "contacts": [1111, 1215]
    }'
Response Example
    {
        "status": 200,
        "message": "2 contacts successfuly deleted"
    }

Objects

Rate

Description of the Object

Data representation of the shipping company offer with price and date of collection and delivery.

Parameters
Parameter Type Description Required
carrier string(20) code of the shipping company according to the dictionary carriers -
service string(20) the name of the particular carrier's service -
service_id integer identifier of the particular carrier service -
pickup_date date earliest possible pickup date (YYYY-MM-DD) -
delivery_date date nearest possible delivery date (YYYY-MM-DD) -
price object money price for shipping excluding VAT -
price_vat object money price for shipping including VAT -

Note: lines in in italics indicate response parameters.

Example
    {
        "carrier": "UPS",
        "service": "Business-Parcel",
        "service_id": 7,
        "pickup_date": 2016-07-11,
        "delivery_date": 2016-07-12,
        "price": {
            "value": 98.35,
            "currency": "ZAR"
        },
        "price_vat": {
            "value": 119,
            "currency": "ZAR"
        }
    }

Contact

Description of the Object

Data representation of the contact person and the place of delivery or pickup.

Parameters
Parameter Type Description Required
id integer identifier of an existing contact no*)
company string(75) company name no
firstname string(50) name of the contact person yes**)
surname string(50) surname of the contact person yes**)
street string(100) street with house number yes**)
city string(50) municipality or city yes**)
zip string(12) postal code yes**)
country string(2) ISO 3166-1 alpha-2 country code yes
phone string(50) telephone contact yes**)
email string(50) email contact no

*) If we pass by ID reference, other parameters are optional

**) Optional when used in the method for obtaining the transport offer

Example
    {
        "id": 1001,
        "firstname": "David",
        "surname": "Williams",
        "company": "Parcelspot Ltd.",
        "street": "4447 Sheffield Rd",
        "city": "Cape Town",
        "zip": "7750",
        "country": "ZA",
        "phone": "+27115689759",
        "email": "williams@dummymail.com"
    }


    Can also be passed as reference only by ID:

    {
        "id": 1001
    }

Shipment

Description of the Object

Data representation of the shipment.

Parameters
Parameter Type Description Required
carrier string(20) code of the shipping company according to the dictionary carriers no
service_id integer identifier of the particular carrier service no
type enum shipment type type (mode) of collection according to shipment type codebook no
pickup_date date required pickup date (YYYY-MM-DD) no
pickup_branch string parcelPoint code collection point code no
delivery_branch string parcelPoint code dispensing point code no
from object contact a contact object specifying the pickup location yes
to object contact a contact object specifying the delivery location yes
services array of service service object array with additional services no
packages array of package array of package objects with individual packages yes
reference string(255) self-marking of the consignment no
note string(255) note for drivers no
status string shipment status -

Note: lines in in italics indicate response parameters.

Example
    {
        "carrier": "UPS",
        "pickup_date": 2016-07-11,
        "from": {
            "id": 1001
        },
        "to": {
            "firstname": "David",
            "surname": "Williams",
            "company": "Parcelspot Ltd.",
            "street": "4447 Sheffield Rd",
            "city": "Cape Town",
            "zip": "7750",
            "country": "ZA",
            "phone": "+27115689759",
            "email": "williams@dummymail.com"
        },
        "services": [{
            "code": "cod",
            "data": {
                "value": {
                    "value": 1500,
                    "currency": "ZAR"
                }
            }
        }, {
            "code": "ins",
            "data": {
                "value": 12500,
                "currency": "ZAR"
            }
        }],
        "packages": [{
            "weight": 1,
            "width": 10,
            "height": 20,
            "length": 30
        }, {
            ...
        }]
    }

ParcelPoint

Description of the Object

Data representation of the place for handing over or picking up the shipment.

Parameters
Parameter Type Description Required
code string location code -
name string place name -
street string street with house number -
city string municipality or city -
zip string postal code -
country string ISO 3166-1 alpha-2 country code -
coords string gps coordinates in tvau "lat | lng" -
contact_name string name of the contact person -
contact_phone string contact phone -
opening_hours array opening hours -

Note: lines in in italics indicate response parameters.

Example
    {
        "code": "7780-Plumblink",
        "name": "Plumblink Lansdowne",
        "street": "11 Blomvlei Rd",
        "city": "Cape Town",
        "zip": "7780",
        "country": "ZA",
        "coords": "-33.993227|18.511108",
        "contact_name": "Michelle Daniels",
        "contact_phone": "+27115689759",
        "opening_hours": {
            "1": "10:00-17:00",
            "2": "10:00-19:00",
            "3": "10:00-19:00",
            "4": "10:00-17:00",
            "5": "10:00-17:00",
            "6": null,
            "7": null
        }
    }

Package

Description of the Object

Data representation of one package in a shipment. The package is described by its weight, dimensions and additionally by its description and its monetary value.

Parameters
Parameter Type Description Required
weight float weight [kg] yes
width integer width v [cm] yes
height integer height v [cm] yes
length integer length [cm] yes
value object money package value no
content string(255) content of package no
status enum shipment status current package status according to shipment shipment status dictionary -
history array of history array of history representing package status history -

Note: lines in in italics indicate response parameters.

Example
    {
        "weight": 7.5,
        "width": 50,
        "height": 30,
        "length": 40,
        "value": {
            "value": 100,
            "currency": "EUR"
        },
        "content": "package description"
    }

History

Description of the Object

Data representation of shipment tracking history.

Parameters
Parameter Type Description Required
date date the date the record was created in the package history -
time time time of record creation in package history -
name string text information about the package history record -
status string status in package history -
location string additional information about package location / location -

Note: lines in in italics indicate response parameters.

Example
    {
        "date": "2016-07-16",
        "time": "15:17:00",
        "name": "Package delivered",
        "status": "DELIVERED",
        "location": "South Africa"
    }

Service

Description of the Object

Data representation of additional service (cash on delivery, additional insurance, etc.)

Parameters
Parameter Type Description Required
code string(20) code optional services under dictionaries services yes
data object optional parameters for the service according to dictionaries services yes
Example
    {
        "code": "cod",
        "data": {
            "value": {
                "value": 100,
                "currency": "ZAR"
            }
        }
    }

Pickup

Description of the Object

Data representation of the collection request.

Parameters
Parameter Type Description Required
date date required collection date (YYYY-MM-DD) yes
carrier string(20) kcode of the shipping company according to the dictionary carriers yes
address_id integer identifier of an existing contact yes
Example
    {
        "date": "2017-01-31",
        "carrier": "UPS",
        "address_id": 1001
    }

Money

Description of the Object

An object representing the monetary value in the corresponding currency. The object is used where it is necessary to pass a numerical expression of the value together with the currency. E.g. COD, insurance, parcel value, etc.

Parameters
Parameter Type Description Required
value float the amount in the relevant currency yes
currency string(3) ISO 4217 currency code yes
Example
    {
        "value": 1500,
        "currency": "ZAR"
    }

ServiceCOD

Description of the Object

Object representing the COD service.

Parameters
Parameter Type Description Required
bank_account string(64) account number for cash on delivery no
bank_code string(4) bank account code for cash on delivery no
bank_variable string(20) variable symbol used for cash on delivery no
value object money cash on delivery package amount yes
Example
    {
        "bank_account": "12-34567890",
        "bank_code": "0100",
        "value": {
            "value": 1500,
            "currency": "ZAR"
        }
    }

Error

Description of the Object

The object representing the error message.

Parameters
Parameter Type Description Required
field string the name of the parameter that caused the error -
message string text description of the error -
value string specified parameter value -
Example
    {
        "field": "contacts[0].email",
        "message": "Invalid e-mail format.",
        "value": "f.williams@dummymail.com"
    }

Dictionaries

HTTP status codes

Description of the code

HTTP response status codes.

Code State Description
200 OK Request successfully processed
400 Bad Request Invalid request (input data error)
401 Unauthorized Unauthorized Request (Invalid API Key)
404 Not Found Requested method not found (bad request URL)
500 Internal Server Error Internal application error (error on our side)

Carriers

Description of the code

Dictionary of shipping companies that the Parcelspot system integrates.

Code Name
GLOBEFLIGHT GlobeFlight
WORLDNETEXPRESS WorldnetExpress
COURIERIT CourierIT
FEDEX FedEx

Payment type

Description of the code

List of available forms of payment per batch / order. The invoice payment is only available by prior arrangement for business customers with a forwarding contract. Do you also want to pay by invoice? Please contact us.

Code Description
ONLINE Payment by GoPay on-line via returned URL
CREDIT Payment from prepaid credit on customer account
INVOICE Payment on invoice only for contract customers

Shipment Status

Description of the code

Dictionary of possible states in shipment history.

Code Description
CREATED Shipment created
EXPORTED The shipper acknowledged receipt of the shipment data
ONPICKUP Shipment waiting for pickup by courier
INTRANSIT The shipment is on its way to the destination depot
ONDELIVERY The consignment was handed over to the courier for delivery
DELIVERED The shipment was delivered
CANCELLED Shipment canceled

Shipment Type

Description of the code

Dictionary of possible collection modes.

Code Description
ONDEMAND One-time Collection - labels are printed by the carrier.
OCCASIONAL Occasional collection - labels are printed by the customer.
REGULAR

Services

Description of the code

Dictionary of extra services.

Code Data Description
COD object serviceCOD Cash on delivery to selected countries (CZ, SK)
INS object money Additional insurance beyond basic insurance
DSC string(20) Discount code
Example: COD
    {
        "code": "cod",
        "data": {
            "bank_currency": "ZAR",
            "bank_account": "12-34567890",
            "bank_code": "0100",
            "bank_variable": "987654321",
            "value": {
                "value": 1500,
                "currency": "ZAR"
            }
        }
    }
Example: insurance
    {
        "code": "ins",
        "data": {
            "value": 500,
            "currency": "ZAR"
        }
    }

Pickup Time Range

Description of the code

Dictionary of time windows of collection.

Code Data
1 09:00:00 - 13:00:00
2 09:30:00 - 13:30:00
3 10:00:00 - 14:00:00
4 10:30:00 - 14:30:00
5 11:00:00 - 15:00:00
6 11:30:00 - 15:30:00
7 12:00:00 - 16:00:00
8 12:30:00 - 16:30:00
9 13:00:00 - 17:00:00

Examples of implementation


This section provides examples of the implementation of the Parcelspot API in the PHP programming language.

Getting a shipping offer

Implementation

To get a shipping offer, you need to send a POST request to the address https://www.parcelspot.com/api/v1/rates/get.

The input data must be specified in the request body as described in the documentation above.

The example in the box on the right is in PHP using the built-in library curl.

Example: Get a shipping offer in PHP

// First, it is necessary to assemble the data that will be sent in the request body
// as specified in the documentation.
$data = array(
    "from" => array(
        "country" => "ZA"
    ),
    "to" => array(
        "country" => "ZA"
    ),
    "services" => array(
        array(
            "code" => "COD",
            "data" => array(
                "value" => array(
                    "value" => 1500,
                    "currency" => "ZAR"
                )
            )
        )
    ),
    "packages" => array(
        array(
            "weight" => 1,
            "width" => 10,
            "height" => 20,
            "length" => 30
        )
    )
);
// The data must be sent in the JSON format in the request body,
// so the data must be transferred to that format.
$data = json_encode($data);

// We will use the cURL PHP library to send the request.
// For all setup options, see http://php.net/manual/en/book.curl.php
// 1. Initialize library
$ch = curl_init();
// 2. Set the API URL
curl_setopt($ch, CURLOPT_URL, "https://www.parcelspot.com/api/v1/rates/get");
// 3. Determine the HTTP call method
curl_setopt($ch, CURLOPT_POST, 1);
// 4. Headers settinfs. Instead of <YOUR-API-KEY> add your API key
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    "Accept: application/json",
    "Content-Type: application/json",
    "X-Apikey: <YOUR-API-KEY>"
));
// 5. Filling the request body with data
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
// 6. Save response to variable
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// 7. Call API Parcelspot with the selected parameters
$response = curl_exec($ch);
// 8. Close a cURL session
curl_close($ch);

// $response variable now contains the JSON response.
// Let's convert it to an associative array format
$response = json_decode($response, true);

Create a new order

Implementation

To create a new order, it is necessary to send a POST request to the address https://www.parcelspot.com/api/v1/shipments/create.

The input data must be specified in the request body as described in the documentation above.

The example in the box on the right is in PHP using the built-in library curl.

Note: for a detailed description of all the methods and calls in the code, please see the code sample to get a transport offer that is richly commented.

Example: Create a new order in PHP

// Request Data
$data = array(
    "currency" => "ZAR",
    "payment_type" => "online",
    "shipments" => array(
        array(
            "pickup_date" => "2017-02-10",
            "from" => array(
                "id" => 1001
            ),
            "to" => array(
                "firstname" => "David",
                "surname" => "Williams",
                "company" => "Parcelspot Ltd.",
                "street" => "4447 Sheffield Rd",
                "city" => "Cape Town",
                "zip" => "7750",
                "country" => "ZA",
                "phone" => "+27115689759",
                "email" => "williams@dummymail.com"
            ),
            "packages" => array(
                array(
                    "weight" => 1,
                    "width" => 10,
                    "height" => 20,
                    "length" => 30
                )
            )
        )
    )
);
$data = json_encode($data);

// Create cURL request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.parcelspot.com/api/v1/shipments/create");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    "Accept: application/json",
    "Content-Type: application/json",
    "X-Apikey: <YOUR-API-KEY>"
));
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);

// Response
$response = json_decode($response, true);

Get a contact list

Implementation

To get a shipping offer, you need to send a GET request to https://www.parcelspot.com/api/v1/contacts/list.

The example in the box on the right is in PHP using the built-in library curl.

Note: for a detailed description of all the methods and calls in the code, please see the code sample to get a transport offer that is richly commented.

Example: Get a contact list in PHP

// Create cURL request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.parcelspot.com/api/v1/contacts/list");
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    "Accept: application/json",
    "Content-Type: application/json",
    "X-Apikey: <YOUR-API-KEY>"
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);

// Response
$response = json_decode($response, true);