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

# Upload CSV records

POST https://api.runtype.com/v1/records/upload-csv
Content-Type: multipart/form-data

Upload and process a CSV file to create records in bulk. Either supply `typeColumn` to read the type from a column, or `typeValue` to assign the same constant type to every row (skipping the column lookup). `typeValue` takes precedence when both are provided.

Reference: https://docs.runtype.com/api-reference/runtype-api/records/upload-csv-records

## Authentication

- `Authorization` header (bearer token, required) — API key or Clerk session token

## Servers

- `https://api.runtype.com` (Production, default)
- `https://api.runtype-staging.com` (Staging)

## Request

### Body (multipart/form-data)

This endpoint expects a multipart form.

- `file` (any, optional)
- `nameColumn` (string, optional)
- `typeColumn` (string, optional)
- `typeValue` (string, optional)

## Response

### 201

CSV upload result

- `created` (integer, required)
- `errorDetails` (list of string, required)
- `errors` (integer, required)
- `message` (string, required)
- `records` (list of V1RecordsUploadCsvPostResponsesContentApplicationJsonSchemaRecordsItems, required)
- `success` (boolean, required)
- `warnings` (list of V1RecordsUploadCsvPostResponsesContentApplicationJsonSchemaWarningsItems, optional)

## Errors

### 400 Bad Request Error

Invalid CSV or missing file

- `error` (string, required)
- `code` (string, optional) — Stable error code. `insufficient_scope` marks an API key that lacks a scope this request needs.
- `details` (list of ErrorDetailsItems, optional)
- `requiredScopes` (list of string, optional) — On `insufficient_scope`: every API key scope this request needs.

### 401 Unauthorized Error

Unauthorized

- `error` (string, required)
- `code` (string, optional) — Stable error code. `insufficient_scope` marks an API key that lacks a scope this request needs.
- `details` (list of ErrorDetailsItems, optional)
- `requiredScopes` (list of string, optional) — On `insufficient_scope`: every API key scope this request needs.

### 403 Forbidden Error

Insufficient permissions

- `error` (string, required)
- `code` (string, optional) — Stable error code. `insufficient_scope` marks an API key that lacks a scope this request needs.
- `details` (list of ErrorDetailsItems, optional)
- `requiredScopes` (list of string, optional) — On `insufficient_scope`: every API key scope this request needs.

### 500 Internal Server Error

Internal server error

- `error` (string, required)
- `code` (string, optional) — Stable error code. `insufficient_scope` marks an API key that lacks a scope this request needs.
- `details` (list of ErrorDetailsItems, optional)
- `requiredScopes` (list of string, optional) — On `insufficient_scope`: every API key scope this request needs.

## Types

### V1RecordsUploadCsvPostResponsesContentApplicationJsonSchemaRecordsItems

- `id` (string, required)
- `metadata` (map from string to any, required)
- `name` (string, required)
- `type` (string, required)

### V1RecordsUploadCsvPostResponsesContentApplicationJsonSchemaWarningsItems

- `code` (enum, required)
  - Allowed values: `KEY_RENAMED`
- `from` (string, required)
- `to` (string, required)

### ErrorDetailsItems

- `message` (string, required)
- `code` (string, optional) — Stable Runtype validation code (e.g. MISSING_REQUIRED_FIELD, INVALID_ENUM).
- `path` (string, optional) — Dotted JSON path to the offending field.
- `suggestion` (string, optional) — Actionable hint (allowed values, accepted range, …).

## Examples

**Request**

```json
{
  "file": {
    "type": "json"
  },
  "nameColumn": {
    "type": "json"
  },
  "typeColumn": {
    "type": "json"
  },
  "typeValue": {
    "type": "json"
  }
}
```

**Response**

```json
{
  "created": 1,
  "errorDetails": [
    "string"
  ],
  "errors": 1,
  "message": "string",
  "records": [
    {
      "id": "string",
      "metadata": {},
      "name": "string",
      "type": "string"
    }
  ],
  "success": true,
  "warnings": [
    {
      "code": "KEY_RENAMED",
      "from": "string",
      "to": "string"
    }
  ]
}
```

**SDK Code**

```python
import requests

url = "https://api.runtype.com/v1/records/upload-csv"

payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"\r\n\r\n{\n  \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"nameColumn\"\r\n\r\n{\n  \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"typeColumn\"\r\n\r\n{\n  \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"typeValue\"\r\n\r\n{\n  \"type\": \"json\"\n}\r\n-----011000010111000001101001--\r\n"
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "multipart/form-data; boundary=---011000010111000001101001"
}

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

print(response.json())
```

```javascript
const url = 'https://api.runtype.com/v1/records/upload-csv';
const form = new FormData();
form.append('file', '{
  "type": "json"
}');
form.append('nameColumn', '{
  "type": "json"
}');
form.append('typeColumn', '{
  "type": "json"
}');
form.append('typeValue', '{
  "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://api.runtype.com/v1/records/upload-csv"

	payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"\r\n\r\n{\n  \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"nameColumn\"\r\n\r\n{\n  \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"typeColumn\"\r\n\r\n{\n  \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"typeValue\"\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://api.runtype.com/v1/records/upload-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=\"file\"\r\n\r\n{\n  \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"nameColumn\"\r\n\r\n{\n  \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"typeColumn\"\r\n\r\n{\n  \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"typeValue\"\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://api.runtype.com/v1/records/upload-csv")
  .header("Authorization", "Bearer <token>")
  .body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"\r\n\r\n{\n  \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"nameColumn\"\r\n\r\n{\n  \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"typeColumn\"\r\n\r\n{\n  \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"typeValue\"\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://api.runtype.com/v1/records/upload-csv', [
  'multipart' => [
    [
        'name' => 'file',
        'contents' => '{
  "type": "json"
}'
    ],
    [
        'name' => 'nameColumn',
        'contents' => '{
  "type": "json"
}'
    ],
    [
        'name' => 'typeColumn',
        'contents' => '{
  "type": "json"
}'
    ],
    [
        'name' => 'typeValue',
        'contents' => '{
  "type": "json"
}'
    ]
  ]
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.runtype.com/v1/records/upload-csv");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddParameter("undefined", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"\r\n\r\n{\n  \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"nameColumn\"\r\n\r\n{\n  \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"typeColumn\"\r\n\r\n{\n  \"type\": \"json\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"typeValue\"\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": "file",
    "value": "{
  \"type\": \"json\"
}"
  ],
  [
    "name": "nameColumn",
    "value": "{
  \"type\": \"json\"
}"
  ],
  [
    "name": "typeColumn",
    "value": "{
  \"type\": \"json\"
}"
  ],
  [
    "name": "typeValue",
    "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://api.runtype.com/v1/records/upload-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()
```