{
    "openapi": "3.0.3",
    "info": {
        "title": "Developer Portal & API Reference | Al-Shrouq Express",
        "version": "1.0.0",
        "description": "Official developer documentation and REST API reference for Al-Shrouq Express delivery, fleet dispatch, Deliverect POS, and Salla ecommerce platform."
    },
    "servers": [
        {
            "url": "https://alshrouqdelivery.com",
            "description": "Production Server"
        },
        {
            "url": "https://staging.alshrouqsse.org/",
            "description": "Staging Sandbox"
        }
    ],
    "paths": {
        "/api/integration/{token}/orders/create": {
            "post": {
                "tags": [
                    "Core Direct Orders Lifecycle"
                ],
                "summary": "Create New Order",
                "description": null,
                "parameters": [],
                "responses": {
                    "200": {
                        "description": "Order Created successfully",
                        "content": {
                            "application/json": {
                                "example": {
                                    "order_id": 609077,
                                    "client_order_id": 12345,
                                    "customer_name": "Ahmed",
                                    "customer_phone": "501234567",
                                    "customer_lat": 24.7135999999999995679900166578590869903564453125,
                                    "customer_lng": 46.67530000000000001136868377216160297393798828125,
                                    "customer_address": null,
                                    "branch_name": "Tawera",
                                    "branch_id": 33,
                                    "fees": "0",
                                    "distance": "0",
                                    "status_id": "",
                                    "status_label": "Order created",
                                    "value": "100.5",
                                    "cod": "100.5",
                                    "payment_type_label": "Cash",
                                    "payment_type": 1,
                                    "details": "Extra sauce, no onions",
                                    "created_at": "2025-04-21 1:17 PM"
                                }
                            }
                        }
                    }
                },
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "branch_lat": {
                                        "type": "integer",
                                        "description": "Required if \"branch_id\" is missing",
                                        "example": "24.7136"
                                    },
                                    "branch_lng": {
                                        "type": "integer",
                                        "description": "Required if \"branch_id\" is missing",
                                        "example": "46.6753"
                                    },
                                    "branch_id": {
                                        "type": "integer",
                                        "description": "Required if \"branch_lat\" & \"branch_lng\" are missing",
                                        "example": "9999927651182"
                                    },
                                    "client_order_id": {
                                        "type": "string",
                                        "description": null,
                                        "example": "\"Test--0007\""
                                    },
                                    "value": {
                                        "type": "number",
                                        "description": "Order Value",
                                        "example": "100.5"
                                    },
                                    "payment_type": {
                                        "type": "integer",
                                        "description": "Payment type",
                                        "example": "1= COD (Cash on Delivery) , 2= SPAN Machine , 3= Paid , 4= AlshrouqPay",
                                        "enum": [
                                            1,
                                            2,
                                            3,
                                            4
                                        ]
                                    },
                                    "preparation_time": {
                                        "type": "integer",
                                        "description": null,
                                        "example": "3"
                                    },
                                    "customer_lat": {
                                        "type": "number",
                                        "description": null,
                                        "example": "24.7136"
                                    },
                                    "customer_lng": {
                                        "type": "number",
                                        "description": null,
                                        "example": "46.6753"
                                    },
                                    "customer_phone": {
                                        "type": "string",
                                        "description": "Customer phone number",
                                        "example": "501234567"
                                    },
                                    "customer_name": {
                                        "type": "string",
                                        "description": "Customer name",
                                        "example": "Ahmed"
                                    },
                                    "details": {
                                        "type": "string",
                                        "description": "Order Details",
                                        "example": "Extra sauce, no onions"
                                    },
                                    "customer_national_address": {
                                        "type": "string",
                                        "description": "Customer national address",
                                        "example": "test address"
                                    },
                                    "building_no": {
                                        "type": "string",
                                        "description": null,
                                        "example": "14"
                                    },
                                    "floor_no": {
                                        "type": "string",
                                        "description": null,
                                        "example": "16"
                                    },
                                    "apartment_no": {
                                        "type": "string",
                                        "description": null,
                                        "example": "3"
                                    },
                                    "customer_address": {
                                        "type": "string",
                                        "description": null,
                                        "example": "\"\""
                                    },
                                    "deliver_at": {
                                        "type": "string",
                                        "description": null,
                                        "example": "\"2029-05-20 14:00:00\""
                                    },
                                    "city": {
                                        "type": "integer",
                                        "description": null,
                                        "example": "3"
                                    },
                                    "ingr_branch_name": {
                                        "type": "string",
                                        "description": null,
                                        "example": "\"\""
                                    },
                                    "otp": {
                                        "type": "string",
                                        "description": null,
                                        "example": "\"\""
                                    },
                                    "pick_up_code": {
                                        "type": "string",
                                        "description": null,
                                        "example": "\"\""
                                    },
                                    "service_type": {
                                        "type": "integer",
                                        "description": null
                                    },
                                    "weight": {
                                        "type": "number",
                                        "description": null
                                    },
                                    "items_no": {
                                        "type": "number",
                                        "description": null
                                    }
                                },
                                "required": [
                                    "branch_lat",
                                    "branch_lng",
                                    "branch_id",
                                    "payment_type",
                                    "customer_phone",
                                    "customer_name"
                                ]
                            },
                            "example": "{\r\n  // Either (\"branch_lat\" & \"branch_lng\") OR \"branch_id\" is required (but not both)\r\n  \"branch_lat\": 24.7136,  // Required if branch_id is missing (must be numeric)\r\n  \"branch_lng\": 46.6753,  // Required if branch_id is missing (must be numeric)\r\n  \"branch_id\": null,      // Required if \"branch_lat\" & \"branch_lng\" are missing\r\n  \r\n  // Optional fields\r\n  \"client_order_id\": \"12345\",  // Optional.\r\n  \"value\": 100.50,             // Optional.\r\n  \"payment_type\": 1,           // Required, must be either //  1= COD (Cash on Delivery) , 2= SPAN Machine , 3= Paid , 4= AlshrouqPay\r\n  \"preparation_time\": 30,      // Optional, must be integer >= 0 if provided\r\n  \r\n  // Customer location\r\n  \"customer_lat\": 24.7136,     // Optional\r\n  \"customer_lng\": 46.6753,     // Optional\r\n  \"customer_address\": \"123 Main St\",  // Optional\r\n  // Customer details\r\n  \"customer_phone\": \"501234567\",  // Required, must follow KSA phone rules\r\n  \"customer_name\": \"Ahmed\",       // Required, must be string if provided\r\n  \r\n  // Delivery time (optional)\r\n  \"deliver_at\": \"2029-05-20 14:00:00\",  // Optional Must be a future datetime in \"Y-m-d H:i:s\" format\r\n  \r\n  // Additional details (optional)\r\n  \"details\": \"Extra sauce, no onions\"  // Optional, must be string if provided\r\n  // \"customer_national_address\":\"test address\" // Optional\r\n}"
                        }
                    }
                }
            }
        },
        "/api/integration/{token}/branches/create": {
            "post": {
                "tags": [
                    "Branches"
                ],
                "summary": "Create new branch",
                "description": null,
                "parameters": [],
                "responses": {
                    "200": {
                        "description": "Branch created successfully",
                        "content": {
                            "application/json": {
                                "example": {
                                    "status": true,
                                    "message": "Branch created successfully",
                                    "data": {
                                        "branch": {
                                            "id": 9999927651212,
                                            "name": "test 3",
                                            "client_branch_name": "test",
                                            "displayed_name": "test",
                                            "logo": "https://www.equinetmedia.com/hubfs/How-to-find-b2b-blog-images.png",
                                            "custom_id": null,
                                            "phone_number": "0512345678",
                                            "lat": 24.7135999999999995679900166578590869903564453125,
                                            "lng": 46.67530000000000001136868377216160297393798828125,
                                            "city": "Riyadh",
                                            "city_id": 2,
                                            "country": "Saudi Arabia",
                                            "country_id": 2,
                                            "street": "King Fahd Road",
                                            "landmark": "Near Kingdom Tower",
                                            "building": "12B",
                                            "floor": "3",
                                            "apartment": "301",
                                            "description": "Main branch",
                                            "is_active": true
                                        }
                                    }
                                }
                            }
                        }
                    }
                },
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "branch_lat": {
                                        "type": "number",
                                        "description": null,
                                        "example": "24.7136"
                                    },
                                    "branch_ln": {
                                        "type": "number",
                                        "description": null,
                                        "example": "46.6753"
                                    },
                                    "city": {
                                        "type": "string",
                                        "description": null,
                                        "example": "2"
                                    },
                                    "ingr_branch_name": {
                                        "type": "string",
                                        "description": null,
                                        "example": "test"
                                    },
                                    "phone_number": {
                                        "type": "string",
                                        "description": "Branch Phone number",
                                        "example": "0512345678"
                                    },
                                    "street": {
                                        "type": "string",
                                        "description": "Street name",
                                        "example": "King Fahd Road"
                                    },
                                    "landmark": {
                                        "type": "string",
                                        "description": "Landmark",
                                        "example": "Near Kingdom Tower"
                                    },
                                    "building": {
                                        "type": "string",
                                        "description": "Building",
                                        "example": "12B"
                                    },
                                    "floor": {
                                        "type": "string",
                                        "description": "Floor number",
                                        "example": "3"
                                    },
                                    "apartment": {
                                        "type": "string",
                                        "description": "Apartment number",
                                        "example": "301"
                                    },
                                    "description": {
                                        "type": "string",
                                        "description": "Description",
                                        "example": "Main branch"
                                    },
                                    "logo_url": {
                                        "type": "string",
                                        "description": "Branch logo",
                                        "example": "https://www.equinetmedia.com/hubfs/How-to-find-b2b-blog-images.png"
                                    }
                                },
                                "required": [
                                    "branch_lat",
                                    "branch_ln",
                                    "ingr_branch_name"
                                ]
                            },
                            "example": "{\r\n    \"branch_lat\": 24.7136, // Required | numeric\r\n    \"branch_lng\": 46.6753, // Required | numeric\r\n    // \"city\": 1,                         // Optional | integer, must exist in cities\r\n    \"ingr_branch_name\": \"test\", // Required | string\r\n    \"displayed_name\": \"test\", // Optional | string\r\n    //\"custom_id\": \"BR-001\", // Optional\r\n    \"phone_number\": \"0512345678\", // Optional\r\n    \"street\": \"King Fahd Road\", // Optional\r\n    \"landmark\": \"Near Kingdom Tower\", // Optional\r\n    \"building\": \"12B\", // Optional\r\n    \"floor\": \"3\", // Optional\r\n    \"apartment\": \"301\", // Optional\r\n    \"description\": \"Main branch\" // Optional\r\n    ,\r\n    \"logo_url\": \"https://www.equinetmedia.com/hubfs/How-to-find-b2b-blog-images.png\" // Optional\r\n}"
                        }
                    }
                }
            }
        },
        "https://{your-domain}/api/webhooks/HandleAlShrouqWebhook": {
            "post": {
                "tags": [
                    "Outbound Webhooks"
                ],
                "summary": "Order Created Webhook",
                "description": "Al-Shrouq posts this notification to each merchant's own webhook URL (every client registers a different callback in the dashboard) — not to Al-Shrouq servers and not a fixed base URL. Placeholder example: https://{your-domain}/api/webhooks/HandleAlShrouqWebhook. The Request Body is the data shape we send. Authorization = the token saved on the webhook settings. Whatever the merchant server returns is logged as-is.",
                "parameters": [
                    {
                        "name": "Content-Type",
                        "in": "header",
                        "required": false,
                        "description": "Content type we send: application/json",
                        "schema": {
                            "type": "string",
                            "default": null,
                            "example": "application/json"
                        }
                    },
                    {
                        "name": "Authorization",
                        "in": "header",
                        "required": false,
                        "description": "Auth key we send in the header. Value = the token field saved on your webhook settings (example: Bearer abc123). If no token is configured, this header is omitted.",
                        "schema": {
                            "type": "string",
                            "default": null,
                            "example": "Bearer YOUR_WEBHOOK_TOKEN"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Example merchant response (logged as-is)",
                        "content": {
                            "application/json": {
                                "example": "{\r\n    \"ok\": Success\r\n}"
                            }
                        }
                    }
                },
                "requestBody": {
                    "required": false,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "order_id": {
                                        "type": "integer",
                                        "description": "Al-Shrouq internal order ID",
                                        "example": "84997"
                                    },
                                    "client_order_id": {
                                        "type": "string",
                                        "description": "Merchant order reference",
                                        "example": "ORD-98432"
                                    },
                                    "status_id": {
                                        "type": "integer",
                                        "description": "Order status code (see Order Statuses section)",
                                        "example": "1"
                                    },
                                    "status_label": {
                                        "type": "string",
                                        "description": "Human-readable status label",
                                        "example": "Order created"
                                    },
                                    "customer_name": {
                                        "type": "string",
                                        "description": "Customer name",
                                        "example": "Ahmed"
                                    },
                                    "customer_phone": {
                                        "type": "string",
                                        "description": "Customer phone",
                                        "example": "0501234567"
                                    },
                                    "customer_lat": {
                                        "type": "string",
                                        "description": "Dropoff latitude",
                                        "example": "24.7136"
                                    },
                                    "customer_lng": {
                                        "type": "string",
                                        "description": "Dropoff longitude",
                                        "example": "46.6753"
                                    },
                                    "branch_id": {
                                        "type": "integer",
                                        "description": "Pickup branch ID",
                                        "example": "12"
                                    },
                                    "fees": {
                                        "type": "string",
                                        "description": "Delivery fees",
                                        "example": "13"
                                    },
                                    "value": {
                                        "type": "string",
                                        "description": "Order value",
                                        "example": "100.00"
                                    },
                                    "cod": {
                                        "type": "string",
                                        "description": "Cash on delivery amount",
                                        "example": "115"
                                    },
                                    "tracking_url": {
                                        "type": "string",
                                        "description": "Live tracking URL",
                                        "example": "https://alshrouqexpress.com/tracking/84997"
                                    },
                                    "driver": {
                                        "type": "object",
                                        "description": "Driver object (often null on create)",
                                        "example": "null"
                                    },
                                    "eta": {
                                        "type": "object",
                                        "description": "ETA in minutes for pickup and delivery",
                                        "example": "{\"pickup\":12,\"delivery\":28}"
                                    }
                                }
                            },
                            "example": {
                                "order_id": 5256258,
                                "customer_id": "",
                                "client_order_id": "KSA_kfc123_07Aug26_6479302",
                                "customer_name": "Test Customer",
                                "customer_phone": "8899889989",
                                "pickup_lat": "",
                                "pickup_lng": "",
                                "lat": "24.6575436485526",
                                "lng": "46.7103296693345",
                                "city": null,
                                "shop": "Americana KFC Test ",
                                "branch": "KFC test B1",
                                "branch_id": 9999927650772,
                                "branch_area": "",
                                "dropoff_area": "",
                                "dropoff_lat": "",
                                "dropoff_lng": "",
                                "tracking_code": "",
                                "tracking_url": "https://staging.alshrouqsse.org/tracking/eyJpdiI6IlkvS0VZUXVVSWM4N085T0ozQTI4cWc9PSIsInZhbHVlIjoiMUtyUm95bG5GeG5sQSsreHlJRXlaWElQc3NKZEFMNkt2MWJOYkMvaVJyTzcrSVIzT3ZEV1AraVIyYW5sdTNGNiIsIm1hYyI6ImM0MTEzMzVmYzE3YmY0ZTM3YTg3Y2I5NGJmZWQyYTcxMTMyNGY4MGU0ZjZhMDI4NzNkMDJjYWNlNWNjZGU1YWMiLCJ0YWciOiIifQ==",
                                "expected_pickup": "",
                                "expected_delivery": "",
                                "at_pickup": "",
                                "pickup": "",
                                "at_dropoff_at": "",
                                "dropoff_at": "",
                                "fees": "0",
                                "distance": "0",
                                "status": 4,
                                "status_id": 4,
                                "status_label": "Driver accepted the order",
                                "value": "13.01",
                                "cod": "13.01",
                                "payment_type_label": "COD",
                                "payment_type": 1,
                                "currency": "",
                                "details": "",
                                "created_at": "2026-09-23 10:11 AM",
                                "customer_address": null,
                                "pickup_poa": 0,
                                "pickup_poa_qrcode": "",
                                "dropoff_poa": 0,
                                "dropoff_poa_qrcode": "",
                                "driver": {
                                    "id": 6610,
                                    "name": "محمد احمد",
                                    "phone": "0500588630",
                                    "location": {
                                        "lat": "31.0961749",
                                        "lng": "29.7524133"
                                    },
                                    "status": "Busy"
                                },
                                "is_current": true,
                                "has_otp": false
                            }
                        }
                    }
                }
            }
        },
        "/api/integration/{token}/orders/cancel": {
            "post": {
                "tags": [
                    "Core Direct Orders Lifecycle"
                ],
                "summary": "Cancel order",
                "description": null,
                "parameters": [],
                "responses": {
                    "200": {
                        "description": "Order Picked Up Cancel Request Submitted",
                        "content": {
                            "application/json": {
                                "example": {
                                    "message": "ok , Order Picked Up Cancel Request Submitted"
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "Order not found or has already been cancelled or cannot be cancelled",
                        "content": {
                            "application/json": {
                                "example": {
                                    "error": "Order not found or has already been cancelled or cannot be cancelled."
                                }
                            }
                        }
                    }
                },
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "order_id": {
                                        "type": "string",
                                        "description": "Order number",
                                        "example": "\"5254700\""
                                    },
                                    "cancellation_reason": {
                                        "type": "string",
                                        "description": "Cancel reason",
                                        "example": "Outside Zone"
                                    }
                                },
                                "required": [
                                    "order_id"
                                ]
                            },
                            "example": {
                                "order_id": "5254700"
                            }
                        }
                    }
                }
            }
        },
        "/api/integration/{token}/branches": {
            "get": {
                "tags": [
                    "Branches"
                ],
                "summary": "Branch list",
                "description": null,
                "parameters": [],
                "responses": {
                    "200": {
                        "description": "Branch retrieved successfully",
                        "content": {
                            "application/json": {
                                "example": "{\r\n  \"status\": true,\r\n  \"message\": \"Branches retrieved successfully\",\r\n  \"data\": {\r\n    \"branches\": [\r\n     {\r\n  \"id\": 9999927651208,\r\n            \"name\": \"test 12\",\r\n            \"client_branch_name\": \"test\",\r\n            \"displayed_name\": \"test\",\r\n            \"logo\": \"https://alshrouqdelivery.b-cdn.net/https://www.equinetmedia.com/hubfs/How-to-find-b2b-blog-images.png\",\r\n            \"custom_id\": \"BR-001\",\r\n            \"phone_number\": \"0512345678\",\r\n            \"lat\": 24.7135999999999995679900166578590869903564453125,\r\n            \"lng\": 46.67530000000000001136868377216160297393798828125,\r\n            \"city\": \"Riyadh\",\r\n            \"city_id\": 2,\r\n            \"country\": \"Saudi Arabia\",\r\n            \"country_id\": 2,\r\n            \"street\": \"King Fahd Road\",\r\n            \"landmark\": \"Near Kingdom Tower\",\r\n            \"building\": \"12B\",\r\n            \"floor\": \"3\",\r\n            \"apartment\": \"301\",\r\n            \"description\": \"Main branch\",\r\n            \"is_active\": true\r\n},\r\n {\r\n  \"id\": 9999927651209,\r\n            \"name\": \"test 13\",\r\n            \"client_branch_name\": \"test\",\r\n            \"displayed_name\": \"test\",\r\n            \"logo\": \"https://alshrouqdelivery.b-cdn.net/https://www.equinetmedia.com/hubfs/How-to-find-b2b-blog-images.png\",\r\n            \"custom_id\": \"BR-001\",\r\n            \"phone_number\": \"0512345678\",\r\n            \"lat\": 24.7135999999999995679900166578590869903564453125,\r\n            \"lng\": 46.67530000000000001136868377216160297393798828125,\r\n            \"city\": \"Riyadh\",\r\n            \"city_id\": 2,\r\n            \"country\": \"Saudi Arabia\",\r\n            \"country_id\": 2,\r\n            \"street\": \"King Fahd Road\",\r\n            \"landmark\": \"Near Kingdom Tower\",\r\n            \"building\": \"12B\",\r\n            \"floor\": \"3\",\r\n            \"apartment\": \"301\",\r\n            \"description\": \"Main branch\",\r\n            \"is_active\": true\r\n},\r\n {\r\n  \"id\": 99999276512010,\r\n            \"name\": \"test 14\",\r\n            \"client_branch_name\": \"test\",\r\n            \"displayed_name\": \"test\",\r\n            \"logo\": \"https://alshrouqdelivery.b-cdn.net/https://www.equinetmedia.com/hubfs/How-to-find-b2b-blog-images.png\",\r\n            \"custom_id\": \"BR-001\",\r\n            \"phone_number\": \"0512345678\",\r\n            \"lat\": 24.7135999999999995679900166578590869903564453125,\r\n            \"lng\": 46.67530000000000001136868377216160297393798828125,\r\n            \"city\": \"Riyadh\",\r\n            \"city_id\": 2,\r\n            \"country\": \"Saudi Arabia\",\r\n            \"country_id\": 2,\r\n            \"street\": \"King Fahd Road\",\r\n            \"landmark\": \"Near Kingdom Tower\",\r\n            \"building\": \"12B\",\r\n            \"floor\": \"3\",\r\n            \"apartment\": \"301\",\r\n            \"description\": \"Main branch\",\r\n            \"is_active\": true\r\n},\r\n {\r\n  \"id\": 99999276512011,\r\n            \"name\": \"test 15\",\r\n            \"client_branch_name\": \"test\",\r\n            \"displayed_name\": \"test\",\r\n            \"logo\": \"https://alshrouqdelivery.b-cdn.net/https://www.equinetmedia.com/hubfs/How-to-find-b2b-blog-images.png\",\r\n            \"custom_id\": \"BR-001\",\r\n            \"phone_number\": \"0512345678\",\r\n            \"lat\": 24.7135999999999995679900166578590869903564453125,\r\n            \"lng\": 46.67530000000000001136868377216160297393798828125,\r\n            \"city\": \"Riyadh\",\r\n            \"city_id\": 2,\r\n            \"country\": \"Saudi Arabia\",\r\n            \"country_id\": 2,\r\n            \"street\": \"King Fahd Road\",\r\n            \"landmark\": \"Near Kingdom Tower\",\r\n            \"building\": \"12B\",\r\n            \"floor\": \"3\",\r\n            \"apartment\": \"301\",\r\n            \"description\": \"Main branch\",\r\n            \"is_active\": true\r\n},\r\n\r\n    ],\r\n    \"pagination\": {\r\n      \"current_page\": 1,\r\n      \"last_page\": 3,\r\n      \"per_page\": 10,\r\n      \"total\": 30,\r\n      \"next_page_url\": \"https://staging.alshrouqsse.org/api/integration/h0v6Xb9pwZvuTQL1CY0V3dXbfygQkO06Z277ojUYpZpqKL4CXP44HIjOmpIXRdFMH5mXOVgrmv6DXNnI/branches?page=2\",\r\n      \"prev_page_url\": null\r\n    }\r\n  }\r\n}"
                            }
                        }
                    }
                }
            }
        },
        "/api/integration/{token}/orders/get": {
            "post": {
                "tags": [
                    "Core Direct Orders Lifecycle"
                ],
                "summary": "Get Specific Order",
                "description": null,
                "parameters": [],
                "responses": {
                    "200": {
                        "description": "Response for 200",
                        "content": {
                            "application/json": {
                                "example": {
                                    "data": {
                                        "order_id": 5254071,
                                        "client_order_id": "1231125",
                                        "customer_name": "Ahmed",
                                        "customer_phone": "501234567",
                                        "customer_lat": "24.7136",
                                        "customer_lng": "46.6753",
                                        "customer_address": "123 Main St",
                                        "branch_name": "Test alaraab",
                                        "branch_id": 9999927650791,
                                        "fees": "15",
                                        "distance": "0",
                                        "status_id": 22,
                                        "status_label": "Client Cancellation Request is being Proccessed",
                                        "value": "100.50",
                                        "tracking_url": "https://staging.alshrouqsse.org/tracking/eyJpdiI6Im1NcmxRRThzWVpWOHowWEwrQXYwQkE9PSIsInZhbHVlIjoiUzZLNVhCTUxxWERYL2w2b3UwVGtnMjF2aXlBYzdnaFU4emdXYkFQTnpXMnJsYTVYamxBWk1VSlcxREI1WVQxdiIsIm1hYyI6IjFjOWY1NmJhZjMyYmQ3NGQyY2I0OWIzMzZjODM4MmRmMGI2YmYzN2ZkNWM0MTM3MDRiNmM0YjMzMzIxOTliOGIiLCJ0YWciOiIifQ==",
                                        "cod": "115.5",
                                        "payment_type_label": "COD",
                                        "payment_type": 1,
                                        "details": "Extra sauce, no onions",
                                        "created_at": "2026-07-26 1:47 PM",
                                        "driver_accepted_time": null,
                                        "arrived_to_pickup_time": null,
                                        "picked_up_time": null,
                                        "arrived_to_dropoff_time": null,
                                        "delivered_at": null,
                                        "driver": null,
                                        "has_otp": false,
                                        "has_pickup_code": false,
                                        "pick_up_code": null,
                                        "otp": null,
                                        "invoice_url": "",
                                        "phone_code": null,
                                        "country_id": 2,
                                        "service_type_value": 0,
                                        "service_type_label": "On Demand",
                                        "current_status_timestamp": "2026-07-26T10:48:40.000000Z",
                                        "previous_status_timestamp": "2026-07-26T10:47:08.000000Z",
                                        "weight": "1.000",
                                        "eta": {
                                            "pickup": 0,
                                            "delivery": 0
                                        }
                                    }
                                }
                            }
                        }
                    }
                },
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "order_id": {
                                        "type": "integer",
                                        "description": "Order number required",
                                        "example": "5254808"
                                    }
                                },
                                "required": [
                                    "order_id"
                                ]
                            },
                            "example": {
                                "order_id": 5254808
                            }
                        }
                    }
                }
            }
        },
        "/api/integration/{token}/cities?country_id=2": {
            "post": {
                "tags": [
                    "Branches"
                ],
                "summary": "Cities list",
                "description": null,
                "parameters": [],
                "responses": {
                    "200": {
                        "description": "Response for 200",
                        "content": {
                            "application/json": {
                                "example": "{\r\n    \"id\": 2,\r\n    \"name\": \"Riyadh\",\r\n    \"lat\": \"24.714061319485616\",\r\n    \"lng\": \"46.67583405296055\",\r\n    \"country\": \"Saudi Arabia\",\r\n    \"spl_id\": \"3\",\r\n    \"spl_name\": \"RIYADH\",\r\n    \"spl_region_id\": \"1\",\r\n    \"distance_km\": null\r\n  },\r\n  {\r\n    \"id\": 3,\r\n    \"name\": \"Jeddah\",\r\n    \"lat\": \"21.529183147129466\",\r\n    \"lng\": \"39.17986254008007\",\r\n    \"country\": \"Saudi Arabia\",\r\n    \"spl_id\": \"18\",\r\n    \"spl_name\": \"JEDDAH\",\r\n    \"spl_region_id\": \"2\",\r\n    \"distance_km\": null\r\n  }"
                            }
                        }
                    }
                }
            }
        },
        "/api/integration/{token}/orders/track-order": {
            "post": {
                "tags": [
                    "Core Direct Orders Lifecycle"
                ],
                "summary": "Track order",
                "description": null,
                "parameters": [],
                "responses": {
                    "200": {
                        "description": "Response for 200",
                        "content": {
                            "application/json": {
                                "example": {
                                    "data": {
                                        "order_id": 5254983,
                                        "client_order_id": "Test-create-01",
                                        "branch": {
                                            "lat": "24.7136",
                                            "lng": "46.6753"
                                        },
                                        "customer": {
                                            "lat": "24.7136",
                                            "lng": "46.6753"
                                        },
                                        "driver": null,
                                        "eta": {
                                            "pickup": 0,
                                            "delivery": 0
                                        }
                                    }
                                }
                            }
                        }
                    }
                },
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "order_id": {
                                        "type": "integer",
                                        "description": null,
                                        "example": "5254808"
                                    }
                                },
                                "required": [
                                    "order_id"
                                ]
                            },
                            "example": {
                                "order_id": 5254808
                            }
                        }
                    }
                }
            }
        },
        "/api/integration/{token}/orders/update": {
            "post": {
                "tags": [
                    "Core Direct Orders Lifecycle"
                ],
                "summary": "Update specific order",
                "description": null,
                "parameters": [],
                "responses": {
                    "200": {
                        "description": "Order Updated successfully",
                        "content": {
                            "application/json": {
                                "example": {
                                    "order_id": 5254072,
                                    "client_order_id": "123115",
                                    "customer_name": "Ahmed",
                                    "customer_phone": "501234567",
                                    "customer_lat": 24.7135999999999995679900166578590869903564453125,
                                    "customer_lng": 46.67530000000000001136868377216160297393798828125,
                                    "customer_address": "123 Main St",
                                    "branch_name": "Test alaraab",
                                    "branch_id": 9999927650791,
                                    "fees": "15",
                                    "distance": "0",
                                    "status_id": 23,
                                    "status_label": "Order Created",
                                    "value": "100.5",
                                    "tracking_url": "https://staging.alshrouqsse.org/tracking/eyJpdiI6Ik1aY0JtakgwZnI2R3FJbG9oNnBMT0E9PSIsInZhbHVlIjoiL1VMUnBmZDBpeUZKR0R5M2dUWDFBQ0RFOENZRDlRT3c1ZWhtM2lET2JLQitkaUVhWWNwU3dETmJmYkxKQmMrVSIsIm1hYyI6IjRmNjEwNjMwNjcwZTAwYWYxNzJiZmJlODMwMzA3MTM5OTdmZmNkOWIzMDY1M2U1NTdmZjRkOTRhMTYxYzkxYmIiLCJ0YWciOiIifQ==",
                                    "cod": "115.5",
                                    "payment_type_label": "COD",
                                    "payment_type": 1,
                                    "details": "Extra sauce, no onions",
                                    "created_at": "2026-07-26 1:49 PM",
                                    "driver_accepted_time": null,
                                    "arrived_to_pickup_time": null,
                                    "picked_up_time": null,
                                    "arrived_to_dropoff_time": null,
                                    "delivered_at": null,
                                    "driver": null,
                                    "has_otp": false,
                                    "has_pickup_code": false,
                                    "pick_up_code": null,
                                    "otp": null,
                                    "invoice_url": "",
                                    "phone_code": null,
                                    "country_id": 2,
                                    "service_type_value": 0,
                                    "service_type_label": "On Demand",
                                    "current_status_timestamp": "2026-07-26T10:49:23.000000Z",
                                    "previous_status_timestamp": "2026-07-26T10:49:11.000000Z",
                                    "weight": "1.000",
                                    "eta": {
                                        "pickup": 0,
                                        "delivery": 0
                                    }
                                }
                            }
                        }
                    }
                },
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "order_id": {
                                        "type": "string",
                                        "description": "Order number",
                                        "example": "751156"
                                    },
                                    "details": {
                                        "type": "string",
                                        "description": "Order details",
                                        "example": "Extra sauce, no onions"
                                    },
                                    "value": {
                                        "type": "number",
                                        "description": "Order value",
                                        "example": "100.5"
                                    },
                                    "payment_type": {
                                        "type": "integer",
                                        "description": "Payment type",
                                        "example": "1 , 2 , 3 , 4"
                                    },
                                    "customer_lat": {
                                        "type": "number",
                                        "description": null,
                                        "example": "24.7136"
                                    },
                                    "customer_lng": {
                                        "type": "number",
                                        "description": null,
                                        "example": "46.6753"
                                    },
                                    "customer_address": {
                                        "type": "string",
                                        "description": "Customer address",
                                        "example": "123 Main St"
                                    },
                                    "customer_phone": {
                                        "type": "string",
                                        "description": "Customer phone",
                                        "example": "501234567"
                                    },
                                    "customer_name": {
                                        "type": "string",
                                        "description": "Customer name",
                                        "example": "Ahmed"
                                    }
                                },
                                "required": [
                                    "order_id",
                                    "details",
                                    "value",
                                    "payment_type",
                                    "customer_lat",
                                    "customer_lng",
                                    "customer_address",
                                    "customer_phone",
                                    "customer_name"
                                ]
                            },
                            "example": "{\r\n    \"order_id\": 5254072,\r\n    // Additional details (optional)\r\n    \"details\": \"Extra sauce, no onions\",  // Optional, must be string if provided\r\n     \"value\": 100.50,           // Optional, must be numeric if provided\r\n     \"payment_type\": 1,          // Optional, must be either // 1 = CASH, 2 = CREDIT\r\n // Customer location\r\n    \"customer_lat\": 24.7136,    // Optional \r\n    \"customer_lng\": 46.6753,    // Optional \r\n    \"customer_address\": \"123 Main St\",   // Optional \r\n    // Customer details\r\n    \"customer_phone\": \"501234567\",  // Optional, must follow KSA phone rules\r\n    \"customer_name\": \"Ahmed\"          // Optional, must be string if provided\r\n}"
                        }
                    }
                }
            }
        },
        "/api/integration/{{api_token}}/orders/get-rate": {
            "post": {
                "tags": [
                    "Core Direct Orders Lifecycle"
                ],
                "summary": "Order rate",
                "description": null,
                "parameters": [],
                "responses": {
                    "200": {
                        "description": "Rate retrieved successfully",
                        "content": {
                            "application/json": {
                                "example": {
                                    "status": true,
                                    "message": "Rate retrieved successfully",
                                    "data": {
                                        "distance": 13.1099999999999994315658113919198513031005859375,
                                        "fees": 15,
                                        "extra_fees": 3.109999999999999875655021241982467472553253173828125,
                                        "total_fees": 18.1099999999999994315658113919198513031005859375
                                    }
                                }
                            }
                        }
                    }
                },
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "pickup_id": {
                                        "type": "integer",
                                        "description": "Branch id",
                                        "example": "9999927650903"
                                    },
                                    "delivery_lat": {
                                        "type": "number",
                                        "description": null,
                                        "example": "24.75"
                                    },
                                    "delivery_lng": {
                                        "type": "number",
                                        "description": null,
                                        "example": "46.70"
                                    }
                                },
                                "required": [
                                    "pickup_id",
                                    "delivery_lat",
                                    "delivery_lng"
                                ]
                            },
                            "example": {
                                "pickup_id": 9999927650903,
                                "delivery_lat": 24.75,
                                "delivery_lng": 46.7000000000000028421709430404007434844970703125
                            }
                        }
                    }
                }
            }
        },
        "/api/integration/{token}/orders/cancel-reasons": {
            "get": {
                "tags": [
                    "Core Direct Orders Lifecycle"
                ],
                "summary": "Cancel reason",
                "description": null,
                "parameters": [],
                "responses": {
                    "200": {
                        "description": "Cancel reasons retrieved successfully",
                        "content": {
                            "application/json": {
                                "example": {
                                    "status": true,
                                    "message": "Cancel reasons retrieved successfully",
                                    "data": [
                                        {
                                            "id": 4,
                                            "name": "Customer Not Responding"
                                        },
                                        {
                                            "id": 11,
                                            "name": "Branch cancel orders"
                                        },
                                        {
                                            "id": 12,
                                            "name": "RTO"
                                        }
                                    ]
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}