This API specification details the requirements for integrating with Royal Mail API Shipping V3.
It specifically covers how the Royal Mail API Shipping V3 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 API Shipping V3 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 API Shipping V3 provides a simple and low cost method for customers to integrate with Royal Mail, and allows them to get shipping quickly. The API offers data streaming and offline barcoding to allow customers greater flexibility when generating their labels. There are no costs to customers for using the Royal Mail API Shipping V3 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 API can be used in conjunction with Royal Mail Pro Shipping, a GUI based shipping platform. For more details on Royal Mail Pro Shipping, including videos on and briefs on updating/ cancelling a shipment and Manifesting please refer to http://www.royalmail.com/pro-shipping-help.
This PHP package is automatically generated by the Swagger Codegen project:
- API version: 3.0.12
- 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/Secret
$config = RoyalMail\Shipping\Rest\Api\Configuration::getDefaultConfiguration()->setApiKey('X-IBM-Client-Id', 'YOUR_API_KEY');
$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-Id', 'Bearer');
$apiInstance = new RoyalMail\Shipping\Rest\ApiAddressesApi(
// 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\Address(); // \RoyalMail\Shipping\Rest\Api\models\Address | The address.
$xRMGAuthToken = "xRMGAuthToken_example"; // string | Authorisation token required to invoke this operation. Can be retrieved by invoking the **_/token** operation.
try {
$result = $apiInstance->addressesCreate($body, $xRMGAuthToken);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling AddressesApi->addressesCreate: ', $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');
$apiInstance = new RoyalMail\Shipping\Rest\ApiAddressesApi(
// 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.
$addressId = "addressId_example"; // string | Your unique Address ID of the address to delete.
try {
$result = $apiInstance->addressesDelete($xRMGAuthToken, $addressId);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling AddressesApi->addressesDelete: ', $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');
$apiInstance = new RoyalMail\Shipping\Rest\ApiAddressesApi(
// 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.
$addressId = "addressId_example"; // string | Your unique Address ID.
try {
$result = $apiInstance->addressesGet($xRMGAuthToken, $addressId);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling AddressesApi->addressesGet: ', $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');
$apiInstance = new RoyalMail\Shipping\Rest\ApiAddressesApi(
// 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.
try {
$result = $apiInstance->addressesGetAll($xRMGAuthToken);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling AddressesApi->addressesGetAll: ', $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');
$apiInstance = new RoyalMail\Shipping\Rest\ApiAddressesApi(
// 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\Address(); // \RoyalMail\Shipping\Rest\Api\models\Address | The address with the updated details.
$xRMGAuthToken = "xRMGAuthToken_example"; // string | Authorisation token required to invoke this operation. Can be retrieved by invoking the **_/token** operation.
$addressId = "addressId_example"; // string | Your unique Address ID of the address to update.
try {
$result = $apiInstance->addressesUpdate($body, $xRMGAuthToken, $addressId);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling AddressesApi->addressesUpdate: ', $e->getMessage(), PHP_EOL;
}
?>
All URIs are relative to ///shipping/v3
Class | Method | HTTP request | Description |
---|---|---|---|
AddressesApi | addressesCreate | POST /addresses | Create Address |
AddressesApi | addressesDelete | DELETE /addresses/{addressId} | Delete Address |
AddressesApi | addressesGet | GET /addresses/{addressId} | Get Address |
AddressesApi | addressesGetAll | GET /addresses | Get Addresses |
AddressesApi | addressesUpdate | PUT /addresses/{addressId} | Update address |
ItemsApi | itemsCreate | POST /items | Create Item |
ItemsApi | itemsDelete | DELETE /items/{itemId} | Delete Item |
ItemsApi | itemsGet | GET /items/{itemId} | Get Item |
ItemsApi | itemsGetAll | GET /items | Get Items |
ItemsApi | itemsUpdate | PUT /items/{itemId} | Update item |
ManifestsApi | manifestsCreate | POST /manifests | Manifest All Shipments |
ManifestsApi | manifestsCreateByCarrier | POST /manifests/bycarrier | Manifest by Carrier Code(s) |
ManifestsApi | manifestsCreateByService | POST /manifests/byservice | Manifest by Service Code(s) |
PackagingApi | packagingCreate | POST /packaging | Create Packaging |
PackagingApi | packagingDelete | DELETE /packaging/{packagingId} | Delete Packaging |
PackagingApi | packagingGet | GET /packaging/{packagingId} | Get Packaging |
PackagingApi | packagingGetAll | GET /packaging | Get All Packaging |
PackagingApi | packagingUpdate | PUT /packaging/{packagingId} | Update packaging |
ShipmentsApi | shipmentsCancel | PUT /shipments/cancel | Cancel Shipments |
ShipmentsApi | shipmentsCreate | POST /shipments | Create Shipment |
ShipmentsApi | shipmentsDefer | PUT /shipments/defer | Defer Shipments |
ShipmentsApi | shipmentsHold | PUT /shipments/hold | Hold Shipments |
ShipmentsApi | shipmentsPrintDocument | PUT /shipments/{shipmentId}/printDocument | Print Document |
ShipmentsApi | shipmentsPrintLabel | PUT /shipments/{shipmentId}/printLabel | Print Label |
ShipmentsApi | shipmentsRelease | PUT /shipments/release | Release Shipments |
ShipmentsApi | shipmentsServiceAvailability | POST /shipments/serviceAvailability | Service Availability |
TokenApi | authenticatePost | POST /token | Authenticates a User and provides token. |
- Address
- AddressResponse
- CreateShipmentDestination
- CreateShipmentServiceOptions
- CreateShipmentShipment
- CreateShipmentShipmentInformation
- CreateShipmentShipmentPackage
- ErrorDetail
- Item
- ItemResponse
- Manifest
- ManifestCarrierCodesRequest
- ManifestRequest
- ManifestResponse
- ManifestServiceCodesRequest
- PackageResponse
- Packaging
- PackagingResponse
- PrintDocumentRequest
- PrintDocumentResponse
- PrintLabelRequest
- PrintLabelResponse
- ServiceAvailabilityDestination
- ServiceAvailabilityFormat
- ServiceAvailabilityOption
- ServiceAvailabilityResponse
- ServiceAvailabilityServiceOptions
- ServiceAvailabilityShipment
- ServiceAvailabilityShipmentInformation
- ServiceAvailabilityShipmentPackage
- ShipmentCancelRequest
- ShipmentCreateResponse
- ShipmentDeferRequest
- ShipmentHoldRequest
- ShipmentItem
- ShipmentsCancelResponse
- ShipmentsDeferResponse
- ShipmentsHoldResponse
- ShipmentsReleaseRequest
- ShipmentsReleaseResponse
- Shipper
- 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