Delivery Zone · Developer docsديليفري زون · توثيق المطورين
Delivery Zone
● Live Production Safe Sandbox Simulator

Delivery Zone B2B Developer Platform & Delivery Engine

Connect your e-commerce store (Shopify, Salla, Zid, WooCommerce, or custom platforms) directly to Delivery Zone's on-demand delivery fleet across Bahrain. Dispatch orders programmatically with dynamic pickup and destination addresses, digital wallet payments, Cash on Delivery (COD) collection, and real-time live map tracking via WebSockets.

منصة المطورين والربط البرمجي لواصل (Delivery Zone B2B API)

اربط متجرك الإلكتروني (سلة، زد، شوبيفاي، ووكومرس، أو تطبيقك الخاص) مباشرة مع أسطول كباتن منصة ديليفري زون في جميع مناطق ومجمعات مملكة البحرين. إنشاء وتوزيع الطلبات آلياً مع مرونة كاملة في تحديد المرسل والمستلم، شحن الرصيد المسبق، الدفع عند الاستلام (COD)، وتتبع الكابتن لحظياً على خريطتك.

HMAC-SHA256 Signed Webhooks Real-time Driver GPS via WebSockets 🇧🇭 Complete Coverage Across All Bahrain Blocks

Who It's For

Online stores, pharmacies, restaurants, supermarkets, and aggregators looking to automate last-mile delivery without managing drivers.

لمن هذه الخدمة؟

المتاجر الإلكترونية، الصيدليات، المطاعم، والمطابخ السحابية، والشركات التي تحتاج أسطول توصيل فوري دون أعباء إدارة السائقين.

Dynamic Dispatch

Pickup from any branch or warehouse and deliver to any customer address. Supports bikes, cars, instant express, and same-day delivery.

مرونة مطلقة في التوصيل

استلام من أي فرع أو مستودع والتسليم لأي عنوان. دعم كامل للدراجات النارية والسيارات، والتوصيل الفوري (Express) أو خلال اليوم.

COD & Digital Wallet

Seamless Cash on Delivery (COD) collection by drivers, deposited directly into your merchant wallet with instant withdrawal capabilities.

تحصيل الكاش (COD) والمحفظة

تحصيل المبالغ النقدية من العملاء بواسطة الكابتن وإيداعها مباشرة في محفظتك الإلكترونية مع إمكانية السحب البنكي في أي وقت.

Real-Time Telemetry

Direct WebSocket channel and signed webhooks to stream moving driver markers on your own custom map seamlessly.

بث مباشر للخريطة والـ Webhooks

قناة WebSocket مباشرة وويب هوك موقع رقمياً لتحديث موقع السائق لحظة بلحظة على خريطتك الخاصة في تطبيقك أو موقعك.

How It Works — 4 Easy Steps

Get your delivery integration up and running in under 5 minutes:

آلية العمل — 4 خطوات بسيطة للربط

ابدأ بتشغيل عمليات التوصيل في متجرك خلال دقائق معدودة:

1
Get API Keys

Generate your Test and Live keys from your profile in the Delivery Zone mobile app or via the API.

استخراج المفاتيح

قم بتوليد مفاتيح الاختبار والإنتاج من شاشة الملف الشخصي في تطبيق ديليفري زون أو عبر الـ API.

2
Test in Sandbox

Use your wsl_test_... keys with 500 BHD virtual test balance to test order creation & webhooks safely.

الاختبار في بيئة الـ Sandbox

استخدم مفاتيح wsl_test_... مع رصيد تجريبي 500 د.ب لاختبار إنشاء الطلبات والـ Webhooks بأمان تام.

3
Configure Webhooks

Provide your HTTPS callback endpoint to receive automatic order status changes (assigned, picked up, delivered).

ضبط الـ Webhook

حدد رابط الـ HTTPS الخاص بك لاستقبال تحديثات الشحنة فوراً مع توقيع رقمي للأمان الكامل.

4
Go Live!

Switch to wsl_live_... keys, fund your merchant wallet, and dispatch real orders to Delivery Zone's fleet across Bahrain.

انطلق للإنتاج الحقيقي!

بدّل لمفاتيح wsl_live_... واشحن محفظتك وابدأ بتوزيع الشحنات الفعلية لكباتن ديليفري زون فوراً.

Dual Environments: Sandbox (Test) vs Live (Production)

Every Delivery Zone merchant account receives two pairs of credentials: Sandbox Keys for risk-free development, and Live Keys for real customer deliveries.

بيئتا العمل: بيئة الاختبار (Sandbox) مقابل بيئة الإنتاج (Live)

يحصل كل حساب تاجر في ديليفري زون على زوجين من المفاتيح: مفاتيح الاختبار (Sandbox) للتطوير الآمن دون تكلفة، والمفاتيح الحية (Live) لتوصيل طلبات الزبائن الفعلية.

Sandbox Environment (Test Mode) wsl_test_

Ideal for testing, CI/CD automated test suites, and staging environments without real money or alerting drivers.

  • Zero Real Wallet Cost: Automatically granted 500.000 BHD virtual test balance.
  • Driver Simulator: Test orders are automatically assigned to Captain Test (Sandbox Simulator) with fake bike TEST-999.
  • Full Webhook Simulation: Real signed webhooks sent to your test_webhook_url with "mode": "test" and "is_test": true.
  • Live Map & WebSocket: Safe WebSocket telemetry streams test GPS positions.

