ProCarrier Returns Retailer API (1.1)

The following API is designed to provide a complete set of tools to integrate with the ProCarrier Returns

Introduction

The following API is designed to provide a complete set of tools to integrate with the system.

Formats of requests and responses

Requests are using application/json format.

Responses are in JSON.

Request Method

Request method should always be POST.

Length of text fields

The maximum length of each text field is 255 symbols (except in a few places).

Request Encoding

Should be UTF-8.

Server Timezone

Timezone of our server is UTC

General Error codes

Error code Description
internal Internal server error.
requestWrong The requested data structure is malformed.
apiKeyEmpty Field `apiKey` from passed request data is empty.
ipBlocked Your IP address was blocked due to many incorrect login attempts.
accessDenied Passed field `apiKey` is incorrect.
requestEmpty Field `request` from passed request data is empty.
jsonInvalid Requested JSON is invalid (Field `request` in passed request).
unknownCall API method does not exist.

Authorization

Each API request requires apiKey key in the POST request body. API key can be found on the profile page. To access a profile page, you must be logged in to your account panel.

Incorrect auth response

{
    "error": {
        "code": "accessDenied",
        "message": [
            "Access denied"
        ]
    }
}

Orders

Create order

Create an order with requested values.

Request Body schema: application/json
required
ApiKey
required
string

Client API key

required
object

Responses

Request samples

Content type
application/json
{
  • "ApiKey": "api_123456789",
  • "Request": {
    }
}

Response samples

Content type
application/json
Example
{
  • "Success": {
    }
}

Update order

Update an order with requested values.

Request Body schema: application/json
required
ApiKey
required
string

Client API key

required
object

Responses

Request samples

Content type
application/json
{
  • "ApiKey": "api_123456789",
  • "Request": {
    }
}

Response samples

Content type
application/json
Example
{
  • "success": {
    }
}

Get order

Fetch order by requested field/value pair.

Request Body schema: application/json
required
ApiKey
required
string

Client API key

required
object

Responses

Request samples

Content type
application/json
{
  • "ApiKey": "api_123456789",
  • "Request": {
    }
}

Response samples

Content type
application/json
Example
{
  • "Success": {
    }
}

Delete order

Delete order by requested field/value pair.

Request Body schema: application/json
required
ApiKey
required
string

Client API key

required
object

Responses

Request samples

Content type
application/json
{
  • "ApiKey": "api_123456789",
  • "Request": {
    }
}

Response samples

Content type
application/json
Example
{
  • "Success": {
    }
}

Search orders

Search orders by requested parameters.

Request Body schema: application/json
required
ApiKey
required
string

Client API key

required
object

Responses

Request samples

Content type
application/json
{
  • "ApiKey": "api_123456789",
  • "Request": {
    }
}

Response samples

Content type
application/json
Example
{
  • "Success": {
    }
}

Services

Carrier Services Identifiers

You can get full list of services available to you by get available services endpoint

Please note, that a carrier service availability is determined by geographical coverage and your account settings.

Tracking status description

Tracking status codes

Code Description
10 Return registered online
11 Quarantine
20 Received by the carrier
24 In transit to transit hub
26 Received at transit hub
28 Processed by transit hub
29 Parcel relabeled
30 In transit to final hub
35 Parcel re-exported
40 Received at final hub
43 Processed by final hub
45 Parcel has been added to the pallet
90 Parcel has been extracted from the pallet
95 Pallet dissolved
50 In transit to the retailer
60 Delivered to the retailer
70 Parcel refunded by retailer
100 Parcel delayed
110 Parcel lost
120 Collection attempt failed
200 Parcel under investigation
201 Awaiting customs clearance
202 Customs clearance completed
300 Cancel requested
310 Canceled
400 Pallet in the process of filling

Get drop off points

Return drop off points information.

Request Body schema: application/json
required
ApiKey
required
string

Client API key

required
object

Responses

Request samples

Content type
application/json
{
  • "ApiKey": "api_123456789",
  • "Request": {
    }
}

Response samples

Content type
application/json
Example
{
  • "Success": {
    }
}

Get available services

Returns the list of available services.

You can query services by address, geographical location or get the list of all the services available to your account by passing empty request:

{
    "ApiKey": "api_123456789",
    "Request": {}
}
Request Body schema: application/json
required
ApiKey
required
string

Client API key

required
object

Responses

Request samples

Content type
application/json
{
  • "ApiKey": "api_123456789",
  • "Request": {
    }
}

Response samples

Content type
application/json
Example
{}

Returns

Create return

Create a return with requested values.

Request Body schema: application/json
required
One of
ApiKey
required
string

Client API key

required
object

Responses

Request samples

Content type
application/json
Example
{
  • "ApiKey": "api_123456789",
  • "Request": {
    }
}

Response samples

