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

# Batch create carrier lane preferences

POST https://tryenvoy.ai/api/v1/carriers/lane-preferences/batch
Content-Type: application/json

Batch create or update carrier lane preferences (e.g. CSV upload). Accepts API-key or session/bearer auth so both integrations and the web app can call it. Returns per-batch created/updated/failed counts + row errors.

**Authentication:** Supports API key and bearer token authentication.

Reference: https://docs.tryenvoy.ai/api-reference/endpoints/api/batch-create-carrier-lane-preferences-api-v-1-carriers-lane-preferences-batch-post

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Servers

- `https://tryenvoy.ai/api/v1` (Production, default)
- `https://staging.tryenvoy.ai/api/v1` (Staging)

## Request

### Headers

- `X-Organization-ID` (string, optional, nullable)
- `Idempotency-Key` (string, optional) — A unique key (up to 255 printable ASCII characters, e.g. a UUID) that makes a retry of this request safe. Envoy stores the response for 24 hours; a retry with the same key and the same request returns it again with `Idempotent-Replayed: true` instead of running twice. The same key with a different request returns 422 `idempotency_key_reused`; while the first request is still running, 409 `idempotency_key_in_progress`. 5xx and 429 responses are not stored.

### Body (application/json)

This endpoint expects a CarrierLanePreferenceBatchRequest.

- `carrier_lane_preferences` (list of CarrierLanePreferenceInput, required) — Lane preferences (max 1000)

## Response

### 200

Successful Response

- `success` (boolean, required)
- `total_records` (integer, required)
- `successful` (integer, required)
- `failed` (integer, required)
- `created` (integer, optional, default: 0)
- `updated` (integer, optional, default: 0)
- `errors` (list of map from string to any, optional)

### 207

Some items were not applied; each one's reason is in data[].error (or errors[])

## Errors

### 401 Unauthorized Error

Not authenticated - missing or invalid token/API key

- `any`

### 403 Forbidden Error

Insufficient permissions for this operation

- `any`

### 409 Conflict Error

`idempotency_key_in_progress`: a request with this Idempotency-Key is still running; retry later

- `any`

### 422 Unprocessable Entity Error

Validation Error; or `idempotency_key_reused`: this Idempotency-Key was already used for a different request

- `detail` (list of ValidationError, optional)

### 429 Too Many Requests Error

Rate limit exceeded - see Retry-After header

- `any`

## Types

### CarrierLanePreferenceInput

One carrier lane preference: the carrier (matched by TMS id, MC, DOT or name) and the lane it runs.

- `id` (string, required) — Your ID for this lane-preference record
- `name` (string, required) — A label for the lane preference
- `lane` (CarrierLaneInput, required) — Lane origin and destination
- `carrier_service_name` (string, optional, nullable) — Alternative carrier name, if your TMS has one
- `carrier_name` (string, optional, nullable) — Carrier company name
- `tms_carrier_id` (string, optional, nullable) — Your TMS's ID for the carrier
- `mc_number` (string, optional, nullable) — MC number
- `dot_number` (string, optional, nullable) — DOT number
- `carrier_phone` (string, optional, nullable) — Carrier phone
- `carrier_main_email` (string, optional, nullable) — Carrier main email
- `dispatcher_phone` (string, optional, nullable) — Dispatcher phone
- `dispatcher_email` (string, optional, nullable) — Dispatcher email
- `last_modified_date` (datetime, optional, nullable) — Last modified timestamp
- `completed_loads` (integer, optional, nullable) — Number of completed loads on this lane
- `preference_score` (integer, optional, nullable) — Preference score 0-100
- `equipment_types` (list of enum, optional, nullable) — Equipment types used
  - Allowed values: `VAN`, `REEFER`, `FLATBED`, `STEPDECK`, `RGN`, `CONESTOGA`, `BOX_TRUCK`, `CONTAINER`, `INTERMODAL`, `POWER_ONLY`, `TANKER`, `LOWBOY`, `HOTSHOT`, `AUTO_CARRIER`, `DRY_BULK`, `DRY_TEAM`, `REEFER_TEAM`, `LTL`, `OTHER`, `VAN/REEFER`
- `carrier_on_time_delivery_pct` (double, optional, nullable) — Carrier on-time delivery % (0-100 scale)
- `carrier_on_time_pickup_pct` (double, optional, nullable) — Carrier on-time pickup % (0-100 scale)
- `carrier_total_loads_hauled` (integer, optional, nullable) — Carrier total loads hauled
- `carrier_is_onboarded` (boolean, optional, default: false) — Whether carrier is onboarded

### ValidationError

- `loc` (list of ValidationErrorLocItems, required)
- `msg` (string, required)
- `type` (string, required)
- `input` (any, optional)
- `ctx` (ValidationErrorCtx, optional)

### CarrierLaneInput

Origin and destination of a lane. Leave the destination out for "from this origin to anywhere".

- `name` (string, optional, nullable)
- `origin_city` (string, optional, nullable)
- `origin_state` (string, optional, nullable)
- `destination_city` (string, optional, nullable)
- `destination_state` (string, optional, nullable)

