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

# /file - Uploads a file to a record

POST https://file
Content-Type: multipart/form-data

POST a file to add a file.

If request has an image or file uuid, that file will be replaced.

If the request has an empty file_uuid, the post body must include the file or image field UUID and the resulting file will be added to that field or will replace if an existing file is present (when the field is set to single upload only).

Reference: https://docs.odr.io/odr-search-api-v-4/file-uploads-a-file-to-a-record

## Request

### Query parameters

- `XDEBUG_SESSION_START` (string, optional)

### Body (multipart/form-data)

This endpoint expects a multipart form containing a file.

- `name` (string, required)
- `file` (file, required)
- `dataset_uuid` (string, required)
- `template_field_uuid` (string, required)
- `user_email` (string, required)
- `field_uuid` (string, required)
- `record_uuid` (string, required)

## Response

### 200

OK

- `database_uuid` (string, required)
- `internal_id` (integer, required)
- `record_name` (integer, required)
- `record_uuid` (string, required)
- `template_uuid` (string, required)
- `metadata_for_uuid` (string, required)
- `_record_metadata` (object, required)
  - `_create_date` (string, required)
  - `_updated_date` (string, required)
  - `_create_auth` (string, required)
  - `_public_date` (string, required)
- `fields` (list of object, required)
  - `field_name` (string, required)
  - `field_uuid` (string, required)
  - `template_field_uuid` (string, required)
  - `id` (integer, required)
  - `value` (string, required)
- `records` (list of object, required)
  - `database_uuid` (string, required)
  - `internal_id` (integer, required)
  - `record_name` (integer, required)
  - `record_uuid` (string, required)
  - `template_uuid` (string, required)
  - `metadata_for_uuid` (string, required)
  - `_record_metadata` (object, required)
    - `_create_date` (string, required)
    - `_updated_date` (string, required)
    - `_create_auth` (string, required)
    - `_public_date` (string, required)
  - `fields` (list of object, required)
    - `field_name` (string, required)
    - `field_uuid` (string, required)
    - `template_field_uuid` (string, required)
    - `id` (integer, required)
    - `files` (list of object, required)
      - `_file_metadata` (object, required)
        - `_external_id` (string, required)
        - `_create_date` (string, required)
        - `_create_auth` (string, required)
        - `_public_date` (string, required)
        - `_display_order` (string, required)
      - `id` (integer, required)
      - `file_uuid` (string, required)
      - `original_name` (string, required)
      - `href` (string, required)
      - `caption` (string, required)
      - `width` (string, required)
      - `height` (string, required)
  - `records` (list of any, required)

## Examples

**Request**

```json
{
  "name": {
    "type": "json",
    "value": "string"
  },
  "file": "<file: [object Object]>",
  "dataset_uuid": {
    "type": "json",
    "value": "string"
  },
  "template_field_uuid": {
    "type": "json",
    "value": "string"
  },
  "user_email": {
    "type": "json",
    "value": "string"
  },
  "field_uuid": {
    "type": "json",
    "value": "string"
  },
  "record_uuid": {
    "type": "json",
    "value": "string"
  }
}
```

**Response**