Content type
application/json
Example
{
  • "Success": {
    }
}

Search returns

Find returns records with requested filters.

Request Body schema: application/json
required
ApiKey
required
string

Client API key

required
object

Responses

Request samples

Content type
application/json
{
  • "ApiKey": "api_123456789",
  • "Request": {
    }
}

Response samples

Content type
application/json
Example
{
  • "Success": {
    }
}

Get return

Find a single return by requested values.

Request Body schema: application/json
required
ApiKey
required
string

Client API key

required
object

Responses

Request samples

Content type
application/json
{
  • "ApiKey": "api_123456789",
  • "Request": {
    }
}

Response samples

Content type
application/json
Example
{
  • "Success": {
    }
}

Get returns by filters

Search returns by requested filters.

This method allows you to get up to 1000 returns records at once, while the get return method will always find a single record.

Please consider using get return if you need to get one record, as it will perform faster.

Keep in mind, this method doesn't return the label field.

Request Body schema: application/json
required
ApiKey
required
string

Client API key

required
object

Responses

Request samples

Content type
application/json
{
  • "ApiKey": "api_123456789",
  • "Request": {
    }
}

Response samples

Content type
application/json
Example
{
  • "Success": {
    }
}

Cancel return

Cancel returning requested order

Request Body schema: applicaiton/json
required
ApiKey
required
string

Client API key

required
object

Either externalId or tracking is required. If both are provided, then a result must match both.

Responses

Request samples

Content type
applicaiton/json
{
  • "ApiKey": "api_123456789",
  • "Request": {
    }
}

Response samples

Content type
application/json
Example
{
  • "Success": {
    }
}

Tracking

Get tracking

Return tracking records for single return

Request Body schema: application/json
required
ApiKey
required
string

Client API key

required
object

Responses

Request samples

Content type
application/json
{
  • "ApiKey": "api_123456789",
  • "Request": {
    }
}

Response samples

Content type
application/json
Example
{
  • "Success": {
    }
}

Get tracking events by date range

Return tracking records by requested date range

Request Body schema: application/json
required
ApiKey
required
string

Client API key

required
object

Responses

Request samples

Content type
application/json
{
  • "ApiKey": "api_123456789",
  • "Request": {
    }
}

Response samples

Content type
application/json
Example
{
  • "Success": {
    }
}

Get tracking events by date added range

Return tracking records by requested date added range

Request Body schema: application/json
required
ApiKey
required
string

Client API key

required
object

Responses

Request samples

Content type
application/json
{
  • "ApiKey": "api_123456789",
  • "Request": {
    }
}

Response samples

Content type
application/json
Example
{
  • "Success": {
    }
}

Add tracking event

Add tracking event with requested data.

Request Body schema: application/json
required
ApiKey
required
string

Client API key

required
object

Responses

Request samples

Content type
application/json
{
  • "ApiKey": "api_123456789",
  • "Request": {
    }
}

Response samples

Content type
application/json
Example
{
  • "Success": {
    }
}

Availability

Check availability

Check API availability

The POST request body will be ignored and may be passed empty. No authorization required.

Request Body schema: application/json
optional
any or null (CheckAvailabilityRequest)

Responses

Request samples

Content type
application/json
null

Response samples

Content type
application/json
Example
{
  • "Success": {
    }
}

Code Examples

Create order method example

Create order method

<?php

$apiKey = 'demoApiKey';
$order = getOrder();

$apiBaseUrl = getApiEndpoint('PRODUCTION');
$apiMethod = 'orders/create';
$requestFormat = 'json';
$apiEndpoint = buildApiEndpoint($apiBaseUrl, $apiMethod, $requestFormat);

$requestData = [
    'ApiKey' => $apiKey,
    'Request' => json_encode(['Order' => $order]),
];
try {
    $apiResponse = makeCurlPostRequest($apiEndpoint, $requestData);
} catch (Exception $exception) {
    die('cURL exception occurred. Details: ' . $exception->getMessage() . ' Error code: ' . $exception->getCode());
}

handleCreateOrderResponse($apiResponse);

/* METHOD DEFINITIONS BELOW */

function handleCreateOrderResponse($apiResponse)
{
    $response = json_decode($apiResponse, true);
    if (null === $response || false === $response) {
        die('The response is not a JSON format. Original response: ' . $apiResponse);
    }

    if (!empty($response['success'])) {
        $orderId = $response['success']['orderId'];
        die('Order successfully created! Order ID: ' . $orderId);
    }

    if (!empty($response['error'])) {
        // Order was not created.
        $errorCode = $response['error']['code'];
        $messages = $response['error']['message'];
        die('Error code: ' . $errorCode . '. Messages: ' . implode("\r\n", $messages));
    }

    die('Unknown response format.');
}

