The following API is designed to provide a complete set of tools to integrate with the ProCarrier Returns
The following API is designed to provide a complete set of tools to integrate with the system.
| 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. |
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.
Create an order with requested values.
| ApiKey required | string Client API key |
required | object |
{- "ApiKey": "api_123456789",
- "Request": {
- "Order": {
- "OrderReference": "REF123456789",
- "OrderDate": "11/22/2020",
- "Currency": "EUR",
- "Rma": "N123456789",
- "FreeReturn": false,
- "Company": "ExampleCompanyName",
- "CustomFields": { },
- "ExportDate": "03/22/2024",
- "ExportAwb": "32153454NL",
- "ExportCarrierName": "Radar",
- "TrackingNumber": "32153454NL",
- "InvoiceNumber": "X1234567890",
- "ExportMRN": "",
- "Products": [
- {
- "Sku": "SKU123456789",
- "Description": "Black short pants",
- "Quantity": 1,
- "Price": 9.99,
- "Weight": 5,
- "WeightUom": "kg",
- "Length": 5,
- "Width": 3.14,
- "Height": 2.7,
- "DimensionsUom": "cm",
- "CountryCode": "string",
- "HsCode": "HS4331767",
- "DangerousGoods": "No",
- "ExportDate": 1606050093,
- "ExportAwb": "32153454NL",
- "ExportCarrierName": "Radar",
- "NonReturnable": false,
- "DaysForReturn": 30,
- "CustomFields": { }
}
], - "Name": "John Smith",
- "Phone": "+10123456789",
- "Email": "example@example.com",
- "Country": "NL",
- "State": "Amsterdam",
- "Zip": "1012 DP",
- "City": "Amsterdam",
- "AddressLine1": "Oudezijds Achterburgwal 60h",
- "AddressLine2": "string",
- "AddressLine3": "string",
- "Neighborhood": "Pilsen"
}
}
}{- "Success": {
- "Message": "Order successfully created",
- "OrderReference": "REF123456789",
- "OrderId": 123456
}
}Update an order with requested values.
| ApiKey required | string Client API key |
required | object |
{- "ApiKey": "api_123456789",
- "Request": {
- "Order": {
- "Id": 12345,
- "OrderReference": "REF123456789",
- "OrderDate": "11/22/2020",
- "Currency": "EUR",
- "Rma": "N123456789",
- "FreeReturn": false,
- "Company": "ExampleCompanyName",
- "ExportDate": "03/22/2024",
- "ExportAwb": "32153454NL",
- "ExportCarrierName": "Radar",
- "TrackingNumber": "32153454NL",
- "InvoiceNumber": "X1234567890",
- "IxportMRN": "",
- "Products": [
- {
- "Id": 12345,
- "Sku": "SKU123456789",
- "Description": "Black short pants",
- "Price": 9.99,
- "HsCode": "HS4331767",
- "Quantity": 1,
- "Weight": 5,
- "WeightUom": "kg",
- "Length": 5,
- "Width": 3.14,
- "Height": 2.7,
- "DimensionsUom": "cm",
- "CountryCode": "string",
- "DangerousGoods": "No",
- "ExportDate": 1606050093,
- "ExportAwb": "32153454NL",
- "ExportCarrierName": "Radar",
- "NonReturnable": false,
- "DaysForReturn": 30
}
], - "Name": "John Smith",
- "Phone": "+10123456789",
- "Email": "example@example.com",
- "Country": "NL",
- "State": "Amsterdam",
- "Zip": "1012 DP",
- "City": "Amsterdam",
- "AddressLine1": "Oudezijds Achterburgwal 60h",
- "AddressLine2": "string"
}
}
}{- "success": {
- "message": "Order successfully updated",
- "orderReference": "REF123456789",
- "orderId": 123456
}
}Fetch order by requested field/value pair.
| ApiKey required | string Client API key |
required | object |
{- "ApiKey": "api_123456789",
- "Request": {
- "Order": {
- "Field": "reference",
- "Value": "REF123456789"
}
}
}{- "Success": {
- "OrderReference": "REF123456789",
- "OrderDate": "11/22/2020",
- "Currency": "EUR",
- "Rma": "N123456789",
- "FreeReturn": false,
- "Company": "ExampleCompanyName",
- "CustomFields": { },
- "ExportDate": "03/22/2024",
- "ExportAwb": "32153454NL",
- "ExportCarrierName": "Radar",
- "TrackingNumber": "32153454NL",
- "InvoiceNumber": "X1234567890",
- "ExportMRN": "",
- "Products": [
- {
- "Sku": "SKU123456789",
- "Description": "Black short pants",
- "Quantity": 1,
- "Price": 9.99,
- "Weight": 5,
- "WeightUom": "kg",
- "Length": 5,
- "Width": 3.14,
- "Height": 2.7,
- "DimensionsUom": "cm",
- "CountryCode": "string",
- "HsCode": "HS4331767",
- "DangerousGoods": "No",
- "ExportDate": 1606050093,
- "ExportAwb": "32153454NL",
- "ExportCarrierName": "Radar",
- "NonReturnable": false,
- "DaysForReturn": 30,
- "CustomFields": { }
}
], - "Name": "John Smith",
- "Phone": "+10123456789",
- "Email": "example@example.com",
- "Country": "NL",
- "State": "Amsterdam",
- "Zip": "1012 DP",
- "City": "Amsterdam",
- "AddressLine1": "Oudezijds Achterburgwal 60h",
- "AddressLine2": "string",
- "AddressLine3": "string",
- "Neighborhood": "Pilsen"
}
}Delete order by requested field/value pair.
| ApiKey required | string Client API key |
required | object |
{- "ApiKey": "api_123456789",
- "Request": {
- "Order": {
- "Field": "reference",
- "Value": "REF123456789"
}
}
}{- "Success": {
- "Message": "Order successfully deleted"
}
}Search orders by requested parameters.
| ApiKey required | string Client API key |
required | object |
{- "ApiKey": "api_123456789",
- "Request": {
- "Filter": {
- "DateFrom": "2020/11/11 10:11:12",
- "DateTo": "2020/11/22 10:11:12",
- "FullTextSearch": "REF123456789 TRC123456789"
}
}
}{- "Success": {
- "Id": [
- 10,
- 12,
- 34,
- 56,
- 59,
- 72,
- 81,
- 93
]
}
}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.
| 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 |
Return drop off points information.
| ApiKey required | string Client API key |
required | object |
{- "ApiKey": "api_123456789",
- "Request": {
- "Request": {
- "Services": [
- 1,
- 2,
- 3
], - "Address": {
- "Country": "NL",
- "State": "Amsterdam",
- "Zip": "1012 DP",
- "City": "Amsterdam",
- "AddressLine1": "Oudezijds Achterburgwal 60h",
- "AddressLine2": "string",
- "AddressLine3": "string",
- "Neighborhood": "Pilsen"
}, - "Coordinates": {
- "Lat": "52.372987",
- "Lng": 4.894087
}, - "Radius": 10
}
}
}{- "Success": {
- "Carriers": [
- {
- "Id": 1,
- "Name": "Radar",
- "Services": [
- {
- "Id": 2,
- "Name": "Radar drop off service",
- "Points": [
- {
- "Id": "123AC",
- "Title": "Radar drop off",
- "AddressDetail": {
- "Country": "NL",
- "State": "Amsterdam",
- "Zip": "1012 DP",
- "City": "Amsterdam",
- "AddressLine1": "Oudezijds Achterburgwal 60h",
- "AddressLine2": "string",
- "AddressLine3": "string",
- "Neighborhood": "Pilsen"
}, - "Hours": "monday-saturday 10:00-14:00 monday-friday 17:00-20:30",
- "DetailHours": {
- "Mo": [
- "10:00-14:00",
- "17:00-20:30"
], - "Tu": [
- "10:00-14:00",
- "17:00-20:30"
], - "We": [
- "10:00-14:00",
- "17:00-20:30"
], - "Th": [
- "10:00-14:00",
- "17:00-20:30"
], - "Fr": [
- "09:00-15:00",
- "17:00-20:30"
], - "Sa": [
- "10:00-14:00",
- "17:00-20:30"
], - "Su": false
}, - "Lat": "52.372987",
- "Lng": 4.894087
}
],
}
]
}
]
}
}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": {}
}
| ApiKey required | string Client API key |
required | object |
{- "ApiKey": "api_123456789",
- "Request": {
- "Service": {
- "Country": "NL",
- "State": "Amsterdam",
- "Zip": "1012 DP",
- "City": "Amsterdam",
- "AddressLine1": "Oudezijds Achterburgwal 60h",
- "AddressLine2": "string",
- "AddressLine3": "string",
- "Neighborhood": "Pilsen"
}, - "Parcel": {
- "Weight": 35
}
}
}{- "Success": {
- "Services": [
- {
- "Carrier": "string",
- "ServiceId": 1,
- "ServiceName": "Radar",
- "ServiceType": "home_collection",
- "ServiceLogo": "string",
- "CommercialService": {
- "Name": "string",
- "BillingCode": "string"
}, - "LocalCarrier": {
- "Name": "string",
- "Logo": "string",
- "PudoLocatorUrl": "string"
}
}
]
}
}Create a return with requested values.
| ApiKey required | string Client API key |
required | object |
{- "ApiKey": "api_123456789",
- "Request": {
- "Return": {
- "Country": "NL",
- "State": "Amsterdam",
- "Zip": "1012 DP",
- "City": "Amsterdam",
- "AddressLine1": "Oudezijds Achterburgwal 60h",
- "AddressLine2": "string",
- "AddressLine3": "string",
- "Neighborhood": "Pilsen",
- "Name": "John Smith",
- "Company": "Apple Inc.",
- "Phone": "+10123456789",
- "Email": "example@example.com",
- "ServiceId": 201,
- "ServiceTrackable": true,
- "OrderReference": "string",
- "OrderReference2": "string",
- "DateAdded": 1606050093,
- "Currency": "EUR",
- "DisplayId": "D123456789",
- "ExternalId": "E123456789",
- "DangerousGoods": "Yes",
- "FinalDisposition": "return",
- "CollectionDate": {
- "date": "2020/11/22",
- "timeFrom": "10:00",
- "timeTo": "15:30"
}, - "SpecialInstruction": "string",
- "Order": {
- "exportDate": "02/22/2024",
- "trackingNumber": "string",
- "invoiceNumber": "string",
- "exportMRN": ""
}, - "Products": [
- {
- "Sku": "SKU123456789",
- "Description": "Black short pants",
- "Quantity": 1,
- "Price": 9.99,
- "Weight": 5,
- "WeightUom": "kg",
- "Length": 5,
- "Width": 3.14,
- "Height": 2.7,
- "DimensionsUom": "cm",
- "CountryCode": "string",
- "HsCode": "HS4331767",
- "DangerousGoods": "No",
- "ExportDate": 1606050093,
- "ExportAwb": "32153454NL",
- "ExportCarrierName": "Radar",
- "FinalDisposition": "return",
- "CustomFields": { },
- "Reason": {
- "Action": "Exchange",
- "Reason": "Does not suit me",
- "Wish": "",
- "Additional": {
- "Title": "Some title",
- "Value": "Some text"
}
}
}
], - "Lang": "string",
- "LabelFormat": "pdf",
- "TrackingNumber": "string",
- "SecondaryBarcodes": [
- "string"
], - "PreAdvisedCarrierName": "string",
- "Destination": {
- "Address": {
- "Country": "string",
- "State": "string",
- "Zip": "string",
- "City": "string",
- "AddressLine1": "string",
- "AddressLine2": "string"
}, - "Contact": {
- "Name": "string",
- "Company": "string",
- "Phone": "string",
- "Email": "string"
}
}
}
}
}{- "Success": {
- "TrackingNumber": "TRC123456789",
- "FirstMileAddress": {
- "AddressLine1": "Oudezijds Achterburgwal 60h",
- "AddressLine2": "",
- "City": "Amsterdam",
- "Zip": "1012 DP",
- "State": "Amsterdam",
- "Country": "NL"
}, - "SecondaryBarcode": null,
- "SecondaryBarcodes": [
- "sec_526u8we",
- "202312041045347716",
- "3SZXSA3238793"
], - "LabelContentYype": "application/pdf",
- "LabelImage": "JVBERi0xLjcKCjEgMCBvYmogICUgZW5..."
}
}Find returns records with requested filters.
| ApiKey required | string Client API key |
required | object |
{- "ApiKey": "api_123456789",
- "Request": {
- "Filter": {
- "DateFrom": "2020/11/11 10:11:12",
- "DateTo": "2020/11/22 10:11:12",
- "FullTextSearch": "REF123456789 TRC123456789",
- "TrackingNumber": "TRC123456789",
- "OrderReference": "REF123456789"
}
}
}{- "Success": {
- "Id": [
- [
- 351,
- 373,
- 409
]
]
}
}Find a single return by requested values.
| ApiKey required | string Client API key |
required | object |
{- "ApiKey": "api_123456789",
- "Request": {
- "Return": {
- "Value": "REF123456789",
- "Field": "orderReference",
- "LabelFormat": "pdf"
}
}
}{- "Success": {
- "Id": 123456789,
- "LabelContentType": "application/pdf",
- "LabelImage": "JVBERi0xLjcKCjEgMCBvYmogICUgZW5...",
- "OrderReference": "REF123456789",
- "DateAdded": "11/22/2020 13:01:33",
- "DisplayId": "REF123456789",
- "Carrier": "Radar",
- "ExportDate": 1606050093,
- "ExportAwb": "32153454NL",
- "ExportCarrierName": "Radar",
- "Products": [
- {
- "Sku": "SKU123456789",
- "Description": "Black short pants",
- "Quantity": 1,
- "Price": 9.99,
- "Weight": 5,
- "WeightUom": "kg",
- "Length": 5,
- "Width": 3.14,
- "Height": 2.7,
- "DimensionsUom": "cm",
- "CountryCode": "string",
- "HsCode": "HS4331767",
- "DangerousGoods": "No",
- "ExportDate": 1606050093,
- "ExportAwb": "32153454NL",
- "ExportCarrierName": "Radar",
- "FinalDisposition": "return",
- "CustomFields": { },
- "Reason": {
- "Action": "Exchange",
- "Reason": "Does not suit me",
- "Wish": "",
- "Additional": {
- "Title": "Some title",
- "Value": "Some text"
}
}
}
], - "CustomFields": { },
- "Phone": "+10123456789",
- "Email": "example@example.com",
- "TrackingNumber": "TRC123456789",
- "TrackingLastUpdate": 1606050093,
- "CurrentTrackingStatus": 40,
- "Country": "NL",
- "State": "Amsterdam",
- "Zip": "1012 DP",
- "City": "Amsterdam",
- "AddressLine1": "Oudezijds Achterburgwal 60h",
- "AddressLine2": "string",
- "AddressLine3": "string",
- "Neighborhood": "Pilsen",
- "Name": "John Smith",
- "Company": "Apple Inc."
}
}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.
| ApiKey required | string Client API key |
required | object |
{- "ApiKey": "api_123456789",
- "Request": {
- "Filter": {
- "DateFrom": "2020/11/11 10:11:12",
- "DateTo": "2020/11/22 10:11:12",
- "FullTextSearch": "REF123456789 TRC123456789",
- "OrderReference": "REF123456789",
- "Status": 303,
- "CurrentTrackingStatus": 40,
- "ServiceId": 1,
- "Country": "NL",
- "IdLast": 123
}
}
}{- "Success": {
- "Total": 1,
- "Return": [
- {
- "Id": 123456789,
- "OrderReference": "REF123456789",
- "DateAdded": "11/22/2020 13:01:33",
- "DisplayId": "REF123456789",
- "Carrier": "Radar",
- "ExportDate": 1606050093,
- "ExportAwb": "32153454NL",
- "ExportCarrierName": "Radar",
- "Products": [
- {
- "Sku": "SKU123456789",
- "Description": "Black short pants",
- "Quantity": 1,
- "Price": 9.99,
- "Weight": 5,
- "WeightUom": "kg",
- "Length": 5,
- "Width": 3.14,
- "Height": 2.7,
- "DimensionsUom": "cm",
- "CountryCode": "string",
- "HsCode": "HS4331767",
- "DangerousGoods": "No",
- "ExportDate": 1606050093,
- "ExportAwb": "32153454NL",
- "ExportCarrierName": "Radar",
- "FinalDisposition": "return",
- "CustomFields": { },
- "Reason": {
- "Action": "Exchange",
- "Reason": "Does not suit me",
- "Wish": "",
- "Additional": {
- "Title": "Some title",
- "Value": "Some text"
}
}
}
], - "CustomFields": { },
- "Phone": "+10123456789",
- "Email": "example@example.com",
- "Country": "NL",
- "State": "Amsterdam",
- "Zip": "1012 DP",
- "City": "Amsterdam",
- "AddressLine1": "Oudezijds Achterburgwal 60h",
- "AddressLine2": "string",
- "AddressLine3": "string",
- "Neighborhood": "Pilsen",
- "Name": "John Smith",
- "Company": "Apple Inc."
}
]
}
}Cancel returning requested order
| ApiKey required | string Client API key |
required | object Either |
{- "ApiKey": "api_123456789",
- "Request": {
- "Return": {
- "ExternalId": "A123456789",
- "TrackingNumber": "TRC123456789"
}
}
}{- "Success": {
- "Result": {
- "Message": "Return cancel requested",
- "TrackingNumber": "TRC123456789",
- "ExternalId": "A123456789",
- "Status": "Return cancel requested"
}
}
}Return tracking records for single return
| ApiKey required | string Client API key |
required | object |
{- "ApiKey": "api_123456789",
- "Request": {
- "TrackingNumber": {
- "Code": "TRC123456789"
}
}
}{- "Success": {
- "Id": 173582722,
- "PalletNumber": "PLTRC123456789",
- "SourceCountry": "NL",
- "CarrierName": "Radar",
- "ServiceId": 2,
- "ExternalId": "N123456789",
- "OrderReference": "REF123456789",
- "TrackingNumber": "TRC123456789",
- "SecondaryBarcode": "SEC_TRC123456789",
- "Events": [
- {
- "Id": 347109300,
- "Dt": 1606050093,
- "Status": 10,
- "Description": "Return registered online",
- "Location": {
- "Country": "NL",
- "State": "AM",
- "City": "Amsterdam"
}
}
]
}
}Return tracking records by requested date range
| ApiKey required | string Client API key |
required | object |
{- "ApiKey": "api_123456789",
- "Request": {
- "Filter": {
- "LastId": 347109299,
- "DateFrom": "2020/11/11 10:11:12",
- "DateTo": "2020/11/22 10:11:12",
- "SourceCountry": "NL",
- "Page": 3,
- "CountPerPage": 15000
}
}
}{- "Success": {
- "TrackingData": [
- {
- "Id": 173582722,
- "PalletNumber": "PLTRC123456789",
- "SourceCountry": "NL",
- "CarrierName": "Radar",
- "ServiceId": 2,
- "ExternalId": "N123456789",
- "OrderReference": "REF123456789",
- "TrackingNumber": "TRC123456789",
- "SecondaryBarcode": "SEC_TRC123456789",
- "Events": [
- {
- "Id": 347109300,
- "Dt": 1606050093,
- "Status": 10,
- "Description": "Return registered online",
- "Location": {
- "Country": "NL",
- "State": "AM",
- "City": "Amsterdam"
}
}
]
}
], - "TotalEventsCount": 6,
- "CurrentPage": 1,
- "TotalPagesCount": 1,
- "CountPerPage": 20000
}
}Return tracking records by requested date added range
| ApiKey required | string Client API key |
required | object |
{- "ApiKey": "api_123456789",
- "Request": {
- "Filter": {
- "LastId": 347109299,
- "DateFrom": "2020/11/11 10:11:12",
- "DateTo": "2020/11/22 10:11:12",
- "SourceCountry": "NL",
- "Page": 3,
- "CountPerPage": 15000
}
}
}{- "Success": {
- "TrackingData": [
- {
- "Id": 173582722,
- "PalletNumber": "PLTRC123456789",
- "SourceCountry": "NL",
- "CarrierName": "Radar",
- "ServiceId": 2,
- "ExternalId": "N123456789",
- "OrderReference": "REF123456789",
- "TrackingNumber": "TRC123456789",
- "SecondaryBarcode": "SEC_TRC123456789",
- "Events": [
- {
- "Id": 347109300,
- "Dt": 1606050093,
- "Status": 10,
- "Description": "Return registered online",
- "Location": {
- "Country": "NL",
- "State": "AM",
- "City": "Amsterdam"
}, - "DateAdded": 1606050093
}
]
}
], - "TotalEventsCount": 6,
- "CurrentPage": 1,
- "TotalPagesCount": 1,
- "CountPerPage": 20000
}
}Add tracking event with requested data.
| ApiKey required | string Client API key |
required | object |
{- "ApiKey": "api_123456789",
- "Request": {
- "TrackingStatus": {
- "TrackingNumber": "TRC123456789",
- "Date": "2020/11/22 11:22:33",
- "Status": 70,
- "DateAdded": "2020/11/22 11:22:33",
- "Description": "Some tracking event description",
- "CarrierStatus": "TRC_CARRIER_STATUS",
- "Location": {
- "Country": "NL",
- "State": "AM",
- "City": "Amsterdam"
}
}
}
}{- "Success": {
- "Code": "success",
- "Message": [
- "Return REF123456789 updated successfully"
]
}
}Check API availability
The POST request body will be ignored and may be passed empty. No authorization required.
null{- "Success": {
- "Date": 1606050093
}
}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' => '',
],
],
];
}
<?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';
}
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.
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.
We'll send this request each time return status is updated.
| X-Hmac-Sha256-Signature | string HMAC-SHA256 signature of the request body with API key as a secret |
| name | string |
| company_name | string |
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 |
{- "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": [
- {
- "sku_code": "SKU123456789",
- "sku_desc": "Black short pants",
- "quantity": "1",
- "price": "9.99",
- "weight": "5",
- "weight_uom": "kg",
- "length": "5",
- "width": "3.14",
- "height": "2.7",
- "dimensions_uom": "cm",
- "country_code": "GB",
- "hs_code": "HS4331767",
- "dangerous_goods": "No",
- "export_date": "1606050093",
- "export_awb": "32153454ABC",
- "export_carrier_name": "Royal Mail",
- "final_disposition": "return",
- "custom_fields": {
- "field1": "string",
- "field2": "string",
- "field3": "string",
- "field4": "string",
- "field5": "string"
}, - "reason": [
- {
- "action": "Exchange",
- "reason": "Does not suit me",
- "wish": "",
- "additional": {
- "title": "Some title",
- "value": "Some text"
}
}
]
}
], - "custom_fields": {
- "field1": "string",
- "field2": "string",
- "field3": "string",
- "field4": "string",
- "field5": "string"
}, - "event_type": "return_updated",
- "events": [
- {
- "dt": 1606050093,
- "status": "20",
- "location": {
- "country": "GB",
- "state": "England",
- "city": "London"
}
}
], - "order": {
- "contact_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",
- "order_reference": "REF123456789",
- "order_date": "1611665973",
- "currency_code": "EUR",
- "rma": "R123456789",
- "free_return": "false",
- "custom_fields": {
- "Whatever": "Value for custom field1",
- "Anything": "Value for custom field2"
}, - "export_date": 1606050093,
- "export_awb": "32153454ABC",
- "export_carrier_name": "Royal Mail",
- "item": [
- {
- "sku_code": "SKU123456789",
- "sku_desc": "Black short pants",
- "quantity": "1",
- "price": "9.99",
- "weight": "5",
- "weight_uom": "kg",
- "length": "5",
- "width": "3.14",
- "height": "2.7",
- "dimensions_uom": "cm",
- "country_code": "GB",
- "hs_code": "HS4331767",
- "dangerous_goods": "No",
- "export_date": "1606050093",
- "export_awb": "32153454ABC",
- "export_carrier_name": "Royal Mail",
- "non_returnable": "false",
- "days_for_return": "30",
- "custom_fields": {
- "field1": "string",
- "field2": "string",
- "field3": "string",
- "field4": "string",
- "field5": "string"
}
}
]
}, - "current_timestamp": 1611665973
}