Deliveries

The Kourier API allows you to create and manage deliveries efficiently. This section details how to interact with the delivery endpoints.

1. Create a Delivery

Use this endpoint to create a new delivery in the system.

URL

POST https://api.kourier.com/v1/deliveries

Headers

Authorization: Bearer YOUR_API_KEY
Content-Type: application/json

Request Body

{
  "pickup_address": "1234 Main St",
  "delivery_address": "5678 Elm St",
  "package_details": {
    "weight": 2.5,
    "description": "Books"
  },
  "receiver_contact": {
    "name": "John Doe",
    "phone": "+1234567890"
  },
  "amount_to_collect": 1000
}

Response Example

{
  "delivery_id": "abc123",
  "status": "created",
  "estimated_delivery_time": "2024-09-14T15:00:00Z"
}

2. Get Delivery Status

Retrieve the current status of an existing delivery.

URL

GET https://api.kourier.com/v1/deliveries/{delivery_id}

Headers

Authorization: Bearer YOUR_API_KEY

Response Example

{
  "delivery_id": "abc123",
  "status": "in_transit",
  "estimated_delivery_time": "2024-09-14T15:00:00Z"
}

3. Cancel a Delivery

Cancel a delivery if it hasn’t been picked up yet.

URL

POST https://api.kourier.com/v1/deliveries/{delivery_id}/cancel

Headers

Authorization: Bearer YOUR_API_KEY
Content-Type: application/json

Response Example

{
  "delivery_id": "abc123",
  "status": "cancelled"
}