> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.milenow.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.milenow.com/_mcp/server.

# Assign your driver to a trip

POST https://lastmile.milenow.com/index.php/api/v1/partners/transporters/trips/{tripId}/driver
Content-Type: application/json

Transporter token. Assigns one of your drivers to a trip outsourced to you, before it starts. You can change the driver the same way until the trip starts. The trip status becomes `4 Dispatch` and the ETAs are recalculated.

Reference: https://docs.milenow.com/ftl-trips/api-reference/transporter-api/assign-transporter-trip-driver

## Authentication

- `Authorization` header (bearer token, required) — Send `Authorization: Bearer <token>`. Company endpoints take the company API token from `POST /api/v1/partners/login`. `/transporters` endpoints take the transporter token from `POST /api/v1/partners/transporters/login`. You can also send the token as an `access_token` query parameter or body field.

## Request

### Path parameters

- `tripId` (integer, required) — Trip id.

### Body (application/json)

This endpoint expects an AssignTransporterTripDriverRequest.

- `driver_id` (integer, required) — A driver from list your drivers.

## Response

### 200

Success

- `status` (integer, required)
- `msg` (string, required)
- `msgs` (list of string, required)
- `data` (TripWithWarnings, required)

## Errors

### 401 Unauthorized Error

Missing, invalid or expired token.

- `status` (integer, required) — Same as the HTTP status code.
- `msg` (string, required) — Summary of the problem. When there are several problems it says how many.
- `msgs` (list of string, required) — Every problem found. Validation lists all problems at once, so fix them all before you retry.
- `data` (list of any, required) — Always an empty list on errors.

### 404 Not Found Error

The trip is not outsourced to you.

- `status` (integer, required) — Same as the HTTP status code.
- `msg` (string, required) — Summary of the problem. When there are several problems it says how many.
- `msgs` (list of string, required) — Every problem found. Validation lists all problems at once, so fix them all before you retry.
- `data` (list of any, required) — Always an empty list on errors.

### 409 Conflict Error

The driver is busy, or the trip has started.

- `status` (integer, required) — Same as the HTTP status code.
- `msg` (string, required) — Summary of the problem. When there are several problems it says how many.
- `msgs` (list of string, required) — Every problem found. Validation lists all problems at once, so fix them all before you retry.
- `data` (list of any, required) — Always an empty list on errors.

### 412 Precondition Failed Error

Missing driver, or not one of your drivers.

- `status` (integer, required) — Same as the HTTP status code.
- `msg` (string, required) — Summary of the problem. When there are several problems it says how many.
- `msgs` (list of string, required) — Every problem found. Validation lists all problems at once, so fix them all before you retry.
- `data` (list of any, required) — Always an empty list on errors.

### 429 Too Many Requests Error

Rate limit reached. Wait `Retry-After` seconds.

- `status` (integer, required) — Same as the HTTP status code.
- `msg` (string, required) — Summary of the problem. When there are several problems it says how many.
- `msgs` (list of string, required) — Every problem found. Validation lists all problems at once, so fix them all before you retry.
- `data` (list of any, required) — Always an empty list on errors.

## Types

### TripWithWarnings

- `id` (integer, optional) — Trip id.
- `type` (enum, optional) — `round_trip` when the trip has a return stop, otherwise `outbound`.
  - Allowed values: `outbound`, `round_trip`
