This API specification details the requirements for integrating with Royal Mail Pro Shipping V2 REST API. It specifically covers how the Royal Mail Pro Shipping API can be used by business customers to conduct shipping activity with Royal Mail and provides the technical information to build this integration. This specification must be used with the relevant accompanying specifications for customers wishing to interface their systems with Royal Mail services. Royal Mail Pro Shipping API exposes a fully RESTful service that allows account customers to create shipments, produce labels, and produce documentation for all the tasks required to ship domestic items with Royal Mail. Built on industry standards, Royal Mail Pro Shipping V2 API provides a simple and low cost method for customers to integrate with Royal Mail, and allows them to get shipping quickly. There are no costs to customers for using the Royal Mail Pro Shipping V2 API services, however customers’ own development costs must be covered by the customer developing the solution. Royal Mail will not accept any responsibility for these development, implementation and testing costs. Customers should address initial enquiries regarding development of systems for these purposes to their account handler.
This PHP package is automatically generated by the Swagger Codegen project:
- API version: 1.0.21
- Build package: io.swagger.codegen.v3.generators.php.PhpClientCodegen
PHP 5.5 and later
To install the bindings via Composer, add the following to composer.json
:
{
"repositories": [
{
"type": "git",
"url": "https://github.com/zVPS/royal-mail-shipping-rest-api-client.git"
}
],
"require": {
"zVPS/royal-mail-shipping-rest-api-client": "*@dev"
}
}
Then run composer install
Download the files and include autoload.php
:
require_once 'vendor/autoload.php';
To run the unit tests:
composer install
./vendor/bin/phpunit
Please follow the installation procedure and then run the following:
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure API key authorization: clientID
$config = RoyalMail\Shipping\Rest\Api\Configuration::getDefaultConfiguration()->setApiKey('X-IBM-Client-Id', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = RoyalMail\Shipping\Rest\Api\Configuration::getDefaultConfiguration()->setApiKeyPrefix('X-IBM-Client-Id', 'Bearer');
// Configure API key authorization: clientSecret
$config = RoyalMail\Shipping\Rest\Api\Configuration::getDefaultConfiguration()->setApiKey('X-IBM-Client-Secret', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = RoyalMail\Shipping\Rest\Api\Configuration::getDefaultConfiguration()->setApiKeyPrefix('X-IBM-Client-Secret', 'Bearer');
$apiInstance = new RoyalMail\Shipping\Rest\Api\RoyalMail\Shipping\Rest\Api\ManifestApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client(),
$config
);
$body = new \RoyalMail\Shipping\Rest\Api\models\ManifestRequest(); // \RoyalMail\Shipping\Rest\Api\models\ManifestRequest |
$xRMGAuthToken = "xRMGAuthToken_example"; // string | Authorisation token required to invoke this operation. Can be retrieved by invoking the **_/token** operation.
try {
$result = $apiInstance->manifestPost($body, $xRMGAuthToken);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling ManifestApi->manifestPost: ', $e->getMessage(), PHP_EOL;
}
// Configure API key authorization: clientID
$config = RoyalMail\Shipping\Rest\Api\Configuration::getDefaultConfiguration()->setApiKey('X-IBM-Client-Id', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = RoyalMail\Shipping\Rest\Api\Configuration::getDefaultConfiguration()->setApiKeyPrefix('X-IBM-Client-Id', 'Bearer');
// Configure API key authorization: clientSecret
$config = RoyalMail\Shipping\Rest\Api\Configuration::getDefaultConfiguration()->setApiKey('X-IBM-Client-Secret', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = RoyalMail\Shipping\Rest\Api\Configuration::getDefaultConfiguration()->setApiKeyPrefix('X-IBM-Client-Secret', 'Bearer');
$apiInstance = new RoyalMail\Shipping\Rest\Api\RoyalMail\Shipping\Rest\Api\ManifestApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client(),
$config
);
$xRMGAuthToken = "xRMGAuthToken_example"; // string | Authorisation token required to invoke this operation. Can be retrieved by invoking the **_/token** operation.
$salesOrderNumber = "salesOrderNumber_example"; // string | The Sales Order Number, which is available via the GUI the day after the manifest was created.
$manifestBatchNumber = "manifestBatchNumber_example"; // string | This is the batch number to print and is returned by a prior call to create manifest operation.
try {
$result = $apiInstance->manifestPut($xRMGAuthToken, $salesOrderNumber, $manifestBatchNumber);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling ManifestApi->manifestPut: ', $e->getMessage(), PHP_EOL;
}
?>
All URIs are relative to ///shipping/v2
Class | Method | HTTP request | Description |
---|---|---|---|
ManifestApi | manifestPost | POST /manifest | Create shipping manifest. |
ManifestApi | manifestPut | PUT /manifest | Create manifest image. |
ShipmentApi | domesticPost | POST /domestic | Create a domestic shipment. |
ShipmentApi | shipmentNumberDelete | DELETE /{shipmentNumber} | Cancel a shipment. |
ShipmentApi | shipmentNumberLabelPut | PUT /{shipmentNumber}/label | Create shipment label. |
ShipmentApi | shipmentNumberPut | PUT /{shipmentNumber} | Update a shipment. |
ShipmentApi | shipmentsPost | POST /shipments | Create an international or domestic shipment. |
ShipmentApi | shipmentsShipmentNumberDocumentsPut | PUT /shipments/{shipmentNumber}/documents | Create international documents. |
TokenApi | getToken | GET /token | Method to get a JSON Web Token (JWT). |
- Address
- CancelOrUpdateShipmentResponse
- CompletedShipments
- Contact
- ContentDetail
- CreatedShipmentResponse
- DocumentsRequest
- Error
- ErrorResponse
- Errors
- LabelImages
- LabelResponse
- ManifestRequest
- ManifestResponse
- ManifestShipment
- ManifestShipments
- Measurement
- OfflineShipment
- Parcel
- PrintManifestResponse
- RecipientAddress
- RecipientContact
- Service
- ServiceEnhancements
- Shipment
- ShipmentBarcodeItem
- ShipmentBarcodeItems
- ShipmentRequestItem
- ShipmentRequestItemInternational
- ShipmentWithBarcodeAndWeight
- ShipmentsRequest
- Token
- Type: API key
- API key parameter name: X-IBM-Client-Id
- Location: HTTP header
- Type: API key
- API key parameter name: X-IBM-Client-Secret
- Location: HTTP header