مثالية للتطوير والاختبار وأنظمة الـ CI/CD ومتاجر الـ Staging دون خصم أموال حقيقية أو إزعاج السائقين.

  • بدون أي خصم مالي: رصيد افتراضي قدره 500.000 د.ب يظهر تلقائياً في استعلام المحفظة.
  • محاكاة تلقائية للسائق: يتم تعيين الطلب فوراً لكابتن وهمي Captain Test (Sandbox Simulator) مع مركبة TEST-999.
  • إشعارات ويب هوك حقيقية: ترسل لسيرفرك مع "mode": "test" و "is_test": true لتجربة المعالجة.
  • WebSocket آمن: بث إحداثيات تجريبية للكابتن لاختبار الخريطة.
Live Environment (Production) wsl_live_

Production environment powering real-world orders dispatched directly to on-duty Bahrain drivers.

  • Real Wallet Deductions: Real delivery fee and VAT deducted from your merchant balance upon order creation.
  • Live Fleet Dispatch: Cascading geospatial dispatch engine offers order to closest active drivers.
  • Production Webhooks: Webhooks delivered to your registered webhook_url with "mode": "live".
  • Real GPS Telemetry: High-frequency live driver tracking over WebSockets.

بيئة الإنتاج الحقيقية لتوصيل شحنات وطلبات الزبائن الفعلية عبر أسطول كباتن ديليفري زون.

  • خصم مالي فعلي: خصم قيمة التوصيل والضريبة من محفظتك المعبأة مسبقاً.
  • توزيع جغرافي فوري: يبدأ النظام فوراً بإرسال الطلب لأقرب الكباتن المتاحين في البحرين.
  • إشعارات إنتاج: إرسال الويب هوك لرابط webhook_url مع "mode": "live".
  • تتبع GPS حقيقي: إحداثيات السائق الحية لحظة بلحظة عبر WebSocket.

Authentication

Authenticate requests by providing your API key and secret in the HTTP headers. The system automatically identifies whether you are calling in Live or Sandbox Test mode based on the key prefix.

المصادقة والتحقق (Authentication)

تتم مصادقة جميع الطلبات عبر الـ Headers باستخدام المفتاح العام والسرّي الخاص بحسابك. يتعرف النظام تلقائياً على بيئة العمل (حقيقية أو تجريبية) من بادئة المفتاح.

Headerالهيدر (Header) Descriptionالوصف Example Valueمثال القيمة
X-API-Key Public API key. Use wsl_live_... for production, or wsl_test_... for Sandbox. مفتاح الـ API العام. استخدم wsl_live_... للإنتاج أو wsl_test_... للاختبار التجريبي. wsl_test_88f8d073995fbb0b...
X-API-Secret Secret API key matching the provided key (starts with wsl_sec_ or wsl_sec_test_). المفتاح السري المطابق للمفتاح المرسل (يبدأ بـ wsl_sec_ أو wsl_sec_test_). wsl_sec_test_tG0gq7H67...
Authorization Alternative: Standard Bearer Token with your API Key بديل قياسي: Bearer Token يحتوي على المفتاح مباشرة Bearer wsl_test_88f8d073995fbb...
SHIELD Tiered Rate Limits & Anti-DDoS Architectureحدود الطلبات المتدرجة ونظام حماية الـ DDoS
RFC 6585 Standard

To ensure maximum uptime, controlled throughput, and prevent API abuse, denial of service (DDoS), Delivery Zone employs a high-performance Redis sliding-window rate limiter tailored per endpoint category.

Standard Rate Limit Headers (Sent with every response):
  • X-RateLimit-Limit: The maximum number of requests allowed within the current window.
  • X-RateLimit-Remaining: The number of requests remaining in the current window.
  • X-RateLimit-Reset: Seconds until the current rate limit window resets.
  • Retry-After: Returned with HTTP 429 when a limit is exceeded, indicating how many seconds to pause before retrying.
Multi-Tiered Endpoint Limits:

لضمان أعلى درجات الاستقرار والسرعة الفائقة والقدرة على استيعاب أحمال التكامل ومنع هجمات حجب الخدمة (DDoS) وسوء الاستخدام، تطبق منصة ديليفري زون نظام حدود طلبات متدرج (Tiered Rate Limiter) فائق الأداء مبني على Redis مع نوافذ انزلاقية وحماية ضد الاندفاع المفاجئ (Burst Protection).

هيدرز حدود الطلب القياسية (تُرسل مع كل استجابة):
  • X-RateLimit-Limit: الحد الأقصى المسموح به من الطلبات في النافذة الزمنية.
  • X-RateLimit-Remaining: عدد الطلبات المتبقية لحسابك في النافذة الحالية.
  • X-RateLimit-Reset: عدد الثواني المتبقية حتى تجديد وإعادة ضبط العداد.
  • Retry-After: يُعاد مع كود الخطأ 429 لتحديد عدد الثواني الواجب انتظارها قبل المعاودة.
