# Fetch Deliveries

## Fetch Deliveries

<mark style="color:blue;">`GET`</mark> `{baseUrl}/deliveries`

This endpoint retrieves all deliveries booked under your business. You can apply filters using the query parameters outlined below:

* **`batchId`**: Filters deliveries by the specified batch ID.
* **`trackingId`**: Filters deliveries by the specified tracking ID.
* **`customer`**: Filters deliveries associated with a specific customer.

#### Query Parameters

| Name            | Type   | Description                                     |
| --------------- | ------ | ----------------------------------------------- |
| batchId         | string | Batch Id generated for a delivery request       |
| trackingId      | string | Tracking Id generated for a delivery request    |
| externalOrderId | string | External order id                               |
| limit           | number | The result limits for pagination, default is 15 |
| page            | number | page option for pagination, default is 1        |
| customer        | string | customer id                                     |

#### Headers

| Name                                          | Type   | Description |
| --------------------------------------------- | ------ | ----------- |
| app\_id<mark style="color:red;">\*</mark>     | String |             |
| app\_secret<mark style="color:red;">\*</mark> | String |             |

### Sample Success Data

```
// Sample Request information
Url: https://sandbox.sendstack.africa/api/v1/deliveries
Method: GET
Headers: 
 - app_id: "your app_id"
 - app_secret: "your app_secret"
```

```json
// Sample Response Body - 200 OK
{
    "status": true,
    "message": "Deliveries successfully retrieved",
    "data": {
        "drops": [
            {
                "id": "65b8c2c734d8cd1be099fd45",
                "deliveryId": "65b8c2c734d8cd1be099fd47",
                "status": "PENDING",
                "paymentStatus": "PENDING",
                "trackingId": "E033LM",
                "batchId": "T4SYZ3",
                "customer": {
                    "id": "670f5170d244e83e2424919e",
                    "name": "Bob",
                    "phone": "+2348151911111"
                },
                "customFields": { 
                    "pickup": {
                        "pickup_house_number": 1
                    },
                    "drop": {
                        "dropoff_house_number": 2
                    }
                 }
           }
           //...trunated for brevity
}
```

### Filter By batchId

```
// Sample Request information
Url: https://sandbox.sendstack.africa/api/v1/deliveries?batchId={{batchId}}
Method: GET
Headers: 
 - app_id: "your app_id"
 - app_secret: "your app_secret"
Query parameter:
 - batchId = "delivery batchId"
```

```json
// Sample Response Body - 200 OK
{
    "status": true,
    "message": "Deliveries successfully retrieved",
    "data": {
        "drops": [
            {
                "id": "65b8c02734d8cd1be099fcf1",
                "status": "PENDING",
                "paymentStatus": "PENDING",
                "trackingId": "KH3I65",
                "batchId": "MFUD2A",
                "address": "95975 Barton Fields",
                "pickupName": "Toni Dicki PhD",
                "pickupNumber": "+2348017126895",
                "altPickupNumber": "+2348033000000",
                "pickupLga": "Yaba - Makoko",
                "pickupState": "Lagos",
                "recipientName": "Kabir",
                "recipientNumber": "+23490234500690",
                "recipientLga": "Yaba - Makoko",
                "amount": 1500,
                "estimatedPickupWindow": {
                    "date": "2024-10-27T08:00:00.000Z",
                    "start": "2024-10-27T08:00:00.000Z",
                    "end": "2024-10-27T13:00:00.000Z"
                },
                //...truncated for brevity
    }
}
```

### Filter By a Specific customer

```
// Sample Request information
Url: https://sandbox.sendstack.africa/api/v1/deliveries?customer={{customerId}}
Method: GET
Headers: 
 - app_id: "your app_id"
 - app_secret: "your app_secret"
Query parameter:
 - customer = "customerId"
```

```
// Sample success Response Body - 200 OK
{
    "status": true,
    "message": "Deliveries successfully retrieved",
    "data": {
        "drops": [
            {
                "id": "65b8c02734d8cd1be099fcf1",
                "status": "PENDING",
                "paymentStatus": "PENDING",
                "trackingId": "KH3I65",
                "batchId": "MFUD2A",
                "address": "95975 Barton Fields",
                "pickupName": "Toni Dicki PhD",
                "pickupNumber": "+2348017126895",
                "altPickupNumber": "+2348033000000",
                "pickupLga": "Yaba - Makoko",
                "pickupState": "Lagos",
                "recipientName": "Kabir",
                "recipientNumber": "+23490234500690",
                "recipientLga": "Yaba - Makoko",
                "amount": 1500,
                "customer": {
                    "id": "670f5170d244e83e2424919e",
                    "name": "Bob",
                    "phone": "+2348151911111"
                }
                //...truncated for brevity
    }
}
```