function makeCurlPostRequest($apiEndpoint, $requestData)
{
    $payload = json_encode($requestData);
    $ch = curl_init($apiEndpoint);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

    $result = curl_exec($ch);
    if ($result === false) {
        // cURL error
        throw new \RuntimeException(curl_error($ch), curl_errno($ch));
    }
    curl_close($ch);

    return $result;
}

function buildApiEndpoint($apiBaseUrl, $apiMethod, $format)
{
    return $apiBaseUrl . '/' . $apiMethod . '/' . $format;
}

function getApiEndpoint($environment)
{
    if ($environment === 'SANDBOX') {
        return 'http://staging.returns-dg.xmlshop.dev/api';
    }

    return 'http://returns.dgapi.app/api';
}

function getOrder()
{
    return [
        'OrderReference' => 'REF10000000001',
        'OrderDate' => '10/20/2019',
        'Rma' => '12345',
        'Name' => 'John Smith',
        'Company' => '',
        'AddressLine1' => '6 Semaphore Close Mount Pleasant',
        'AddressLine2' => '',
        'AddressLine3' => 'Christchurch',
        'Zip' => '8081',
        'State' => 'qwe',
        'Country' => 'NZ',
        'Phone' => '+102030405060',
        'Email' => 'john.smith@googlemail.com',
        'Currency' => 'AUD',
        'ExportAwb' => '32153454GB',
        'ExportCarrierName' => 'USPS',
        'Products' => [
            [
                'Sku' => 'QWE123',
                'Description' => 'Black Sculpting & Smoothing Shapewear Body Suit-EUR 38 (M)',
                'Quantity' => '5',
                'Price' => '100',
                'Weight' => '1',
                'Length' => '2',
                'Width' => '3',
                'Height' => '4',
                'DimensionsUom' => 'mm',
                'HsCode' => '',
                'CountryCode' => 'GB',
                'ImgUrl' => '',
            ],
            [
                'Sku' => 'QWE456',
                'Description' => 'Black Halterneck Corset',
                'Quantity' => '10',
                'Price' => '200',
                'Weight' => '0.86',
                'Length' => '0',
                'Width' => '0',
                'Height' => '0',
                'DimensionsUom' => 'mm',
                'HsCode' => '',
                'CountryCode' => 'GB',
                'ImgUrl' => '',
            ],
        ],
    ];
}

Check availability method example

Check availability

<?php

$apiKey = 'demoApiKey';

$apiBaseUrl = getApiEndpoint('PRODUCTION');
$apiMethod = 'check/available';
$requestFormat = 'json';
$apiEndpoint = buildApiEndpoint($apiBaseUrl, $apiMethod, $requestFormat);

try {
    $apiResponse = makeCurlPostRequest($apiEndpoint);
} catch (Exception $exception) {
    die('cURL exception occurred. Details: ' . $exception->getMessage() . ' Error code: ' . $exception->getCode());
}

handleCheckAvailableResponse($apiResponse);

function handleCheckAvailableResponse($apiResponse)
{
    $response = json_decode($apiResponse, true);

    if ($response === null) {
        die('The response is not a JSON format. Original response: ' . $apiResponse);
    }

    if (!empty($response['Success'])) {
        if (!empty($response['Success']['Date'])) {
            die('Ok. Service is available.');
        }

        // Check the online documentation here https://localhost/api/
        var_dump($response);
        die('Wrong response format.');
    }

    if (!empty($response['Error'])) {
        // API temporarily unavailable
        $errorCode = $response['Error']['Code'];
        $messages = $response['Error']['Message'];
        die('Error code: ' . $errorCode . '. Messages: ' . implode("\r\n", $messages));
    }

    // Check the online documentation here https://localhost/api/
    var_dump($response);
    die('Unknown response format.');
}

function makeCurlPostRequest($apiEndpoint)
{
    $ch = curl_init($apiEndpoint);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HEADER, true);

    $result = curl_exec($ch);

    if ($result === false) {
        // cURL error
        throw new \RuntimeException(curl_error($ch), curl_errno($ch));
    }

    $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);

    if ($httpCode !== 200) {
        throw new \RuntimeException('API temporarily unavailable.', $httpCode);
    }

    return $result;
}

function buildApiEndpoint($apiBaseUrl, $apiMethod, $format)
{
    return $apiBaseUrl . '/' . $apiMethod . '/' . $format;
}

function getApiEndpoint($environment)
{
    if ($environment === 'SANDBOX') {
        return 'http://staging.returns-dg.xmlshop.dev/api';
    }

    return 'http://returns.dgapi.app/api';
}

Webhooks

Info

This part of API describes requests that your server should accept and responses that your server should return to implement webhooks support. You can configure the urls for each type of webhook in admin panel.

Authentication

Each request will contain header X-Hmac-Sha256-Signature with HMAC-SHA256 signature of the request body.