```json
{
  "database_uuid": "a9cb4723567ab797e9f58ae0ba45",
  "internal_id": 339,
  "record_name": 339,
  "record_uuid": "be6224d42961852bcdd6c5899970",
  "template_uuid": "b7ee31b8466ff933265455487962",
  "metadata_for_uuid": "",
  "_record_metadata": {
    "_create_date": "2022-08-30 23:11:16",
    "_updated_date": "2022-09-01 19:18:25",
    "_create_auth": "nate@opendatarepository.org",
    "_public_date": "2200-01-01 00:00:00"
  },
  "fields": [
    {
      "field_name": "RRUFF ID",
      "field_uuid": "b25c4d87bc4450887f5320760ea3",
      "template_field_uuid": "dc85b516c2d253f3512f1a5d25a2",
      "id": 353,
      "value": "R220001"
    },
    {
      "field_name": "Sample Image",
      "field_uuid": "9085b5e3428e7c3746edbefc6a0b",
      "template_field_uuid": "string",
      "id": 354,
      "value": "string"
    },
    {
      "field_name": "Type Image",
      "field_uuid": "b167a5f56ca1655b9816ec8de839",
      "template_field_uuid": "9d9bd1a6bcce90dfcf0d4964412c",
      "id": 356,
      "value": "string"
    }
  ],
  "records": [
    {
      "database_uuid": "cf21778b31250c10718d1594e667",
      "internal_id": 340,
      "record_name": 340,
      "record_uuid": "204bc7dbad7f6655d7eabd6ac708",
      "template_uuid": "8658e6218e0545e74e95afc2c42a",
      "metadata_for_uuid": "",
      "_record_metadata": {
        "_create_date": "2022-09-01 17:22:37",
        "_updated_date": "2022-09-01 17:23:46",
        "_create_auth": "nate@opendatarepository.org",
        "_public_date": "2200-01-01 00:00:00"
      },
      "fields": [
        {
          "field_name": "Microprobe Image",
          "field_uuid": "94b385c01737aea0777931f27c42",
          "template_field_uuid": "c2e40c66245bbcb78bd407dde838",
          "id": 328,
          "files": [
            {
              "_file_metadata": {
                "_external_id": "",
                "_create_date": "2022-09-01 17:23:45",
                "_create_auth": "nate@opendatarepository.org",
                "_public_date": "2200-01-01 00:00:00",
                "_display_order": "0"
              },
              "id": 174,
              "file_uuid": "47db2e515f2910bddc722751984b",
              "original_name": "Uvarovite__R060477-2__Chemistry__Photo__4412__L.jpeg",
              "href": "https://omicron.odr.io/app_dev.php/view/downloadimage/174",
              "caption": "",
              "width": "415",
              "height": "375"
            },
            {
              "_file_metadata": {
                "_external_id": "",
                "_create_date": "2022-09-01 17:23:45",
                "_create_auth": "nate@opendatarepository.org",
                "_public_date": "2200-01-01 00:00:00",
                "_display_order": "0"
              },
              "id": 173,
              "file_uuid": "f411cfd4db051c2af06b05267e43",
              "original_name": "Uvarovite__R060477-2__Chemistry__Photo__4412__L.jpeg",
              "href": "https://omicron.odr.io/app_dev.php/view/downloadimage/173",
              "caption": "",
              "width": "1154",
              "height": "1043"
            }
          ]
        },
        {
          "field_name": "RRUFF ID",
          "field_uuid": "fb4df17f19961aeef5227cb3c17f",
          "template_field_uuid": "64a69b499baef3c9fa0ce3f1359e",
          "id": 329,
          "files": [
            {
              "_file_metadata": {
                "_external_id": "string",
                "_create_date": "string",
                "_create_auth": "string",
                "_public_date": "string",
                "_display_order": "string"
              },
              "id": 1,
              "file_uuid": "string",
              "original_name": "string",
              "href": "string",
              "caption": "string",
              "width": "string",
              "height": "string"
            }
          ]
        }
      ],
      "records": []
    },
    {
      "database_uuid": "0bb51c2acf16875e0db5c3c7897d",
      "internal_id": 341,
      "record_name": 341,
      "record_uuid": "1d9fa61317be16f910c8976d0c90",
      "template_uuid": "7b2a93b76d428682103f3ad82602",
      "metadata_for_uuid": "",
      "_record_metadata": {
        "_create_date": "2022-09-01 17:22:45",
        "_updated_date": "2022-09-01 17:22:45",
        "_create_auth": "nate@opendatarepository.org",
        "_public_date": "2200-01-01 00:00:00"
      },
      "fields": [
        {
          "field_name": "RRUFF ID",
          "field_uuid": "d7feb0803bc76750fa5b601066d5",
          "template_field_uuid": "8eff95317a7b2650e96803a38c94",
          "id": 338,
          "files": [
            {
              "_file_metadata": {
                "_external_id": "string",
                "_create_date": "string",
                "_create_auth": "string",
                "_public_date": "string",
                "_display_order": "string"
              },
              "id": 1,
              "file_uuid": "string",
              "original_name": "string",
              "href": "string",
              "caption": "string",
              "width": "string",
              "height": "string"
            }
          ]
        }
      ],
      "records": []
    },
    {
      "database_uuid": "720332564da1df6bc578a768c857",
      "internal_id": 342,
      "record_name": 342,
      "record_uuid": "7b912526b888b1988e1e8a00b711",
      "template_uuid": "d2258a18fd94127327289fcecb64",
      "metadata_for_uuid": "",
      "_record_metadata": {
        "_create_date": "2022-09-01 17:22:57",
        "_updated_date": "2022-09-01 17:22:57",
        "_create_auth": "nate@opendatarepository.org",
        "_public_date": "2200-01-01 00:00:00"
      },
      "fields": [
        {
          "field_name": "RRUFF ID",
          "field_uuid": "6d4a0cff695f73f0697db4ce4079",
          "template_field_uuid": "f3a4755c2d0a95ad504efa043f01",
          "id": 320,
          "files": [
            {
              "_file_metadata": {
                "_external_id": "string",
                "_create_date": "string",
                "_create_auth": "string",
                "_public_date": "string",
                "_display_order": "string"
              },
              "id": 1,
              "file_uuid": "string",
              "original_name": "string",
              "href": "string",
              "caption": "string",
              "width": "string",
              "height": "string"
            }
          ]
        }
      ],
      "records": []
    },
    {
      "database_uuid": "34c0b180fa9c2b444c5da069242d",
      "internal_id": 343,
      "record_name": 343,
      "record_uuid": "c8216e89e51ed1b4c2f0a20c85e4",
      "template_uuid": "6b534d7ecfa469c489455e19d6f7",
      "metadata_for_uuid": "",
      "_record_metadata": {
        "_create_date": "2022-09-01 17:23:09",
        "_updated_date": "2022-09-01 17:23:09",
        "_create_auth": "nate@opendatarepository.org",
        "_public_date": "2200-01-01 00:00:00"
      },
      "fields": [
        {
          "field_name": "RRUFF ID",
          "field_uuid": "3a5b3708871d5feac21f70b41f59",
          "template_field_uuid": "1e31cb4be63bb104b64baf515bd8",
          "id": 335,
          "files": [
            {
              "_file_metadata": {
                "_external_id": "string",
                "_create_date": "string",
                "_create_auth": "string",
                "_public_date": "string",
                "_display_order": "string"
              },
              "id": 1,
              "file_uuid": "string",
              "original_name": "string",
              "href": "string",
              "caption": "string",
              "width": "string",
              "height": "string"
            }
          ]
        }
      ],
      "records": []
    },
    {
      "database_uuid": "b4a3a1b7ec39a2e6be8e62e4b2de",
      "internal_id": 344,
      "record_name": 344,
      "record_uuid": "fd3aaa5bbc41166d0b364051b565",
      "template_uuid": "8c15173f0dae8e98f750c9cf0499",
      "metadata_for_uuid": "",
      "_record_metadata": {
        "_create_date": "2022-09-01 17:23:17",
        "_updated_date": "2022-09-01 17:23:17",
        "_create_auth": "nate@opendatarepository.org",
        "_public_date": "2200-01-01 00:00:00"
      },
      "fields": [
        {
          "field_name": "RRUFF ID",
          "field_uuid": "65606eae79c79151cf35840e4821",
          "template_field_uuid": "4497c404299d44d6ad43bdf4db1b",
          "id": 350,
          "files": [
            {
              "_file_metadata": {
                "_external_id": "string",
                "_create_date": "string",
                "_create_auth": "string",
                "_public_date": "string",
                "_display_order": "string"
              },
              "id": 1,
              "file_uuid": "string",
              "original_name": "string",
              "href": "string",
              "caption": "string",
              "width": "string",
              "height": "string"
            }
          ]
        }
      ],
      "records": []
    }
  ]
}
```

