$credentials = base64_encode("publickey:secretkey");
$requestBody = '{
"parcel": {
"name": "John Doe",
"company_name": "FlowerShop",
"email": "john@doe.com",
"telephone": "+31611223344",
"address": "Fürstenrieder Str.",
"house_number": "70",
"address_2": "",
"city": "Munich",
"country": "DE",
"postal_code": "80686",
"country_state": null,
"customs_invoice_nr": "",
"customs_shipment_type": null,
"parcel_items": [
{
"description": "T-Shirt",
"hs_code": "6109",
"origin_country": "SE",
"product_id": "898678671",
"properties": {
"color": "Blue",
"size": "Medium"
},
"quantity": 2,
"sku": "TST-OD2019-B620",
"value": "19.95",
"weight": "0.9"
},
{
"description": "Laptop",
"hs_code": "84713010",
"origin_country": "DE",
"product_id": "5756464758",
"properties": {
"color": "Black",
"internal_storage": "2TB"
},
"quantity": 1,
"sku": "LT-PN2020-B23",
"value": "876.97",
"weight": "1.69"
}
],
"weight": "3.49",
"length": "31.5",
"width": "27.2",
"height": "12.7",
"total_order_value": "896.92",
"total_order_value_currency": "EUR",
"shipment": {
"id": 8,
"name": "Unstamped letter"
},
"shipping_method_checkout_name": "Battery WarehouseX DHL",
"sender_address": 317854,
"quantity": 1,
"total_insured_value": 0,
"is_return": false,
"request_label": false,
"apply_shipping_rules": false,
"request_label_async": false
}
}';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://panel.sendcloud.sc/api/v2/parcels');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $requestBody);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Authorization: Basic '.$credentials,
'Content-Type: application/json',
));
$response = curl_exec($ch);
curl_close($ch);
echo $response;