- `status` (TripWithWarningsStatus, optional, nullable) — Trip status, or `null` until a driver is assigned. See [trip statuses](/ftl-trips/business-rules#trip-statuses).
- `created_at` (string, optional, nullable) — Local date and time in your company time zone, `Y-m-d H:i:s`, no offset.
- `outbound_stops` (integer, optional)
- `return_stops` (integer, optional)
- `driver` (Driver, optional)
- `partner` (TripWithWarningsPartner, optional, nullable) — Transporter the trip is outsourced to in the Mile web app.
- `offer` (TripOfferState, optional) — Latest offer sent from the Mile web app for this trip, or `null` if it was never offered.
- `busy_from` (string, optional, nullable) — When the truck starts work for this trip, from the ETA plan. Local date and time in your company time zone, `Y-m-d H:i:s`, no offset.
- `busy_to` (string, optional, nullable) — When the truck is back at base, from the ETA plan. Local date and time in your company time zone, `Y-m-d H:i:s`, no offset.
- `stops` (list of Stop, optional) — Stops in route order.
- `eta` (EtaPlan, optional) — Estimated day-by-day plan for the truck. See [ETA plan](/ftl-trips/business-rules#eta-plan).
- `warnings` (list of string, optional) — Non-blocking problems, for example `ETAs could not be calculated: ...`. The change was saved.

### TripWithWarningsStatus

Trip status, or `null` until a driver is assigned. See [trip statuses](/ftl-trips/business-rules#trip-statuses).

- `id` (integer, optional)
- `name` (string, optional)

### Driver

- `id` (integer, optional)
- `name` (string, optional)
- `phone` (string, optional, nullable)
- `vehicle` (DriverVehicle, optional, nullable)

### TripWithWarningsPartner

Transporter the trip is outsourced to in the Mile web app.

- `id` (integer, optional)
- `name` (string, optional)

### TripOfferState

Latest offer sent from the Mile web app for this trip, or `null` if it was never offered.

- `status` (string, optional) — Latest offer for this trip: `offered`, `accepted`, `assigned`, `rejected`, `expired`, `withdrawn` or `not_accepted`.
- `partner` (string, optional, nullable) — Transporter of the latest offer.
- `expires_at` (string, optional, nullable) — Set while `status` is `offered`. Local date and time in your company time zone, `Y-m-d H:i:s`, no offset.
- `batch_id` (integer, optional)

### Stop

- `order_id` (long, optional) — Stop id. Send it to [remove a stop](/ftl-trips/guides/manage-stops#remove-a-stop).
- `tracking_no` (string, optional) — Stop tracking number, based on the first container number.
- `leg` (enum, optional)
  - Allowed values: `outbound`, `return`
- `stop_no` (integer, optional) — Position within its leg, in the order you added the stops.
- `pickup_sequence` (integer, optional, nullable) — Position of the pickup in the optimized route.
- `delivery_sequence` (integer, optional, nullable) — Position of the delivery in the optimized route.
- `status` (StopStatus, optional, nullable) — Stop status. `1 Scheduled` means not started.
- `pickup` (StopPickup, optional)
- `delivery` (StopDelivery, optional)
- `staging_warehouse` (StopStagingWarehouse, optional, nullable) — Warehouse where the container waits overnight when delivery is on a later day than pickup.
- `eta` (string, optional, nullable) — Estimated arrival at the delivery address. Local date and time in your company time zone, `Y-m-d H:i:s`, no offset.
- `shipment` (Ftl, optional)

### EtaPlan

Estimated day-by-day plan for the truck. See [ETA plan](/ftl-trips/business-rules#eta-plan).

- `calculated_at` (string, optional, nullable) — Local date and time in your company time zone, `Y-m-d H:i:s`, no offset.
- `busy_from` (string, optional, nullable) — Local date and time in your company time zone, `Y-m-d H:i:s`, no offset.
- `busy_to` (string, optional, nullable) — Local date and time in your company time zone, `Y-m-d H:i:s`, no offset.
- `total_km` (double, optional)
- `total_drive_min` (integer, optional)
- `late` (boolean, optional) — `true` when any stop is late.
- `days` (list of EtaPlanDaysItems, optional)

### DriverVehicle

- `id` (integer, optional)
- `name` (string, optional)
- `plate` (string, optional, nullable)

### StopStatus

Stop status. `1 Scheduled` means not started.

- `id` (integer, optional)
- `name` (string, optional)

### StopPickup

- `address` (string, optional, nullable)
- `latitude` (any, optional) — Latitude. Decimal degrees. Can be a number or a numeric string.
- `longitude` (any, optional) — Longitude. Decimal degrees. Can be a number or a numeric string.
- `from` (string, optional, nullable) — Local date and time in your company time zone, `Y-m-d H:i:s`, no offset.
- `to` (string, optional, nullable) — Local date and time in your company time zone, `Y-m-d H:i:s`, no offset.

### StopDelivery

- `name` (string, optional) — Consignee name. Hidden on an open offer.
- `phone` (string, optional) — Hidden on an open offer.
- `address` (string, optional, nullable)
- `latitude` (any, optional) — Latitude. Decimal degrees. Can be a number or a numeric string.
- `longitude` (any, optional) — Longitude. Decimal degrees. Can be a number or a numeric string.
- `from` (string, optional, nullable) — Local date and time in your company time zone, `Y-m-d H:i:s`, no offset.
- `to` (string, optional, nullable) — Local date and time in your company time zone, `Y-m-d H:i:s`, no offset.

### StopStagingWarehouse

Warehouse where the container waits overnight when delivery is on a later day than pickup.

- `id` (integer, optional)
- `name` (string, optional)

### Ftl

- `id` (integer, optional) — FTL id. Use it as `shipment_id` in a stop.
- `shipment_no` (string, optional)
- `tracking_no` (string, optional)
- `bl_no` (string, optional)
- `vessel` (string, optional, nullable)
- `voyage_no` (string, optional, nullable)
- `shipping_line` (FtlShippingLine, optional, nullable)
- `status` (FtlStatus, optional, nullable) — FTL status. New FTLs are `Awaiting Approval`; a driver assignment moves them to `Local Dispatch`.
- `created_on` (string, optional, nullable) — Pickup day. Local date and time in your company time zone, `Y-m-d H:i:s`, no offset.
- `expected_on` (string, optional, nullable) — Delivery day. Local date and time in your company time zone, `Y-m-d H:i:s`, no offset.
- `merchant` (FtlMerchant, optional, nullable) — Merchant linked to the customer.
- `consigner` (Party, optional) — Customer (consigner) or consignee. On an open offer a transporter sees only `address`, `latitude` and `longitude`.
- `consignee` (Party, optional) — Customer (consigner) or consignee. On an open offer a transporter sees only `address`, `latitude` and `longitude`.
- `pickup_from_port` (boolean, optional)
- `destination_port` (FtlDestinationPort, optional, nullable)
- `warehouse` (FtlWarehouse, optional, nullable)
- `is_direct_delivery` (boolean, optional) — `true` when the FTL has no warehouse.
- `containers` (list of Container, optional)

### EtaPlanDaysItems

- `date` (string, optional)
- `busy_from` (string, optional, nullable) — Local date and time in your company time zone, `Y-m-d H:i:s`, no offset.
- `busy_to` (string, optional, nullable) — Local date and time in your company time zone, `Y-m-d H:i:s`, no offset.
- `km` (double, optional)
- `drive_min` (integer, optional)
- `late` (boolean, optional)
- `stops` (list of EtaPlanDaysItemsStopsItems, optional)

### FtlShippingLine

- `id` (integer, optional)
- `name` (string, optional)

### FtlStatus

FTL status. New FTLs are `Awaiting Approval`; a driver assignment moves them to `Local Dispatch`.

- `id` (integer, optional)
- `name` (string, optional)

### FtlMerchant

Merchant linked to the customer.

- `id` (integer, optional)
- `short_name` (string, optional)
- `long_name` (string, optional)
- `address` (string, optional, nullable)
- `latitude` (any, optional) — Latitude. Decimal degrees. Can be a number or a numeric string.
- `longitude` (any, optional) — Longitude. Decimal degrees. Can be a number or a numeric string.

### Party

Customer (consigner) or consignee. On an open offer a transporter sees only `address`, `latitude` and `longitude`.

- `id` (integer, optional) — Customer id. Reuse it as `customer.id` or `consignee.id`.
- `name` (string, optional)
- `address` (string, optional, nullable)
- `latitude` (any, optional) — Latitude. Decimal degrees. Can be a number or a numeric string.
- `longitude` (any, optional) — Longitude. Decimal degrees. Can be a number or a numeric string.
- `contact_person_name` (string, optional, nullable)
- `contact_person_contact` (string, optional, nullable) — Phone.
- `contact_person_email` (string, optional, nullable)

### FtlDestinationPort

- `id` (integer, optional)
- `name` (string, optional)
- `unlocode` (string, optional, nullable)
- `latitude` (any, optional) — Latitude. Decimal degrees. Can be a number or a numeric string.
- `longitude` (any, optional) — Longitude. Decimal degrees. Can be a number or a numeric string.

### FtlWarehouse

- `id` (integer, optional)
- `name` (string, optional)
- `address` (string, optional, nullable)

### Container

- `id` (integer, optional)
- `container_no` (string, optional)
- `seal_no` (string, optional)
- `size` (string, optional)
- `weight` (string, optional)
- `quantity` (integer, optional)
- `category` (ContainerCategory, optional, nullable)
- `product` (ContainerProduct, optional, nullable)

### EtaPlanDaysItemsStopsItems

- `action` (string, optional) — `Start`, `Continue`, `Pickup`, `Gate In`, `Gate Out`, `Deliver`, `Overnight stop` or `Back at base`.
- `kind` (string, optional) — `base`, `carry`, `pickup`, `warehouse`, `delivery`, `rest` or `return`.
- `order_id` (long, optional, nullable)
- `shipment_no` (string, optional, nullable)
- `name` (string, optional, nullable)
- `address` (string, optional, nullable)
- `arrive` (string, optional, nullable) — Local date and time in your company time zone, `Y-m-d H:i:s`, no offset.
- `depart` (string, optional, nullable) — Local date and time in your company time zone, `Y-m-d H:i:s`, no offset.
- `window_from` (string, optional, nullable) — Requested window start. Local date and time in your company time zone, `Y-m-d H:i:s`, no offset.
- `window_to` (string, optional, nullable) — Requested window end. Local date and time in your company time zone, `Y-m-d H:i:s`, no offset.
- `late` (boolean, optional) — `true` when the truck leaves after `window_to`.

### ContainerCategory

- `id` (integer, optional)
- `name` (string, optional)

### ContainerProduct

- `id` (integer, optional)
- `name` (string, optional)

## Examples

**Request**

```json
{
  "driver_id": 7019258
}
```

**Response**

```json
{
  "status": 200,
  "msg": "Driver assigned",
  "msgs": [],
  "data": {
    "id": 413,
    "type": "outbound",
    "status": {
      "id": 4,
      "name": "Dispatch"
    },
    "created_at": "2026-10-28 14:42:16",
    "outbound_stops": 1,
    "return_stops": 0,
    "driver": {
      "id": 7019258,
      "name": "Yusuf Ali",
      "phone": "+966500000000",
      "vehicle": {
        "id": 7012246,
        "name": "Desert Line Truck 1",
        "plate": "DLT 5123"
      }
    },
    "partner": {
      "id": 7019257,
      "name": "Desert Line Transport"
    },
    "busy_from": "2026-11-03 09:30:00",
    "busy_to": "2026-11-03 17:41:00",
    "stops": [
      {
        "order_id": 70003943807,
        "tracking_no": "MSKU4821736",
        "leg": "outbound",
        "stop_no": 1,
        "pickup_sequence": 1,
        "delivery_sequence": 2,
        "status": {
          "id": 1,
          "name": "Scheduled"
        },
        "pickup": {
          "address": "Jiddah",
          "latitude": null,
          "longitude": null,
          "from": "2026-11-03 10:00:00",
          "to": "2026-11-03 11:00:00"
        },
        "delivery": {
          "name": "Coastal Trading Factory",
          "phone": "",
          "address": "South Industrial Area, Jeddah",
          "latitude": null,
          "longitude": null,
          "from": "2026-11-03 12:00:00",
          "to": "2026-11-03 14:00:00"
        },
        "staging_warehouse": null,
        "eta": "2026-11-03 12:09:00",
        "shipment": {
          "id": 301,
          "shipment_no": "SHP-1001",
          "tracking_no": "TRK48210",
          "bl_no": "BL-55001",
          "vessel": "MAERSK SELETAR",
          "voyage_no": "442W",
          "shipping_line": {
            "id": 10,
            "name": "MAERSK"
          },
          "status": {
            "id": 10,
            "name": "Awaiting Approval"
          },
          "created_on": "2026-11-03 00:00:00",
          "expected_on": "2026-11-03 00:00:00",
          "merchant": {
            "id": 13618,
            "short_name": "Coastal Trading LLC",
            "long_name": "Coastal Trading LLC",
            "address": "Al Sulaimaniyah Industrial, Jeddah",
            "latitude": null,
            "longitude": null
          },
          "consigner": {
            "id": 7001021045,
            "name": "Coastal Trading LLC",
            "address": "Al Sulaimaniyah Industrial, Jeddah",
            "latitude": null,
            "longitude": null,
            "contact_person_name": "Coastal Trading LLC",
            "contact_person_contact": "+966500000000",
            "contact_person_email": null
          },
          "consignee": {
            "id": 7001021046,
            "name": "Coastal Trading Factory",
            "address": "South Industrial Area, Jeddah",
            "latitude": null,
            "longitude": null,
            "contact_person_name": "Coastal Trading Factory",
            "contact_person_contact": "",
            "contact_person_email": null
          },
          "pickup_from_port": true,
          "destination_port": {
            "id": 61021,
            "name": "Jiddah",
            "unlocode": "SA JED",
            "latitude": null,
            "longitude": null
          },
          "warehouse": null,
          "is_direct_delivery": true,
          "containers": [
            {
              "id": 376,
              "container_no": "MSKU4821736",
              "seal_no": "SL-77120",
              "size": "40ft",
              "weight": "26000",
              "quantity": 1,
              "category": {
                "id": 702810,
                "name": "Containers"
              },
              "product": {
                "id": 875777,
                "name": "40ft GP Container - Full"
              }
            }
          ]
        }
      }
    ],
    "eta": {
      "calculated_at": "2026-10-28 14:42:16",
      "busy_from": "2026-11-03 09:30:00",
      "busy_to": "2026-11-03 17:41:00",
      "total_km": 80,
      "total_drive_min": 78,
      "late": false,
      "days": [
        {
          "date": "2026-11-03",
          "busy_from": "2026-11-03 09:30:00",
          "busy_to": "2026-11-03 17:41:00",
          "km": 80,
          "drive_min": 78,
          "late": false,
          "stops": [
            {
              "action": "Start",
              "kind": "base",
              "order_id": null,
              "shipment_no": null,
              "name": "Head office",
              "address": "Jeddah, Saudi Arabia",
              "arrive": null,
              "depart": "2026-11-03 09:30:00",
              "window_from": null,
              "window_to": null,
              "late": false
            },
            {
              "action": "Pickup",
              "kind": "pickup",
              "order_id": 70003943807,
              "shipment_no": "SHP-1001",
              "name": "Jiddah",
              "address": "Jiddah",
              "arrive": "2026-11-03 10:00:00",
              "depart": "2026-11-03 10:41:00",
              "window_from": "2026-11-03 10:00:00",
              "window_to": "2026-11-03 11:00:00",
              "late": false
            },
            {
              "action": "Deliver",
              "kind": "delivery",
              "order_id": 70003943807,
              "shipment_no": "SHP-1001",
              "name": "Coastal Trading Factory",
              "address": "South Industrial Area, Jeddah",
              "arrive": "2026-11-03 12:09:00",
              "depart": "2026-11-03 13:09:00",
              "window_from": "2026-11-03 12:00:00",
              "window_to": "2026-11-03 14:00:00",
              "late": false
            },
            {
              "action": "Back at base",
              "kind": "return",
              "order_id": null,
              "shipment_no": null,
              "name": "Head office",
              "address": "Jeddah, Saudi Arabia",
              "arrive": "2026-11-03 17:41:00",
              "depart": "2026-11-03 17:41:00",
              "window_from": null,
              "window_to": null,
              "late": false
            }
          ]
        }
      ]
    },
    "warnings": []
  }
}
```

**SDK Code**

```python Example
import requests

url = "https://lastmile.milenow.com/index.php/api/v1/partners/transporters/trips/413/driver"

payload = { "driver_id": 7019258 }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Example
const url = 'https://lastmile.milenow.com/index.php/api/v1/partners/transporters/trips/413/driver';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"driver_id":7019258}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Example
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://lastmile.milenow.com/index.php/api/v1/partners/transporters/trips/413/driver"

	payload := strings.NewReader("{\n  \"driver_id\": 7019258\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Example
require 'uri'
require 'net/http'

url = URI("https://lastmile.milenow.com/index.php/api/v1/partners/transporters/trips/413/driver")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"driver_id\": 7019258\n}"

response = http.request(request)
puts response.read_body
```

```java Example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://lastmile.milenow.com/index.php/api/v1/partners/transporters/trips/413/driver")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"driver_id\": 7019258\n}")
  .asString();
```

```php Example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://lastmile.milenow.com/index.php/api/v1/partners/transporters/trips/413/driver', [
  'body' => '{
  "driver_id": 7019258
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Example
using RestSharp;

var client = new RestClient("https://lastmile.milenow.com/index.php/api/v1/partners/transporters/trips/413/driver");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"driver_id\": 7019258\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Example
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["driver_id": 7019258] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://lastmile.milenow.com/index.php/api/v1/partners/transporters/trips/413/driver")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```