**SDK Code**

```python /file - Uploads a file to a record_example
import requests

url = "https://https/file"

querystring = {"XDEBUG_SESSION_START":"phpstorm_xdebug"}

files = { "file": "open('[object Object]', 'rb')" }
payload = {
    "name": "{
  \"type\": \"json\",
  \"value\": \"string\"
}",
    "dataset_uuid": "{
  \"type\": \"json\",
  \"value\": \"string\"
}",
    "template_field_uuid": "{
  \"type\": \"json\",
  \"value\": \"string\"
}",
    "user_email": "{
  \"type\": \"json\",
  \"value\": \"string\"
}",
    "field_uuid": "{
  \"type\": \"json\",
  \"value\": \"string\"
}",
    "record_uuid": "{
  \"type\": \"json\",
  \"value\": \"string\"
}"
}

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

print(response.json())
```

```javascript /file - Uploads a file to a record_example
const url = 'https://https/file?XDEBUG_SESSION_START=phpstorm_xdebug';
const form = new FormData();
form.append('name', '{
  "type": "json",
  "value": "string"
}');
form.append('file', '[object Object]');
form.append('dataset_uuid', '{
  "type": "json",
  "value": "string"
}');
form.append('template_field_uuid', '{
  "type": "json",
  "value": "string"
}');
form.append('user_email', '{
  "type": "json",
  "value": "string"
}');
form.append('field_uuid', '{
  "type": "json",
  "value": "string"
}');
form.append('record_uuid', '{
  "type": "json",
  "value": "string"
}');

const options = {method: 'POST'};

options.body = form;

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

```go /file - Uploads a file to a record_example
package main

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

