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

# Validate lane preferences without saving

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

Dry run of POST /v1/carriers/lane-preferences/batch: per-item errors and warnings, nothing written. Takes the same body; each record is checked on its own.

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

Reference: https://docs.tryenvoy.ai/api-reference/endpoints/api/validate-carrier-lane-preferences-api-v-1-carriers-lane-preferences-validate-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 LanePreferenceValidateRequest.

- `carrier_lane_preferences` (list of CarrierLanePreferenceInput, required) — Lane preferences in the /v1/carriers/lane-preferences/batch shape

## Response

### 200

Successful Response

- `valid` (boolean, required) — True when every item is valid (warnings allowed)
- `data` (list of ValidationItemResult, required)
- `summary` (ValidationSummary, required) — Counts for a dry run: how many items would be applied, rejected, or applied with warnings.

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

### ValidationItemResult

The findings for one submitted item.

- `index` (integer, required) — Position of the item in the request array (0-based)
- `valid` (boolean, required) — True when the batch route would apply the item (no errors)
- `external_id` (string, optional, nullable) — The item's own ID (tms_load_id, tms_carrier_id or id)
- `errors` (list of ValidationIssue, optional) — Why the batch route would reject it
- `warnings` (list of ValidationIssue, optional) — Accepted, but missing something the AI agent needs

### ValidationSummary

Counts for a dry run: how many items would be applied, rejected, or applied with warnings.

- `total` (integer, required)
- `valid` (integer, required)
- `invalid` (integer, required)
- `with_warnings` (integer, required)

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

### ValidationIssue

One problem found in an item.

- `code` (enum, required) — validation_error or rule_violation (in errors: the batch would reject the item); missing_required_field or unrecognized_status (in warnings)
  - Allowed values: `validation_error`, `rule_violation`, `missing_required_field`, `unrecognized_status`
- `message` (string, required)
- `field` (string, optional, nullable) — Dotted path to the field, e.g. stops.0.location.city

### ValidationErrorLocItems

- string
- integer

### ValidationErrorCtx

## Examples

**Request**

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

**Response**

```json
{
  "valid": true,
  "data": [
    {
      "index": 1,
      "valid": true,
      "external_id": "string",
      "errors": [
        {
          "code": "validation_error",
          "message": "string",
          "field": "string"
        }
      ],
      "warnings": [
        {
          "code": "validation_error",
          "message": "string",
          "field": "string"
        }
      ]
    }
  ],
  "summary": {
    "total": 1,
    "valid": 1,
    "invalid": 1,
    "with_warnings": 1
  }
}
```

**SDK Code**

```python
import requests

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

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/validate';
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/validate"

	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/validate")

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/validate")
  .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/validate', [
  '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/validate");
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/validate")! 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()
```