### ValidationErrorLocItems

- string
- integer

### ValidationErrorCtx

## Examples

### Example 1

**Request**

```json
{
  "carrier_lane_preferences": [
    {
      "id": "string",
      "name": "string",
      "lane": {}
    }
  ]
}
```

**Response**

```json
{
  "success": true,
  "total_records": 1,
  "successful": 1,
  "failed": 1,
  "created": 0,
  "updated": 0,
  "errors": [
    {}
  ]
}
```

**SDK Code**

```python
import requests

url = "https://tryenvoy.ai/api/v1/carriers/lane-preferences/batch"

payload = { "carrier_lane_preferences": [
        {
            "id": "string",
            "name": "string",
            "lane": {}
        }
    ] }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript
const url = 'https://tryenvoy.ai/api/v1/carriers/lane-preferences/batch';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"carrier_lane_preferences":[{"id":"string","name":"string","lane":{}}]}'
};

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

```go
package main

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

func main() {

	url := "https://tryenvoy.ai/api/v1/carriers/lane-preferences/batch"

	payload := strings.NewReader("{\n  \"carrier_lane_preferences\": [\n    {\n      \"id\": \"string\",\n      \"name\": \"string\",\n      \"lane\": {}\n    }\n  ]\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
require 'uri'
require 'net/http'

url = URI("https://tryenvoy.ai/api/v1/carriers/lane-preferences/batch")

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  \"carrier_lane_preferences\": [\n    {\n      \"id\": \"string\",\n      \"name\": \"string\",\n      \"lane\": {}\n    }\n  ]\n}"

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

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

HttpResponse<String> response = Unirest.post("https://tryenvoy.ai/api/v1/carriers/lane-preferences/batch")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"carrier_lane_preferences\": [\n    {\n      \"id\": \"string\",\n      \"name\": \"string\",\n      \"lane\": {}\n    }\n  ]\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://tryenvoy.ai/api/v1/carriers/lane-preferences/batch', [
  'body' => '{
  "carrier_lane_preferences": [
    {
      "id": "string",
      "name": "string",
      "lane": {}
    }
  ]
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://tryenvoy.ai/api/v1/carriers/lane-preferences/batch");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"carrier_lane_preferences\": [\n    {\n      \"id\": \"string\",\n      \"name\": \"string\",\n      \"lane\": {}\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["carrier_lane_preferences": [
    [
      "id": "string",
      "name": "string",
      "lane": []
    ]
  ]] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://tryenvoy.ai/api/v1/carriers/lane-preferences/batch")! 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()
```

### Example 2

**Request**

```json
{
  "carrier_lane_preferences": [
    {
      "id": "string",
      "name": "string",
      "lane": {}
    }
  ]
}
```

**Response**

```json
{
  "success": true,
  "total_records": 1,
  "successful": 1,
  "failed": 1,
  "created": 0,
  "updated": 0,
  "errors": [
    {}
  ]
}
```

**SDK Code**

```python
import requests

url = "https://tryenvoy.ai/api/v1/carriers/lane-preferences/batch"

payload = { "carrier_lane_preferences": [
        {
            "id": "string",
            "name": "string",
            "lane": {}
        }
    ] }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript
const url = 'https://tryenvoy.ai/api/v1/carriers/lane-preferences/batch';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"carrier_lane_preferences":[{"id":"string","name":"string","lane":{}}]}'
};

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

```go
package main

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

func main() {

	url := "https://tryenvoy.ai/api/v1/carriers/lane-preferences/batch"

	payload := strings.NewReader("{\n  \"carrier_lane_preferences\": [\n    {\n      \"id\": \"string\",\n      \"name\": \"string\",\n      \"lane\": {}\n    }\n  ]\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
require 'uri'
require 'net/http'

url = URI("https://tryenvoy.ai/api/v1/carriers/lane-preferences/batch")

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  \"carrier_lane_preferences\": [\n    {\n      \"id\": \"string\",\n      \"name\": \"string\",\n      \"lane\": {}\n    }\n  ]\n}"

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

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

HttpResponse<String> response = Unirest.post("https://tryenvoy.ai/api/v1/carriers/lane-preferences/batch")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"carrier_lane_preferences\": [\n    {\n      \"id\": \"string\",\n      \"name\": \"string\",\n      \"lane\": {}\n    }\n  ]\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://tryenvoy.ai/api/v1/carriers/lane-preferences/batch', [
  'body' => '{
  "carrier_lane_preferences": [
    {
      "id": "string",
      "name": "string",
      "lane": {}
    }
  ]
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://tryenvoy.ai/api/v1/carriers/lane-preferences/batch");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"carrier_lane_preferences\": [\n    {\n      \"id\": \"string\",\n      \"name\": \"string\",\n      \"lane\": {}\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["carrier_lane_preferences": [
    [
      "id": "string",
      "name": "string",
      "lane": []
    ]
  ]] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://tryenvoy.ai/api/v1/carriers/lane-preferences/batch")! 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()
```