جدول الحدود لكل عملية ومسار:
Operation / Categoryالعملية / المسار Endpointالرابط البرمجي Standard Limitالحد الأساسي Burst Protectionحماية الاندفاع (Burst)
Create Delivery Orderإنشاء طلب توصيل POST /api/v1/b2b/orders 120 req / min Max 25 req / 10 sec
Pricing & Quote Calculationحساب تسعيرة الشحن POST /api/v1/b2b/pricing/estimate 300 req / min Max 60 req / 10 sec
Live Driver GPS Pollإحداثيات الكابتن لايف GET /api/v1/b2b/orders/{id}/track 600 req / min 10 req / sec
Order Details & Routeتفاصيل الشحنة والمسار GET /api/v1/b2b/orders/{id} 300 req / min -
List Ordersقائمة الطلبات GET /api/v1/b2b/orders 180 req / min -
Cancel Orderإلغاء الطلب واسترجاع الرصيد POST /api/v1/b2b/orders/{id}/cancel 60 req / min -
Bahrain Cities Catalogمدن ومجمعات البحرين GET /api/v1/b2b/catalog/cities 300 req / min In-Memory Cache (Sub-ms)
Wallet & Transactionsالمحفظة وسجل العمليات GET /api/v1/b2b/wallet/* 120 req / min -
Live Map WebSocketsاتصال الخريطة الحي WSS /api/v1/b2b/ws/orders/{id} 40 connects / min Max 20 concurrent sockets
Global IP DDoS Shieldدرع حماية الـ IP العام All endpoints 1,200 req / min per IP Anti-Flood Defense
HTTP 429 Too Many Requests Example
{
  "detail": {
    "error": "rate_limit_exceeded",
    "message": "Rate limit of 120 requests per 60s reached for 'b2b.order_create'.",
    "retry_after_seconds": 12,
    "limit": 120,
    "window_seconds": 60
  }
}
POST https://deliveryzone.bh/api/v1/b2b/orders
201 Created

Create a new delivery order. In Live Mode, fees are deducted and couriers dispatched. In Sandbox Mode, virtual simulation takes place with no monetary deduction.

Request Parameters (JSON Body):

إنشاء طلب توصيل جديد. في الوضع الحي يتم خصم الرسوم وتوزيع الطلب للكباتن. في الوضع التجريبي يتم محاكاة العملية دون أي خصم مالي.

مواصفات حقول الطلب (JSON Request Body):
Fieldالحقل Typeالنوع Descriptionالوصف
client_reference_id string Your internal store/order reference ID (e.g. ORDER-9021) رقم الطلب في متجرك (مثال: ORDER-9021) لربطه بسهولة في نظامك
delivery_type * string Delivery speed: express (dedicated instant idle-driver priority), normal (same-day corridor batching & routing), or next_day (hybrid batch consolidation + en-route matching) سرعة التوصيل: express (فوري بسائق متفرغ حصرياً)، normal (توصيل نفس اليوم وتجميع ذكي)، أو next_day (تجميع الدفعات لليوم التالي مع أولوية المارين بالمسار)
vehicle_type string Vehicle preference: bike (motorcycle) or car نوع المركبة: bike (دراجة نارية) أو car (سيارة)
cod_amount number Cash on Delivery amount (BHD) driver should collect from customer upon delivery المبلغ المراد تحصيله نقداً من المستلم عند التسليم (COD) بالدينار البحريني
notes string Special instructions for the driver تعليمات أو ملاحظات خاصة للكابتن
sender * object Pickup details: name, phone, city_id, block_id, road, building, flat بيانات نقطة الاستلام: name, phone, city_id, block_id, road, building, flat
receiver * object Destination details: name, phone, city_id, block_id, road, building, flat بيانات المستلم والوجهة: name, phone, city_id, block_id, road, building, flat
# Test in Sandbox using wsl_test_ keys:
curl -X POST https://deliveryzone.bh/api/v1/b2b/orders   -H "X-API-Key: wsl_test_YOUR_KEY"   -H "X-API-Secret: wsl_sec_test_YOUR_SECRET"   -H "Content-Type: application/json"   -d '{
    "client_reference_id": "SHOPIFY-9021",
    "delivery_type": "normal",
    "vehicle_type": "bike",
    "cod_amount": 14.500,
    "notes": "Fragile items - Handle with care",
    "sender": {
      "name": "Bahar Electronics",
      "phone": "39XXXXXXXX",
      "city_id": 1,
      "block_id": 79,
      "road": "101",
      "building": "50",
      "flat": "1"
    },
    "receiver": {
      "name": "Ali Hassan",
      "phone": "39XXXXXXXX",
      "city_id": 1,
      "block_id": 79,
      "road": "202",
      "building": "60",
      "flat": "4"
    }
  }'
Response (201 Created):
application/json
{
  "delivery_id": 9042,
  "client_reference_id": "SHOPIFY-9021",
  "status": "assigned",
  "status_label_ar": "تم تعيين الكابتن",
  "status_label_en": "Driver Assigned",
  "price_bhd": 1.650,
  "cod_amount": 14.500,
  "delivery_type": "normal",
  "service_type": "same_day",
  "is_test": false,
  "driver": {
    "name": "Kareem Al-Bahraini",
    "phone": "+97339XXXXXXXX",
    "vehicle_type": "bike"
  },
  "pod_photo_url": null,
  "proof_of_delivery": null,
  "tracking_token": "wNKDCCnmFdewu-CaogcqKA",
  "tracking_url": "https://deliveryzone.bh/track/wNKDCCnmFdewu-CaogcqKA",
  "live_websocket": "wss://deliveryzone.bh/api/v1/b2b/ws/orders/9042?api_key=YOUR_KEY",
  "delivered_at": null,
  "created_at": "2026-11-09T09:15:00"
}
GET https://deliveryzone.bh/api/v1/b2b/orders
200 OK

Retrieve a paginated list of your merchant deliveries. Automatically isolates Live vs Sandbox test orders based on your active API key.

Query Parameters:

استعراض قائمة طلبات التوصيل الخاصة بمتجرك مع ترقيم الصفحات. يفصل النظام الطلبات الحية عن طلبات الاختبار تلقائياً حسب نوع المفتاح المستخدم.

محددات الاستعلام (Query Parameters):
Parameterالمعامل Typeالنوع Descriptionالوصف
limit integer Number of records per page (default: 50, max: 200). عدد الطلبات في الصفحة الواحدة (الافتراضي: 50، الحد الأقصى: 200).
offset integer Offset record index for pagination (default: 0). موضع بداية السجلات للترقيم (الافتراضي: 0).
status string Filter by state: pending, assigned, picked_up, delivered, cancelled. فلترة حسب الحالة: pending, assigned, picked_up, delivered, cancelled.
curl -X GET "https://deliveryzone.bh/api/v1/b2b/orders?limit=10&status=assigned"   -H "X-API-Key: wsl_test_YOUR_KEY"   -H "X-API-Secret: wsl_sec_test_YOUR_SECRET"
Response (200 OK):
application/json
{
  "mode": "test",
  "total": 35,
  "limit": 10,
  "offset": 0,
  "orders": [
    {
      "delivery_id": 9042,
      "client_reference_id": "SHOPIFY-9021",
      "status": "assigned",
      "status_label_ar": "تم تعيين الكابتن",
      "price_bhd": 1.650,
      "cod_amount": 14.500,
      "service_type": "same_day",
      "pod_photo_url": "https://deliveryzone.bh/static/uploads/pod/2026/11/order_9042_proof.jpg",
      "is_test": true,
      "created_at": "2026-11-09T09:15:00"
    }
  ]
}
GET https://deliveryzone.bh/api/v1/b2b/orders/{order_id}
200 OK

Retrieve complete metadata, pickup and destination addresses, driver profile, Proof of Delivery (POD) photo URL & notes, timeline timestamps, and active status of a specific order to display directly in your storefront.

جلب كامل تفاصيل الشحنة بما في ذلك العناوين التفصيلية، بيانات الكابتن، صورة إثبات التسليم (Proof of Delivery) لعرضها لعملاء متجرك، والجدول الزمني والمبالغ المالية.

curl -X GET https://deliveryzone.bh/api/v1/b2b/orders/9042   -H "X-API-Key: wsl_test_YOUR_KEY"   -H "X-API-Secret: wsl_sec_test_YOUR_SECRET"
Response (200 OK):
application/json
{
  "delivery_id": 9042,
  "client_reference_id": "SHOPIFY-9021",
  "status": "delivered",
  "status_label_ar": "تم التوصيل",
  "status_label_en": "Delivered",
  "progress_percent": 100.0,
  "price_bhd": 1.650,
  "cod_amount": 14.500,
  "service_type": "same_day",
  "pickup": {
    "name": "Bahar Electronics",
    "phone": "39XXXXXXXX",
    "address": "Manama, Block 79, Road 101, Building 50, Flat 1",
    "lat": 26.2285,
    "lng": 50.5860
  },
  "destination": {
    "name": "Ali Hassan",
    "phone": "39XXXXXXXX",
    "address": "Manama, Block 79, Road 202, Building 60, Flat 4",
    "lat": 26.2285,
    "lng": 50.5860
  },
  "driver": {
    "name": "Captain Test (Sandbox Simulator)",
    "phone": "+97339XXXXXXXX",
    "vehicle_type": "bike"
  },
  "pod_photo_url": "https://deliveryzone.bh/static/uploads/pod/2026/11/order_9042_proof.jpg",
  "proof_of_delivery": {
    "photo_url": "https://deliveryzone.bh/static/uploads/pod/2026/11/order_9042_proof.jpg",
    "uploaded_at": "2026-11-12T06:34:04",
    "lat": 26.2285,
    "lng": 50.5860,
    "notes": "Left at main entrance door"
  },
  "delivered_at": "2026-11-12T06:34:30",
  "tracking_token": "wNKDCCnmFdewu-CaogcqKA",
  "tracking_url": "https://deliveryzone.bh/track/wNKDCCnmFdewu-CaogcqKA"
}
POST https://deliveryzone.bh/api/v1/b2b/orders/{order_id}/rate
201 Created

Submit your end-customer's post-delivery rating once an order reaches delivered. Collects two 1–5 star scores: service_rating (overall experience / platform) and driver_rating (courier performance), plus an optional comment. You can also fetch a submitted rating via GET /api/v1/b2b/orders/{order_id}/rating.

Request Body (JSON):

إرسال تقييم عميلك النهائي بعد اكتمال الطلب ووصول حالته إلى delivered. يشمل تقييمين من 1 إلى 5 نجوم: service_rating (تجربة الخدمة/التطبيق) وdriver_rating (أداء المندوب)، بالإضافة إلى تعليق اختياري comment. كما يمكنك جلب التقييم عبر GET /api/v1/b2b/orders/{order_id}/rating.

مواصفات الجسم (JSON):
Fieldالحقل Typeالنوع Descriptionالوصف
service_rating integer (1-5, required) Overall service & platform experience ratingتقييم تجربة الخدمة والتطبيق (1 إلى 5)
driver_rating integer (1-5, required) Delivery courier ratingتقييم المندوب (1 إلى 5)
comment string (optional, max 1000) Optional free-text feedback from customerملاحظات إضافية اختيارية من العميل
curl -X POST https://deliveryzone.bh/api/v1/b2b/orders/9042/rate \
  -H "X-API-Key: wsl_live_YOUR_KEY" \
  -H "X-API-Secret: wsl_sec_YOUR_SECRET" \
  -H "Content-Type: application/json" \
  -d '{
    "service_rating": 5,
    "driver_rating": 5,
    "comment": "Fast delivery and polite courier!"
  }'
Response (201 Created):
application/json
{
  "mode": "live",
  "id": 14,
  "delivery_id": 9042,
  "driver_id": 18,
  "service_rating": 5,
  "driver_rating": 5,
  "comment": "Fast delivery and polite courier!",
  "source": "b2b_api",
  "created_at": "2026-11-12T08:15:10"
}
GET https://deliveryzone.bh/api/v1/b2b/orders/{order_id}/track
200 OK

Live snapshot of courier GPS coordinates, 6-step progression stage (including on_the_way_to_you "You're Next" between en_route_multi_stop and arrived), multi-stop chained ETA (road_drive_minutes + stop_handling_minutes), privacy-isolated stops_before_yours, and a tokenized public tracking_url safe to share directly with your end customer via SMS or WhatsApp.

قراءة فورية لموقع السائق، ومراحل التقدم الست (بما فيها حالة on_the_way_to_you «أنت التالي» بين en_route_multi_stop وarrived)، وحساب الوقت التراكمي للوصول (زمن القيادة + وقت توقف المحطات السابقة stops_before_yours)، مع رابط تتبع عام آمن ومعزول tracking_url جاهز للإرسال مباشرةً للمستلم عبر SMS أو واتساب.

curl -X GET https://deliveryzone.bh/api/v1/b2b/orders/9042/track   -H "X-API-Key: wsl_test_YOUR_KEY"   -H "X-API-Secret: wsl_sec_test_YOUR_SECRET"
Response (200 OK):
application/json
{
  "mode": "test",
  "delivery_id": 9042,
  "client_reference_id": "SHOPIFY-9021",
  "status": "picked_up",
  "stage": {
    "stage_key": "on_the_way_to_you",
    "stage_step": 4,
    "total_steps": 6,
    "is_coming_to_you": true,
    "label_en": "You're Next · On the Way",
    "label_ar": "أنت التالي · في الطريق إليك"
  },
  "service_type": "same_day",
  "driver": {
    "assigned": true,
    "name": "Captain Test (Sandbox Simulator)",
    "phone": "+97339XXXXXXXX",
    "current_lat": 26.2285,
    "current_lng": 50.5860
  },
  "eta": {
    "target": "destination",
    "distance_km": 4.2,
    "eta_minutes": 12.5,
    "road_drive_minutes": 8.5,
    "stop_handling_minutes": 4.0,
    "handover_per_stop_minutes": 4.0,
    "stops_before_yours": 1,
    "queue_position": 2,
    "next_up": false,
    "route_style": "dashed_with_stops"
  },
  "pod_photo_url": "https://deliveryzone.bh/static/uploads/pod/2026/11/order_9042_proof.jpg",
  "proof_of_delivery": {
    "photo_url": "https://deliveryzone.bh/static/uploads/pod/2026/11/order_9042_proof.jpg",
    "uploaded_at": "2026-11-12T06:34:04",
    "lat": 26.2285,
    "lng": 50.5860,
    "notes": "Left at main entrance door"
  },
  "delivered_at": "2026-11-12T06:34:30",
  "tracking_token": "wNKDCCnmFdewu-CaogcqKA",
  "tracking_url": "https://deliveryzone.bh/track/wNKDCCnmFdewu-CaogcqKA",
  "live_websocket": "wss://deliveryzone.bh/api/v1/b2b/ws/orders/9042?api_key=TEST_KEY"
}
POST https://deliveryzone.bh/api/v1/b2b/orders/{order_id}/cancel
200 OK

Cancel an unassigned delivery (pending, pending_dispatch, offered, available or dispatch_failed). Sandbox also allows the simulated assigned state. In Live mode, the delivery fee and VAT are immediately credited back to your merchant wallet.

إلغاء طلب لم يُسند بعد: pending أو pending_dispatch أو offered أو available أو dispatch_failed. يقبل Sandbox أيضًا حالة assigned المحاكاة. في الوضع الحي، يتم إيداع واسترجاع رسوم التوصيل والضريبة في محفظتك الإلكترونية تلقائياً وفوراً.

curl -X POST https://deliveryzone.bh/api/v1/b2b/orders/9042/cancel   -H "X-API-Key: wsl_test_YOUR_KEY"   -H "X-API-Secret: wsl_sec_test_YOUR_SECRET"   -H "Content-Type: application/json"   -d '{"reason": "Customer cancelled their purchase"}'
Response (200 OK):
application/json
{
  "success": true,
  "mode": "test",
  "message": "Delivery #9042 cancelled successfully.",
  "order": {
    "delivery_id": 9042,
    "status": "cancelled",
    "mode": "test",
    "is_test": true
  }
}
WSS wss://deliveryzone.bh/api/v1/b2b/ws/orders/{order_id}?api_key=YOUR_KEY
Bi-Directional Telemetry

The current channel sends initial_state once. Send a non-ping message (for example status) to request a heartbeat with status, driver_lat and driver_lng. A ping receives pong only. Live mode returns recorded driver coordinates; test mode simulates coordinates when an update is requested. If no client message arrives for five seconds, the server sends a heartbeat automatically.

JavaScript Client Example (Google Maps / Leaflet):

ترسل القناة initial_state عند الاتصال. أرسل نصًا غير ping (مثل status) لطلب heartbeat يتضمن الحالة وdriver_lat وdriver_lng. رسالة ping تعيد pong فقط. الوضع الحي يعيد إحداثيات السائق المسجلة، والوضع التجريبي يحاكي الإحداثيات عند طلب تحديث. ترسل القناة تحديثًا عند مرور خمس ثوانٍ دون رسائل من العميل، ويمكن إرسال update لطلب تحديث أو ping للتحقق من الاتصال.

كود جافاسكريبت للربط مع الخريطة:
liveTracker.js
const wsUrl = `wss://deliveryzone.bh/api/v1/b2b/ws/orders/${orderId}?api_key=${apiKey}`;
const socket = new WebSocket(wsUrl);

socket.onmessage = (event) => {
  const data = JSON.parse(event.data);
  if (data.type === 'initial_state') {
    console.log("Order snapshot:", data.order);
  } else if (data.type === 'heartbeat') {
    console.log("Order status:", data.status);
    if (data.driver_lat != null && data.driver_lng != null) {
      driverMarker.setPosition({ lat: data.driver_lat, lng: data.driver_lng });
    }
  }
};

socket.onerror = (err) => console.error("WS Telemetry Error:", err);
STATUS Delivery Status + Hold / Return Systemنظام الحالات + التعليق / الإرجاع

GPS never changes status. Multi-stop: finishing dropoff #1 (delivered / customer_not_available / pickup_failed) auto-promotes the next already-picked_up order to on_the_way («You're next») + push + webhook. Oreem-style money: a failed attempt keeps the delivery fee (delivery_fee_retained=true); returning the package is a separate paid trip (return_fee_bhd).

StatusWhoMeaningWebhook
pending_dispatch … offeredSystemDispatch pipelinedelivery.created / …
assigned / acceptedSystem / DriverDriver on job → pickupassigned / accepted
preparing / ready_for_pickupDriverAt senderyes
picked_upDriver (+ geofence)Package in vehicledelivery.picked_up
on_the_wayDriver or auto«You're next» dropoffdelivery.on_the_way
arrived → deliveredDriverDoor → success (+ POD/COD)arrived / delivered
customer_not_availableDriverRecipient no-answer. Package stays with driver. Hold awaiting_shop. Fee retained. Next stop continues.delivery.customer_not_available
pickup_failedDriverSender/shop no-answer at pickup. No package — cannot deliver this order. Other picked-up stops continue.delivery.pickup_failed
returning_to_senderDriver hold-action / CSDriver taking package back to shop (separate return fee)delivery.returning_to_sender
returnedDriver confirm / CSBack at shop or officedelivery.returned
cancelledAdmin / CSCancel; optionally keep fee (cancel_keep_fee) or refunddelivery.cancelled
delivery_failedDriverHard failureyes
Hold payload fields (order detail / webhooks)
  • package_with_driver — true after CNA until returned/office
  • hold_kind — recipient_unavailable | pickup_failed | return
  • hold_stage — awaiting_shop | returning_to_sender | at_office | resolved | closed
  • delivery_fee_retained — true after failed attempt (no auto-refund of delivery fee)
  • return_fee_bhd — optional separate return charge (CS)
Driver APIs
  • POST /api/v1/driver/deliveries/{id}/status?new_status=…&lat=&lng= — driver statuses only; cancelled/returned → 403
  • After CNA (default = wait for shop): POST /api/v1/driver/deliveries/{id}/hold-action?action=return_to_sender
  • Handed to shop/office: …/hold-action?action=confirm_returned

CS desk (map + actions): /admin/delivery/orders — retry same driver, return + fee, at office, cancel keep fee / refund.

GPS لا يغيّر الحالة. مسار متعدد: بعد إنهاء محطة 1 يُرقّى الطلب التالي المستلم إلى on_the_way («أنت التالي»). قاعدة الرسوم: محاولة فاشلة = الاحتفاظ برسوم التوصيل · الإرجاع = رسوم منفصلة.

الحالةمنالمعنىWebhook
picked_up → on_the_way → arrived → deliveredسائق / تلقائيمسار ناجحنعم
customer_not_availableسائقالمستلم ما رد — الشحنة معه — بانتظار المحل — يكمل باقي المسارنعم
pickup_failedسائقالمحل ما رد عند الاستلام — ما في شحنةنعم
returning_to_sender → returnedسائق / دعمإرجاع للمرسل/المكتبنعم
cancelledدعم فقطإلغاء (مع أو بدون استرجاع الرسوم)نعم

بعد CNA: hold-action?action=return_to_sender أو confirm_returned. ممنوع على السائق: cancelled / ضبط returned عبر status (403).

WEBHOOK Real-Time Webhooks & Securityإشعارات الحالة التلقائية (Webhooks)
HMAC-SHA256 Signed

Delivery Zone automatically pushes HTTP POST notifications to your configured Webhook URL whenever an order status changes. Every payload is securely signed using your webhook_secret via HMAC-SHA256 and sent in the X-Wassel-Signature: sha256=... header to verify authenticity and prevent tampering. See also Status System.

Supported Webhook Events:
  • delivery.created → assigned → accepted / preparing / ready_for_pickup
  • delivery.picked_up → delivery.on_the_way («You're next», also auto after previous stop) → arrived → delivered
  • delivery.pod_uploaded: POD photo (pod_photo_url / proof_of_delivery)
  • delivery.customer_not_available: Recipient unreachable; package with driver; fee retained; next stop may get on_the_way
  • delivery.pickup_failed: Sender/shop no-answer at pickup (no package for this order)
  • delivery.returning_to_sender → delivery.returned: Return trip / back at shop or office
  • delivery.delivery_failed / delivery.cancelled: Failure / CS cancel
  • webhook.test_ping: POST /b2b/webhooks/test

Hold fields are included on order payloads when present: package_with_driver, hold_kind, hold_stage, delivery_fee_retained, return_fee_bhd. See Status System.

Signature Verification (Node.js & Python):

يقوم سيرفر ديليفري زون بإرسال طلب HTTP POST مباشر إلى رابط الـ Webhook المسجل في حسابك فور حدوث أي تغيير على الطلب، مرفقاً بهيدر التوقيع الرقمي X-Wassel-Signature: sha256=... للتحقق من أمان ومصدر الرسالة. راجع أيضاً نظام الحالات + التعليق/الإرجاع.

أحداث الويب هوك (Supported Events):
  • مسار ناجح: created → assigned → picked_up → on_the_way → arrived → delivered
  • customer_not_available: مستلم غير متاح — الشحنة مع السائق — الرسوم محفوظة
  • pickup_failed: فشل الاستلام من المرسل
  • returning_to_sender → returned: إرجاع للمرسل/المكتب
  • cancelled / delivery_failed / webhook.test_ping
التحقق من التوقيع الرقمي (Signature Verification):
verifyWebhookSignature.js
const crypto = require('node:crypto');

function verifyWasselWebhook(rawBody, signatureHeader, secret) {
  if (!secret || typeof signatureHeader !== 'string' ||
      !/^sha256=[a-f0-9]{64}$/i.test(signatureHeader)) return false;
  const expected = crypto.createHmac('sha256', secret).update(rawBody).digest();
  const received = Buffer.from(signatureHeader.slice(7), 'hex');
  return received.length === expected.length &&
    crypto.timingSafeEqual(received, expected);
}
POST https://deliveryzone.bh/api/v1/b2b/webhooks/test

Trigger a live test ping to your registered webhook URL anytime to verify your server handshake and signature verification logic. أرسل فحصاً تجريبياً لرابط الـ Webhook الخاص بك في أي وقت للتأكد من وصول البيانات وصحة التحقق من التوقيع الرقمي.

curl -X POST https://deliveryzone.bh/api/v1/b2b/webhooks/test   -H "X-API-Key: wsl_test_YOUR_KEY"   -H "X-API-Secret: wsl_sec_test_YOUR_SECRET"
GET https://deliveryzone.bh/api/v1/b2b/catalog/cities
200 OK

Retrieve all official Bahrain cities and blocks for checkout address validation and dropdown population in your store.

جلب قائمة المدن والمجمعات المعتمدة في مملكة البحرين للتحقق من العناوين في متجرك قبل إرسال الطلبات.

curl -X GET https://deliveryzone.bh/api/v1/b2b/catalog/cities   -H "X-API-Key: wsl_test_YOUR_KEY"   -H "X-API-Secret: wsl_sec_test_YOUR_SECRET"
Response (200 OK):
application/json
{
  "cities": [
    {
      "name_ar": "المنامة",
      "name_en": "Manama",
      "blocks": [
        {
          "block_number": "307",
          "lat": 26.2285,
          "lng": 50.586,
          "block_id": 79
        },
        {
          "block_number": "308",
          "lat": 26.229,
          "lng": 50.587,
          "block_id": 80
        }
      ],
      "city_id": 1,
      "blocks_count": 2
    }
  ]
}
POST https://deliveryzone.bh/api/v1/b2b/pricing/estimate
200 OK

Calculate the exact delivery fee, distance (km), estimated time of arrival (ETA in minutes), and applicable VAT before placing an order. For express (Instant), the fee scales dynamically within the configured range (1.500 – 4.000 BHD) based on road distance and vehicle type (bike / car).

Request Parameters (JSON Body):

حساب تسعيرة التوصيل الدقيقة والمسافة المقدرة بالكيلومتر ووقت الوصول المتوقع (ETA) والضريبة قبل اعتماد الطلب. بالنسبة للنوع الفوري express (Instant)، يتم احتساب السعر ديناميكياً ضمن النطاق (1.500 – 4.000 BHD) بناءً على المسافة الفعلية ونوع المركبة (bike / car).

مواصفات حقول الطلب:
Fieldالحقل Typeالنوع Descriptionالوصف
delivery_type string normal, express, or next_day
vehicle_type string bike or car
pickup_city_id integer Pickup City ID
pickup_block_id integer Pickup Block ID
destination_city_id integer Destination City ID
destination_block_id integer Destination Block ID
pickup_lat, pickup_lng, destination_lat, destination_lng float (optional) Exact GPS coordinates for distance-dynamic express (Instant) quotes
curl -X POST https://deliveryzone.bh/api/v1/b2b/pricing/estimate   -H "X-API-Key: wsl_test_YOUR_KEY"   -H "X-API-Secret: wsl_sec_test_YOUR_SECRET"   -H "Content-Type: application/json"   -d '{
    "delivery_type": "normal",
    "vehicle_type": "bike",
    "pickup_city_id": 1,
    "pickup_block_id": 79,
    "destination_city_id": 1,
    "destination_block_id": 80
  }'
Response (200 OK):
application/json
{
  "mode": "live",
  "delivery_type": "express",
  "vehicle_type": "car",
  "is_dynamic": true,
  "distance_km": 14.2,
  "duration_minutes": 19.5,
  "delivery_fee_bhd": 3.000,
  "platform_fee_bhd": 0.600,
  "platform_fee_pct": 20.0,
  "driver_share_bhd": 2.400,
  "min_price_bhd": 2.000,
  "max_price_bhd": 4.000,
  "vat_percentage": 0.0,
  "vat_amount_bhd": 0.0,
  "total_charge_bhd": 3.000,
  "currency": "BHD"
}
GET https://deliveryzone.bh/api/v1/b2b/wallet
200 OK

Check your merchant wallet balance and pending COD collections. When queried with wsl_test_... keys, automatically returns a virtual 500.000 BHD sandbox balance.

الاستعلام عن رصيد محفظة التاجر والمبالغ النقدية المعلقة (COD). عند استخدام مفاتيح wsl_test_...، يتم إرجاع رصيد تجريبي قدره 500.000 د.ب لتجربة النظام بأمان.

curl -X GET https://deliveryzone.bh/api/v1/b2b/wallet   -H "X-API-Key: wsl_test_YOUR_KEY"   -H "X-API-Secret: wsl_sec_test_YOUR_SECRET"
Response (200 OK):
application/json
{
  "mode": "test",
  "sandbox": true,
  "balance_bhd": 500.000,
  "currency": "BHD",
  "note": "Virtual test sandbox balance. No real money deducted."
}
GET https://deliveryzone.bh/api/v1/b2b/wallet/transactions
200 OK

Audit ledger of all financial deposits, order fee deductions, refunds, and COD cash collections.

كشف حساب مالي تفصيلي لجميع عمليات الإيداع، خصومات التوصيل، المبالغ المسترجعة، وتحصيلات الكاش من الكباتن.

curl -X GET "https://deliveryzone.bh/api/v1/b2b/wallet/transactions?limit=10"   -H "X-API-Key: wsl_live_YOUR_KEY"   -H "X-API-Secret: wsl_sec_YOUR_SECRET"
Response (200 OK):
application/json
{
  "total": 12,
  "transactions": [
    {
      "id": 142,
      "amount": -1.650,
      "type": "delivery_fee",
      "description": "Delivery #9042 fee deduction",
      "created_at": "2026-11-09T09:15:00"
    },
    {
      "id": 141,
      "amount": 25.000,
      "type": "deposit",
      "description": "Wallet top-up via BenefitPay",
      "created_at": "2026-11-09T08:00:00"
    }
  ]
}
POST https://deliveryzone.bh/api/v1/user/developer/keys/generate
200 OK

Endpoints designed for the Delivery Zone Flutter app in the User Profile screen, enabling users to generate their Live and Sandbox developer keys and configure their webhook URLs with one tap.

مسارات موجهة لتطبيق فلاتر في شاشة الملف الشخصي لتمكين المستخدم من توليد مفاتيح الربط البرمجي الحية والتجريبية وربط الويب هوك بنقرة زر واحدة.

curl -X POST https://deliveryzone.bh/api/v1/user/developer/keys/generate   -H "Authorization: Bearer YOUR_USER_JWT_TOKEN"
Response (200 OK):
application/json
{
  "success": true,
  "message": "Live and Test API keys generated successfully.",
  "live": {
    "api_key": "wsl_live_d1506d20f0d4e6852a1a3ef351f96fa1",
    "api_secret": "wsl_sec_vIrhIAYXJ9JmaoemKG3JFyCy0gZZPuMnVDNldgxWsMc",
    "webhook_url": "https://mystore.com/api/wassel-webhook"
  },
  "test": {
    "api_key": "wsl_test_88f8d073995fbb0bd80f583ebef52a78",
    "api_secret": "wsl_sec_test_tG0gq7H67V8Qc1J",
    "webhook_url": "https://mystore.com/api/test-webhook"
  },
  "webhook_secret": "whsec_082b7a580e75581894ca6d5bcfde91f65b4e2df836c68177"
}

Reliable requests and webhook deliveryموثوقية الطلبات وتسليم الويب هوك

An administrator must enable API access for your account before developer keys, B2B HTTP calls or WebSocket tracking can be used. Account access can be disabled centrally without changing customer app access.

يجب أن تفعّل الإدارة صلاحية API لحسابك قبل استخدام مفاتيح المطور أو طلبات B2B أو تتبع WebSocket. يمكن للإدارة تعطيلها دون تعطيل واجهات تطبيق العميل العادية.

Send Idempotency-Key on POST /api/v1/b2b/orders, /api/v1/delivery and /api/v1/wallet/withdraw. Repeating a key for the same account, operation, environment and payload returns the existing resource. A changed payload returns 409. B2B client_reference_id is used when the header is absent. Keys are retained with the resource record; retries do not create another delivery or debit. Rate limits alone do not provide this guarantee.

أرسل Idempotency-Key عند إنشاء طلب B2B أو طلب العميل أو طلب سحب. تكرار المفتاح للحساب والعملية والبيئة والبيانات نفسها يعيد المورد السابق؛ تغيير البيانات يعيد 409. يستخدم B2B قيمة client_reference_id عند غياب الترويسة. الاحتفاظ بالمفتاح مرتبط بسجل العملية، وحدود الطلبات وحدها لا تمنع تكرار الخصم.

Webhook destinations require public HTTPS on port 443 or 8443. Internal addresses and redirects are rejected. Sandbox requires its own test_webhook_url and never falls back to the live URL. Test wallet transactions are empty because no real money is moved.

روابط الويب هوك تتطلب HTTPS عامًا على المنفذ 443 أو 8443؛ العناوين الداخلية والتحويلات غير مقبولة. يتطلب Sandbox رابط test_webhook_url مستقلًا ولا يرجع إلى رابط الإنتاج. كشف المحفظة التجريبي فارغ لأن الاختبار لا يحرك أموالًا فعلية.

POST /api/v1/b2b/webhooks/test queues an account-only diagnostic event and returns 202 with event_id. GET /api/v1/b2b/webhooks/deliveries lists delivery attempts; GET /api/v1/b2b/webhooks/deliveries/{event_id} returns status and payload. POST /api/v1/b2b/webhooks/deliveries/{event_id}/retry queues a replay with the same event ID. All endpoints are scoped to the authenticated account and live/test mode.

اختبار الويب هوك يعيد 202 وevent_id لحدث تشخيص خاص بالحساب دون الحاجة إلى طلب توصيل. واجهة GET /api/v1/b2b/webhooks/deliveries تعرض السجل؛ إضافة /{event_id} تعرض الحالة والمحتوى، وPOST على /{event_id}/retry يعيد الإرسال بالمعرف نفسه. جميعها مقيدة بالحساب ووضع live أو test.

Events are persisted and retried up to six times with exponential backoff, beginning at 30 seconds. Delivery is at least once: deduplicate by event_id. Verify X-Wassel-Signature against the exact raw request body using HMAC-SHA256 and your webhook secret. Return any 2xx status. X-Wassel-Event-Id and X-Wassel-Attempt identify the event and attempt. DELETE /api/v1/user/developer/keys revokes the account's developer keys.

تُحفظ الأحداث وتُعاد محاولتها حتى ست مرات بانتظار متزايد يبدأ من 30 ثانية. قد يصل الحدث أكثر من مرة؛ امنع التكرار بواسطة event_id. تحقق من X-Wassel-Signature على جسم الطلب الخام باستخدام HMAC-SHA256 وسر الويب هوك، وأعد أي حالة 2xx. تعرض ترويستا X-Wassel-Event-Id وX-Wassel-Attempt المعرف ورقم المحاولة. DELETE /api/v1/user/developer/keys يبطل مفاتيح المطور للحساب.