func main() {

	url := "https://https/file?XDEBUG_SESSION_START=phpstorm_xdebug"

	payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\n{\n  \"type\": \"json\",\n  \"value\": \"string\"\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=\"dataset_uuid\"\r\n\r\n{\n  \"type\": \"json\",\n  \"value\": \"string\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"template_field_uuid\"\r\n\r\n{\n  \"type\": \"json\",\n  \"value\": \"string\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"user_email\"\r\n\r\n{\n  \"type\": \"json\",\n  \"value\": \"string\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"field_uuid\"\r\n\r\n{\n  \"type\": \"json\",\n  \"value\": \"string\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"record_uuid\"\r\n\r\n{\n  \"type\": \"json\",\n  \"value\": \"string\"\n}\r\n-----011000010111000001101001--\r\n")

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

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby /file - Uploads a file to a record_example
require 'uri'
require 'net/http'

url = URI("https://https/file?XDEBUG_SESSION_START=phpstorm_xdebug")

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

request = Net::HTTP::Post.new(url)
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\n{\n  \"type\": \"json\",\n  \"value\": \"string\"\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=\"dataset_uuid\"\r\n\r\n{\n  \"type\": \"json\",\n  \"value\": \"string\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"template_field_uuid\"\r\n\r\n{\n  \"type\": \"json\",\n  \"value\": \"string\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"user_email\"\r\n\r\n{\n  \"type\": \"json\",\n  \"value\": \"string\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"field_uuid\"\r\n\r\n{\n  \"type\": \"json\",\n  \"value\": \"string\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"record_uuid\"\r\n\r\n{\n  \"type\": \"json\",\n  \"value\": \"string\"\n}\r\n-----011000010111000001101001--\r\n"

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

```java /file - Uploads a file to a record_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://https/file?XDEBUG_SESSION_START=phpstorm_xdebug")
  .body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\n{\n  \"type\": \"json\",\n  \"value\": \"string\"\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=\"dataset_uuid\"\r\n\r\n{\n  \"type\": \"json\",\n  \"value\": \"string\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"template_field_uuid\"\r\n\r\n{\n  \"type\": \"json\",\n  \"value\": \"string\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"user_email\"\r\n\r\n{\n  \"type\": \"json\",\n  \"value\": \"string\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"field_uuid\"\r\n\r\n{\n  \"type\": \"json\",\n  \"value\": \"string\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"record_uuid\"\r\n\r\n{\n  \"type\": \"json\",\n  \"value\": \"string\"\n}\r\n-----011000010111000001101001--\r\n")
  .asString();
```

```php /file - Uploads a file to a record_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://https/file?XDEBUG_SESSION_START=phpstorm_xdebug', [
  'multipart' => [
    [
        'name' => 'name',
        'contents' => '{
  "type": "json",
  "value": "string"
}'
    ],
    [
        'name' => 'file',
        'filename' => '[object Object]',
        'contents' => null
    ],
    [
        'name' => 'dataset_uuid',
        'contents' => '{
  "type": "json",
  "value": "string"
}'
    ],
    [
        'name' => 'template_field_uuid',
        'contents' => '{
  "type": "json",
  "value": "string"
}'
    ],
    [
        'name' => 'user_email',
        'contents' => '{
  "type": "json",
  "value": "string"
}'
    ],
    [
        'name' => 'field_uuid',
        'contents' => '{
  "type": "json",
  "value": "string"
}'
    ],
    [
        'name' => 'record_uuid',
        'contents' => '{
  "type": "json",
  "value": "string"
}'
    ]
  ]
]);

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

```csharp /file - Uploads a file to a record_example
using RestSharp;

var client = new RestClient("https://https/file?XDEBUG_SESSION_START=phpstorm_xdebug");
var request = new RestRequest(Method.POST);
request.AddParameter("undefined", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\n{\n  \"type\": \"json\",\n  \"value\": \"string\"\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=\"dataset_uuid\"\r\n\r\n{\n  \"type\": \"json\",\n  \"value\": \"string\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"template_field_uuid\"\r\n\r\n{\n  \"type\": \"json\",\n  \"value\": \"string\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"user_email\"\r\n\r\n{\n  \"type\": \"json\",\n  \"value\": \"string\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"field_uuid\"\r\n\r\n{\n  \"type\": \"json\",\n  \"value\": \"string\"\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"record_uuid\"\r\n\r\n{\n  \"type\": \"json\",\n  \"value\": \"string\"\n}\r\n-----011000010111000001101001--\r\n", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift /file - Uploads a file to a record_example
import Foundation
let parameters = [
  [
    "name": "name",
    "value": "{
  \"type\": \"json\",
  \"value\": \"string\"
}"
  ],
  [
    "name": "file",
    "fileName": "[object Object]"
  ],
  [
    "name": "dataset_uuid",
    "value": "{
  \"type\": \"json\",
  \"value\": \"string\"
}"
  ],
  [
    "name": "template_field_uuid",
    "value": "{
  \"type\": \"json\",
  \"value\": \"string\"
}"
  ],
  [
    "name": "user_email",
    "value": "{
  \"type\": \"json\",
  \"value\": \"string\"
}"
  ],
  [
    "name": "field_uuid",
    "value": "{
  \"type\": \"json\",
  \"value\": \"string\"
}"
  ],
  [
    "name": "record_uuid",
    "value": "{
  \"type\": \"json\",
  \"value\": \"string\"
}"
  ]
]

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://https/file?XDEBUG_SESSION_START=phpstorm_xdebug")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
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()
```