Your API key will be used as a secret.

Return updated Webhook

We'll send this request each time return status is updated.

header Parameters
X-Hmac-Sha256-Signature
string

HMAC-SHA256 signature of the request body with API key as a secret

Request Body schema: application/json
required
name
string
company_name
string
email
string
phone
string
zip
string
addr1
string
addr2
string
addr3
string
city
string
state
string
country
string (CountryCode) = 2 characters
Enum: "AF" "AX" "AL" "DZ" "AS" "AD" "AO" "AI" "AQ" "AG" "AR" "AM" "AW" "AU" "AT" "AZ" "BS" "BH" "BD" "BB" "BY" "BE" "BZ" "BJ" "BM" "BT" "BO" "BQ" "BA" "BW" "BV" "BR" "IO" "BN" "BG" "BF" "BI" "KH" "CM" "CA" "CV" "KY" "CF" "TD" "CL" "CN" "CX" "CC" "CO" "KM" "CG" "CD" "CK" "CR" "CI" "HR" "CU" "CW" "CY" "CZ" "DK" "DJ" "DM" "DO" "EC" "EG" "SV" "GQ" "ER" "EE" "ET" "FK" "FO" "FJ" "FI" "FR" "GF" "PF" "TF" "GA" "GM" "GE" "DE" "GH" "GI" "GR" "GL" "GD" "GP" "GU" "GT" "GG" "GN" "GW" "GY" "HT" "HM" "VA" "HN" "HK" "HU" "IS" "IN" "ID" "IR" "IQ" "IE" "IM" "IL" "IT" "JM" "JP" "JE" "JO" "KZ" "KE" "KI" "KP" "KR" "KW" "KG" "LA" "LV" "LB" "LS" "LR" "LY" "LI" "LT" "LU" "MO" "MK" "MG" "MW" "MY" "MV" "ML" "MT" "MH" "MQ" "MR" "MU" "YT" "MX" "FM" "MD" "MC" "MN" "ME" "MS" "MA" "MZ" "MM" "NA" "NR" "NP" "NL" "NC" "NZ" "NI" "NE" "NG" "NU" "NF" "MP" "NO" "OM" "PK" "PW" "PS" "PA" "PG" "PY" "PE" "PH" "PN" "PL" "PT" "PR" "QA" "RE" "RO" "RU" "RW" "BL" "SH" "KN" "LC" "MF" "PM" "VC" "WS" "SM" "ST" "SA" "SN" "RS" "SC" "SL" "SG" "SX" "SK" "SI" "SB" "SO" "ZA" "GS" "SS" "ES" "LK" "SD" "SR" "SJ" "SZ" "SE" "CH" "SY" "TW" "TJ" "TZ" "TH" "TL" "TG" "TK" "TO" "TT" "TN" "TR" "TM" "TC" "TV" "UG" "UA" "AE" "GB" "US" "UM" "UY" "UZ" "VU" "VE" "VN" "VG" "VI" "WF" "EH" "YE" "ZM" "ZW"
id
integer

Internal return ID

tracking
string

Tracking number

string or integer

The time the tracking data was last updated

current_tracking_status
integer (TrackingStatus)

Tracking status. See docs

barcode_number
string

Barcode value on label

order_reference
string

Order reference

string or integer

The time return was added to the system

display_id
string

An additional information, which will be displayed on the shipping label (if it is possible). Order reference by default

service_id
integer

Internal service identifier

carrier
string

Carrier name

Array of objects (ReturnItemWebhook)

Items of return. Can be empty

object

Custom fields

event_type
string
Value: "return_updated"

Type of the webhook event

Array of objects (TrackingEventWebhook)

Tracking events list

object (OrderWebhook)

Order object

string or integer

The time webhook is dispatched

Responses

Request samples

Content type
application/json
{
  • "name": "Jane Doe",
  • "company_name": "ACME corp.",
  • "email": "jane@example.org",
  • "phone": 1234567890,
  • "zip": "W1W 7PA",
  • "addr1": "33 Great Titchfield St",
  • "addr2": "3rd floor",
  • "addr3": "string",
  • "city": "London",
  • "state": "England",
  • "country": "NL",
  • "id": 123456789,
  • "tracking": "HZ962130067GB",
  • "tracking_last_update": "1611665973",
  • "current_tracking_status": "20",
  • "barcode_number": "HZ962130067GB001234777493",
  • "order_reference": "REF123456789",
  • "date_added": "1611665973",
  • "display_id": "REF123456789",
  • "service_id": 252,
  • "carrier": "Royal Mail",
  • "item": [
    ],
  • "custom_fields": {
    },
  • "event_type": "return_updated",
  • "events": [
    ],
  • "order": {
    },
  • "current_timestamp": 1611665973
}