Get shipment label
The shipment's label as a PDF
https://s.zo.sa/api/public/v1 /shipments/{id}/label shipments.readThe label as the dashboard prints it: the carrier's own PDF, or the platform's printable label for a carrier that gave none. The label shows the shopper's address and mobile, so besides shipments.read the key needs customers.read (403 insufficient_scope with scope customers.read otherwise). A tracking number of the store's own carrier has no label (404). A cancelled shipment's label is never handed out again (422).
Request
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | integer | required | At least 1 |
cURL
curl -sS "https://s.zo.sa/api/public/v1/shipments/640/label" \
-H "Authorization: Bearer $ZO_API_KEY" \
-H "Accept: application/pdf" \
-o label.pdfJavaScript
import { writeFile } from 'node:fs/promises';
const response = await fetch('https://s.zo.sa/api/public/v1/shipments/640/label', {
headers: {
Authorization: `Bearer ${process.env.ZO_API_KEY}`,
Accept: 'application/pdf',
},
});
await writeFile('label.pdf', Buffer.from(await response.arrayBuffer()));
console.log(response.status);PHP
<?php
$ch = curl_init('https://s.zo.sa/api/public/v1/shipments/640/label');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('ZO_API_KEY'),
'Accept: application/pdf',
],
]);
$body = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
file_put_contents('label.pdf', $body);
echo $status, PHP_EOL;Python
import os
import requests
response = requests.get(
"https://s.zo.sa/api/public/v1/shipments/640/label",
headers={
"Authorization": f"Bearer {os.environ['ZO_API_KEY']}",
"Accept": "application/pdf",
},
timeout=30,
)
with open("label.pdf", "wb") as f:
f.write(response.content)
print(response.status_code)application/pdf: The label.
Responses
application/pdf
An error object: {"error": {"code", "message", "fields"}}.
An error object: {"error": {"code", "message", "fields"}}.
An error object: {"error": {"code", "message", "fields"}}.
An error object: {"error": {"code", "message", "fields"}}.
An error object: {"error": {"code", "message", "fields"}}.
An error object: {"error": {"code", "message", "fields"}}.