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

# Upload a raw CSV file

POST https://tryenvoy.ai/api/v1/uploads/csv
Content-Type: multipart/form-data

Persist a raw CSV through the shared attachment layer for audit / re-ingest. Ingestion of the parsed rows happens separately via the v1 batch endpoints — this only lands the file.

**Authentication:** Bearer token required.

Reference: https://docs.tryenvoy.ai/api-reference/endpoints/api/upload-csv-api-v-1-uploads-csv-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 (multipart/form-data)

This endpoint expects a multipart form containing a file.

- `entity_type` (enum, required) — Which entity the CSV is for
- `file` (file, required) — The CSV file
- `import_id` (string, optional) — Browser-generated CSV import correlation ID

## Response

### 200

Successful Response

- `id` (string, required)
- `entity_type` (enum, required) — Which entity a CSV upload is for — echoed in the response and the correlated logs.
  - Allowed values: `loads`, `carriers`, `carrier-lane-preferences`
- `filename` (string, required)
- `blob_name` (string, required)
- `file_size_bytes` (integer, required)
- `import_id` (string, optional, nullable)
- `archival_duration_ms` (double, optional, nullable)

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

### ValidationError

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

### ValidationErrorLocItems

- string
- integer

### ValidationErrorCtx

## Examples

**Request**

```json
{
  "entity_type": {
    "type": "json",
    "value": "loads"
  },
  "file": "<file: [object Object]>",
  "import_id": {
    "type": "json"
  }
}
```

**Response**

```json
{
  "id": "string",
  "entity_type": "loads",
  "filename": "string",
  "blob_name": "string",
  "file_size_bytes": 1,
  "import_id": "string",
  "archival_duration_ms": 1.1
}
```

**SDK Code**

```python
import requests

url = "https://tryenvoy.ai/api/v1/uploads/csv"

files = { "file": "open('[object Object]', 'rb')" }
payload = {
    "entity_type": "{
  \"type\": \"json\",
  \"value\": \"loads\"
}",
    "import_id": "{
  \"type\": \"json\"
}"
}
headers = {"Authorization": "Bearer <token>"}

response = requests.post(url, data=payload, files=files, headers=headers)

print(response.json())
```

```javascript
const url = 'https://tryenvoy.ai/api/v1/uploads/csv';
const form = new FormData();
form.append('entity_type', '{
  "type": "json",
  "value": "loads"
}');
form.append('file', '[object Object]');
form.append('import_id', '{
  "type": "json"
}');

const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};

options.body = form;

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/uploads/csv"

	payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"entity_type\"\r\n\r\n{\n  \"type\": \"json\",\n  \"value\": \"loads\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"[object Object]\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"import_id\"\r\n\r\n{\n  \"type\": \"json\"\n}\r\n-----011000010111000001101001--\r\n")

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

	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
require 'uri'
require 'net/http'

url = URI("https://tryenvoy.ai/api/v1/uploads/csv")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"entity_type\"\r\n\r\n{\n  \"type\": \"json\",\n  \"value\": \"loads\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"[object Object]\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"import_id\"\r\n\r\n{\n  \"type\": \"json\"\n}\r\n-----011000010111000001101001--\r\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/uploads/csv")
  .header("Authorization", "Bearer <token>")
  .body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"entity_type\"\r\n\r\n{\n  \"type\": \"json\",\n  \"value\": \"loads\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"[object Object]\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"import_id\"\r\n\r\n{\n  \"type\": \"json\"\n}\r\n-----011000010111000001101001--\r\n")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://tryenvoy.ai/api/v1/uploads/csv', [
  'multipart' => [
    [
        'name' => 'entity_type',
        'contents' => '{
  "type": "json",
  "value": "loads"
}'
    ],
    [
        'name' => 'file',
        'filename' => '[object Object]',
        'contents' => null
    ],
    [
        'name' => 'import_id',
        'contents' => '{
  "type": "json"
}'
    ]
  ]
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://tryenvoy.ai/api/v1/uploads/csv");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddParameter("undefined", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"entity_type\"\r\n\r\n{\n  \"type\": \"json\",\n  \"value\": \"loads\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"[object Object]\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"import_id\"\r\n\r\n{\n  \"type\": \"json\"\n}\r\n-----011000010111000001101001--\r\n", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Authorization": "Bearer <token>"]
let parameters = [
  [
    "name": "entity_type",
    "value": "{
  \"type\": \"json\",
  \"value\": \"loads\"
}"
  ],
  [
    "name": "file",
    "fileName": "[object Object]"
  ],
  [
    "name": "import_id",
    "value": "{
  \"type\": \"json\"
}"
  ]
]

let boundary = "---011000010111000001101001"

var body = ""
var error: NSError? = nil
for param in parameters {
  let paramName = param["name"]!
  body += "--\(boundary)\r\n"
  body += "Content-Disposition:form-data; name=\"\(paramName)\""
  if let filename = param["fileName"] {
    let contentType = param["content-type"]!
    let fileContent = String(contentsOfFile: filename, encoding: String.Encoding.utf8)
    if (error != nil) {
      print(error as Any)
    }
    body += "; filename=\"\(filename)\"\r\n"
    body += "Content-Type: \(contentType)\r\n\r\n"
    body += fileContent
  } else if let paramValue = param["value"] {
    body += "\r\n\r\n\(paramValue)"
  }
}

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