Skip to content

Labels

Parcel Monkey Parcel2Go
Where label_url returned by CreateShipment GET /api/labels/{reference} after the order is paid, or document links from the order
When Up to 30 minutes. Poll label_url at most every 5 minutes. It returns 404 until ready (503 on v3.0). After payment. See Timing.
Format One label document PDF or PNG, A4 or 4×6, all in one or one per order line
Auth Signed URL Bearer token, plus the order or order line hash with client credentials

Call GET /api/labels/{reference} with:

Parameter Values Notes
reference An OrderId or OrderLineId In the path
referenceType OrderId, OrderLineId Which kind of reference you passed
detailLevel All, Labels, AdditionalDocuments, Instructions, CommercialInvoice CommercialInvoice replaces Parcel Monkey’s customs doc_type
labelMedia A4, Label4X6 Page size
labelFormat PDF, PNG File type
hash Hash from the create-order response Required with client credentials. Use the order hash for an OrderId, and the order line hash for an OrderLineId.
curl -G -X GET "https://sandbox.parcel2go.com/api/labels/115030194" \
-H "Authorization: Bearer $P2G_TOKEN" \
-H "Accept: application/json" \
--data-urlencode 'referenceType=OrderLineId' \
--data-urlencode 'detailLevel=Labels' \
--data-urlencode 'labelMedia=Label4X6' \
--data-urlencode 'labelFormat=PDF' \
--data-urlencode 'hash=<order line hash>'
Response
{
"SuccessfulLabels": 1,
"FailedLabels": 0,
"Base64EncodedLabels": [
"JVBERi0xLjcKJ..."
]
}

Each entry is a base64-encoded PDF or PNG. Decode it and save or print it.

Save the decoded file:

<?php
file_put_contents('label-115030194.pdf', base64_decode($labels['Base64EncodedLabels'][0]));

GET /api/labels/{reference}/separate takes the same parameters and returns one file per order line, with its courier tracking numbers. Use it when you print or store labels per shipment.

curl -G -X GET "https://sandbox.parcel2go.com/api/labels/76423942/separate" \
-H "Authorization: Bearer $P2G_TOKEN" \
-H "Accept: application/json" \
--data-urlencode 'referenceType=OrderId' \
--data-urlencode 'detailLevel=All' \
--data-urlencode 'labelMedia=A4' \
--data-urlencode 'labelFormat=PDF' \
--data-urlencode 'hash=<order hash>'
Response
{
"SuccessfulLabels": 1,
"FailedLabels": 0,
"Items": [
{
"OrderLineId": 115030194,
"Base64EncodedLabel": "JVBERi0xLjcKJ...",
"CourierTrackingNumbers": [
"<courier tracking number>"
]
}
]
}

After payment, Links objects can include public document URLs that you fetch with a plain GET, with no token. They include labels-a4, labels-4x6, labels-a4-4x6 (PDF), invoice, picking-list, and for print-in-store services barcode-printinstore (PNG). Which links you get depends on the order. See Parcel2Go’s links object guide.

Parcel Monkey labels could take up to 30 minutes. With Parcel2Go, request labels after a successful payment. The labels endpoints can return 408 RequestTimeout: if you get one, wait and retry with a backoff, not in a tight loop.

TODO(verify) T2: Are labels available as soon as paywithprepay succeeds? If not, what retry interval should customers use?

Check FailedLabels in the response. If it’s above 0, some labels weren’t generated. Retry, and log the order line IDs if it keeps failing.