The Delivery Zone API accepts a JSON POST and returns a JSON response. Call it using file_get_contents with a stream context, cURL, or wp_remote_post in WordPress.
Call the API inside your PHP request handling code — in a controller, a WordPress filter, or an API endpoint. Always server-side.
// PHP — server-side, keep API key out of frontend
$r = wp_remote_post('https://api.deliveryzone.fi/v1/check', [
'headers' => [
'X-Api-Key' => get_option('dz_api_key'),
'Content-Type' => 'application/json',
],
'body' => json_encode([
'destinationPostcode' => $postcode,
'basketValueCents' => $basketCents,
]),
]);
$data = json_decode(wp_remote_retrieve_body($r), true);
if (!$data['canDeliver']) return [];
foreach ($rates as $rate) {
$rate->cost = $data['priceCents'] / 100;
}
When canDeliver is false, the response includes a reason field. Display this to the customer:
OUT_OF_ZONE — postcode is valid but outside all defined zonesUNKNOWN_POSTCODE — postcode is not recognisedMIN_BASKET — basket value is below the zone minimumAlways handle HTTP errors (5xx, timeout) gracefully. If the API is unreachable, fail safe — either reject the order or allow manual review.
Create a free account and get your sandbox API key in minutes.