Download Shipment Label
Provides a redirect to download the generated shipping label for a specific shipment.
Endpoint
GET /v1/shipments/{id}/label
Authentication
API key required. Include it in the Authorization header:
Authorization: Bearer YOUR_API_KEY
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | The ID of the shipment to download the label for. |
Response
200 OK
A successful request will return a JSON object containing the label content and metadata.
{
"data": {
"shipment_id": "sh_123456",
"reference_number": "ORD-2025-001",
"provider_shipment_id": "DHL-ABC-123",
"label": {
"content": "JVBERi0xLjQKJeLjz9MKMiAwIG9iago8PC9UeXBlL1hPYmplY3QvU3VidHlwZS9JbWFnZS9XaWR0aCAx...",
"format": "pdf",
"mime_type": "application/pdf",
"size": 12345
}
}
}
Error Responses
| Status Code | Description |
|---|---|
| 401 | Unauthorized - Invalid or missing API key |
| 403 | Forbidden - You don't have permission to access this shipment's label |
| 404 | Not Found - The specified shipment or its label could not be found |
| 429 | Too Many Requests - Rate limit exceeded |
| 500 | Server Error - Something went wrong on our end |
Example Request
cURL
curl -X GET \
https://api.shipping-channels.com/v1/shipments/sh_123456/label \
-H "Authorization: Bearer YOUR_API_KEY"
PHP
<?php
$client = new \GuzzleHttp\Client();
$response = $client->request('GET', 'https://api.shipping-channels.com/v1/shipments/sh_123456/label', [
'headers' => [
'Authorization' => 'Bearer YOUR_API_KEY',
'Accept' => 'application/json',
],
]);
$data = json_decode($response->getBody(), true);
// The label content is base64 encoded
$labelContent = base64_decode($data['data']['label']['content']);
// Save the label to a file
file_put_contents('label.pdf', $labelContent);
JavaScript
fetch('https://api.shipping-channels.com/v1/shipments/sh_123456/label', {
method: 'GET',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Accept': 'application/json'
}
})
.then(response => response.json())
.then(data => {
// The label content is base64 encoded
const labelContent = atob(data.data.label.content);
// Create a blob from the label content
const blob = new Blob([labelContent], { type: data.data.label.mime_type });
// Create a link to download the blob
const link = document.createElement('a');
link.href = window.URL.createObjectURL(blob);
link.download = 'label.pdf';
link.click();
})
.catch(error => console.error('Error:', error));