Returns
Create Authorized Return – REST
Summary
Name: | Create Authorized Return |
---|---|
Reason to Call: | To create an authorized return that allows you to retrieve and print a return shipping label that can be sent (either physically or electronically) to a shopper. |
Input: | Shipment input information including return address (both sender and receiver) and parcel characteristics (e.g. dimensions, weight) |
Output: | Pointers to artifact to allow label to be printed. |
Error Example: | Errors in address or parcel characteristics. |
Typical Next Call: | Get Artifact to retrieve the return shipping label. |
Version history: | Release notes |
Request Details
Request – Structure for Create Authorized Return
Endpoint
POST https://XX/rs/{mailed by customer}/{mobo}/authorizedreturn |
|
---|---|
Replace... | With... |
XX (Development) |
ct.soa-gw.canadapost.ca |
XX (Production) |
soa-gw.canadapost.ca |
{mailed by customer} |
your customer number |
{mobo} |
the mailed on behalf of customer number or repeat your customer number |
HTTP Headers
HTTP Header Variable |
Value |
---|---|
Accept |
application/vnd.cpc.authreturn-v2+xml (Note: */* in place of the header value will return an error) |
Content-Type |
application/vnd.cpc.authreturn-v2+xml (Note: */* in place of the header value will return an error) |
Authorization |
Basic {Base64 encoding of userid:password} |
Accept-language |
en-CA or fr-CA |
Body
<?xml version="1.0" encoding="utf-8"?
>
<authorized-return xmlns=”http://www.canadapost.ca/ws/authreturn-v2”>
xxx
</authorized-return>
Request – Elements
This table describes the XML elements that make up the input to this service. The hierarchical structure of the XML inputs is shown in the Request - XML Diagram.
Create Authorized Return – Request Elements | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Element Name | Type | Required / Optional | Description | ||||||||||
authorized-return |
Complex |
Required |
This is the overall XML structure for the request input information. This structure provides a description of the return request details, including receiver, service-code, returner, parcel-characteristics and references. |
||||||||||
create-public-key |
Simple |
Optional |
{true} |
||||||||||
create-qr-code |
Simple |
(true|false) |
|||||||||||
customer-barcode |
Simple |
Optional |
(16 alphanumeric) |
||||||||||
customer-barcode-type |
Simple |
Optional |
(LINEAR|2D) |
||||||||||
box-free |
Simple |
Optional |
(true|false) if flag is present and set to ‘true, “Box-free / Sans emballage” verbiage is added on the image containing the QR code and green colored QR code is generated. Note: There are eligibility requirements for box-free returns. If items are not eligible, they will not be accepted as a box-free return at the post office. See the Parcel Services Customer Guide for more information. |
||||||||||
service-code |
Simple |
Required |
(Character string – up to 32 alphanumeric) Return labels can only be created if the shipment originates in Canada and is destined for delivery in Canada.
This is the Canada Post delivery service used for shipping the item. |
||||||||||
returner |
Complex |
Required |
This structure contains data about the sender that will appear in the “From” address of the label. Blank fields will be removed in the address formatting. |
||||||||||
name |
Simple |
Required |
(44 alphanumeric) |
||||||||||
company |
Simple |
Optional |
(44 alphanumeric) |
||||||||||
domestic-address |
Complex |
Required |
This structure contains the address data about the returner of the shipment. Blank fields will be removed in address fields for formatting the labels. |
||||||||||
address-line-1 |
Simple |
Required |
(44 alphanumeric) |
||||||||||
address-line-2 |
Simple |
Optional |
(44 alphanumeric) |
||||||||||
city |
Simple |
Required |
(40 alphanumeric) |
||||||||||
province |
Simple |
Required |
(2 characters) |
||||||||||
postal-code |
Simple |
Required |
(6-digit code in Canadian Postal Code pattern: A9A9A9) |
||||||||||
receiver |
Complex |
Required |
This structure contains data about the destination and will appear in the “To” address of the label. Blank fields will be removed in the address formatting. |
||||||||||
name |
Simple |
Required |
(44 alphanumeric) |
||||||||||
company |
Simple |
Optional |
(44 alphanumeric) |
||||||||||
Simple |
Optional |
(60 characters - must be a valid email pattern) |
|||||||||||
receiver-voice-number |
Simple |
Optional |
(Character String – up to 25 characters) |
||||||||||
domestic-address |
Complex |
Required |
Required if the corresponding parent XML element “receiver” exists. |
||||||||||
address-line-1 |
Simple |
Required |
(44 alphanumeric). |
||||||||||
address-line-2 |
Simple |
Optional |
(44 alphanumeric) |
||||||||||
city |
Simple |
Required |
(40 alphanumeric) |
||||||||||
province |
Simple |
Required |
(2 characters) |
||||||||||
postal-code |
Simple |
Required |
(6-digit code in Canadian Postal Code pattern: A9A9A9) |
||||||||||
parcel-characteristics |
Complex |
Optional |
This structure contains the information about the physical characteristics of the parcel. |
||||||||||
weight |
Simple |
Optional |
(Numeric field of pattern 3.3 e.g. 999.999) |
||||||||||
dimensions |
Complex |
Optional |
This structure contains information specifying the dimensions of a parcel. |
||||||||||
length |
Simple |
Conditionally |
(Numeric field of pattern 3.1 e.g. 999.9 pattern) |
||||||||||
width |
Simple |
Conditionally |
(Numeric field of pattern 3.1 e.g. 999.9 pattern) |
||||||||||
height |
Simple |
Conditionally |
(Numeric field of pattern 3.1 e.g. 999.9 pattern) |
||||||||||
print-preferences |
Complex |
Optional |
This structure contains print preferences for the labels. |
||||||||||
output-format |
Simple |
Optional |
(7 alphanumeric) |
||||||||||
encoding |
Simple |
Optional |
{PDF, ZPL} Use this field to specify the output format for your return label: PDF or ZPL II. If not provided, PDF will be selected by default. If you choose ZPL, the response from a Get Artifact call will include a file containing ZPL II printer commands. You will then need to either code a solution or use an application to stream the commands directly to a thermal printer. For ZPL II labels, your printer must support truncation. Use our sample code to test your printer’s ability to truncate text. ZPL is only available on thermal paper. The <output-format> must therefore be 4x6. |
||||||||||
show-packing-instructions |
Simple |
Optional |
{true, false} Defaults to True |
||||||||||
settlement-info |
Complex |
Required |
This structure is analogous to the structure from Create Shipment; however, here the contents are optional and recommended to be omitted. |
||||||||||
paid-by-customer |
Simple |
Optional |
(10-digit numeric) For future use. |
||||||||||
contract-id |
Simple |
Optional |
(10-digit numeric) For future use. |
||||||||||
references |
Complex |
Optional |
This structure contains reference fields that you can assign. These alternate (possibly unique) identification numbers are assigned to the return, and can be used for tracking or for any other purpose you deem useful. |
||||||||||
customer-ref-1 |
Simple |
Optional |
(Character string – up to 35 characters) |
||||||||||
customer-ref-2 |
Simple |
Optional |
(Character string- up to 35 characters) |
||||||||||
notifications |
Complex |
Optional |
This structure holds email notification settings for receiving parcel tracking information. |
||||||||||
notification |
Complex |
Mandatory |
If the notifications structure is present, at least one notification instance is required and up to 4 are allowed. This structure holds one email address and the kinds of notifications to be sent to the email address. |
||||||||||
Simple |
Mandatory |
(Email string up to 60 characters) Email address to receive automatic tracking updates. Must be a valid email address, i.e., pattern of (['_A-Za-z0-9\-\+])(\.['_A-Za-z0-9\-\+])@([A-Za-z0-9-])(\.[A-Za-z0-9-])(\.[A-Za-z]{2,}) If the notification structure is present, the email address element must be provided. |
|||||||||||
on-shipment |
Simple |
Mandatory |
{true, false} If the notification structure is present, this element must be provided. If set to “true”, all shipment related tracking updates will be sent to the email addressed. |
||||||||||
on-exception |
Simple |
Mandatory |
{true, false} If the notification structure is present, this element must be provided. If set to “true”, all exception related tracking updates will be sent to the email addressed. |
||||||||||
on-delivery |
Simple |
Mandatory |
{true, false} If the notification structure is present, this element must be provided. If set to “true”, all delivery related tracking updates will be sent to the email addressed. |
||||||||||
email-subject |
Simple |
Optional |
{tracking,customer-ref-1,customer-ref-2} Email subject lines have the following general forms depending on type of notification:
The value following the colon defaults to “TRACKING” and the Canada Post tracking number. Or you can set it to “REFERENCE” and one of the customer reference numbers. |
Request – XML Diagram
Response Details
Response – Elements
The following table describes the XML fields in the response. For a detailed view of the hierarchy of the response, see the diagram below.
Create Authorized Return – Response Elements | ||
---|---|---|
Element Name | Type | Description |
authorized-return |
Complex |
This is the top level XML element for the response. |
public-key-info |
Complex |
This structure represents data pertaining to label public URL – the URL to retrieve a PDF version of shipping label along with expiry date of the URL. |
expiry-date |
Simple |
The expiry date of label public URL. |
url |
Simple |
Actual URL to retrieve PDF version of the label in format |
qr-code |
Simple |
The Base64 encoding of the actual image of the QR code that represents the public URL (if create-qr-code and create-public-key are both present in the request and set to true). |
tracking-pin |
Simple |
This is the tracking PIN for the shipment. The tracking PIN can be used as input to other web service calls such as Get Tracking Details. |
customer-barcode |
Simple |
The barcode value that is specified in the request (if provided). |
links |
Complex |
This structure represents a list of links to information relating to the shipment that was created. |
return-link |
Complex |
The links structure contains a single return-link element. <link href=”https://XX/ers/artifact/12346789/9876554/01 This link contains no sub-elements and has three attributes as follows:
Note: After you create an authorized return, you have five calendar days to retrieve the return label before the link expires. |
Response – XML Diagram
Response – Possible Error Responses
In the case of an application error, an HTTP 400 level status code error response will be generated and the XML body will have an error message structure rather than the success response. For more information, see HTTP status codes.
Code |
Description |
---|---|
9191 |
ZPL is a language for thermal printers. You can therefore only use it with 4x6 thermal paper. |
9192 |
3x5 return labels are not available anymore. Please use 4x6 on thermal printers. |
9208 |
Public labels are only available in 8.5x11 PDF format. |
Examples
Sample REST XML Request – Create Authorized Return
<authorized-return>
<create-public-key>true</create-public-key>
<service-code>DOM.EP</service-code>
<returner>
<name>Jane Doe</name>
<company>Capsule Corp.</company>
<domestic-address>
<address-line-1>2701 Return Avenue</address-line-1>
<city>Ottawa</city>
<province>ON</province>
<postal-code>K1A0B1</postal-code>
</domestic-address>
</returner>
<receiver>
<name>John Doe</name>
<company>Canada Post Corporation</company>
<domestic-address>
<address-line-1>2701 Riverside Drive</address-line-1>
<city>Ottawa</city>
<province>ON</province>
<postal-code>K1A0B1</postal-code>
</domestic-address>
</receiver>
<parcel-characteristics>
<weight>15</weight>
</parcel-characteristics>
<print-preferences>
<output-format>8.5x11</output-format>
</print-preferences>
<settlement-info></settlement-info>
</authorized-return>
Sample REST XML Response – Create Authorized Return
<authorized-return-info>
<tracking-pin>12345678901234</tracking-pin>
<public-key-info>
<expiry-date>2020-02-22T23:59:59-05:00</expiry-date>
<url>https://www.canadapost-postescanada.ca/printlabel-imprimeretiquette?key-cle=6b7e21420a314e7b84c34a7be5fa8728</url>
</public-key-info>
<links>
<linkhref="https://ct.soa-gw.canadapost.ca/ers/artifact/76108cb5192002d5/21238/0"rel="returnLabel"media-type="application/pdf"index="0"></link>
</links>
</authorized-return-info>