> 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.

# Search ports

GET https://lastmile.milenow.com/index.php/api/v1/partners/shipments/ports

Company token. Up to 20 ports that match the name, alternate name, code, UN/LOCODE or country code. An empty `data` list means no match; `msg` then suggests another spelling.

Reference: https://docs.milenow.com/ftl-trips/api-reference/ftl/search-ports

## 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

### Query parameters

- `search` (string, required) — At least 2 characters of the port name, code or UN/LOCODE, for example `Jeddah` or `SA JED`.

## Response

### 200

Success

- `status` (integer, required)
- `msg` (string, required)
- `msgs` (list of string, required)
- `data` (list of Port, 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.

### 412 Precondition Failed Error

`search` is shorter than 2 characters.

- `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

### Port

- `id` (integer, optional) — Send as `destination_port_id` or `origination_port_id`.
- `name` (string, optional)
- `alternate_names` (string, optional, nullable)
- `code` (string, optional, nullable)
- `unlocode` (string, optional, nullable) — UN/LOCODE, for example `SA JED`.
- `country` (string, optional, nullable)

## Examples

**Response**

```json
{
  "status": 200,
  "msg": "Ports fetched successfully",
  "msgs": [],
  "data": [
    {
      "id": 61021,
      "name": "Jiddah",
      "alternate_names": "Jidda",
      "code": "48140",
      "unlocode": "SA JED",
      "country": "Saudi Arabia"
    }
  ]
}
```

**SDK Code**

```python Example
import requests

url = "https://lastmile.milenow.com/index.php/api/v1/partners/shipments/ports"

querystring = {"search":"Jeddah"}

headers = {"Authorization": "Bearer <token>"}

response = requests.get(url, headers=headers, params=querystring)

print(response.json())
```

```javascript Example
const url = 'https://lastmile.milenow.com/index.php/api/v1/partners/shipments/ports?search=Jeddah';
const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};

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"
	"net/http"
	"io"
)

func main() {

	url := "https://lastmile.milenow.com/index.php/api/v1/partners/shipments/ports?search=Jeddah"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("Authorization", "Bearer <token>")

	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/shipments/ports?search=Jeddah")

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

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'

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.get("https://lastmile.milenow.com/index.php/api/v1/partners/shipments/ports?search=Jeddah")
  .header("Authorization", "Bearer <token>")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://lastmile.milenow.com/index.php/api/v1/partners/shipments/ports?search=Jeddah', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

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

```csharp Example
using RestSharp;

var client = new RestClient("https://lastmile.milenow.com/index.php/api/v1/partners/shipments/ports?search=Jeddah");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

```swift Example
import Foundation

let headers = ["Authorization": "Bearer <token>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://lastmile.milenow.com/index.php/api/v1/partners/shipments/ports?search=Jeddah")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

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()
```