> This page is for Developer Documentation.

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

# Create a file

POST https://{tenant_name}.benchling.com/api/v2-beta/files
Content-Type: application/json

Create a file of a supported type. Currently, we support these file extensions: .csv; .html;
.jmp, .jrn, .jrp (JMP); .jpeg, .jpg (JPEG); .png; .pdf; .zip; and .txt.

A successful file upload requires 3 calls in serial:

1. [Create a file](#/Analyses/createFile), this endpoint, which returns an S3 `PUT` URL for the 2nd
   call and a file ID for the 3rd call
2. Upload the file contents to S3. Add `x-amz-server-side-encryption: AES256` to the request headers,
   because we use server-side encryption. Here is a `curl` example:
   ```bash
   curl -H "x-amz-server-side-encryption: AES256" -X PUT -T <LOCAL_FILE> -L <S3_PUT_URL>
   ```
3. [Update the file](#/Analyses/patchFile), which marks the upload as `SUCCEEDED`

Note: URL is valid for 1 hour after being returned from this endpoint. It should not be stored
persistently for later use.

Files up to 30MB are supported.

Reference: https://docs.benchling.com/docs/api/v2-beta/benchling-api-beta/files/create-file

## Authentication

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

## Request

### Body (application/json)

This endpoint expects a FileCreate.

- `customFields` (map from string to CustomField, optional) — Custom field values to set on the file
- `filename` (string, optional) — Filename for the file
- `folderId` (string, optional) — ID of the folder that contains the file
- `name` (string, optional) — Display name for the file

## Response

### 200

OK

- `errorMessage` (string, optional, nullable)
- `uploadStatus` (enum, optional)
  - Allowed values: `IN_PROGRESS`, `SUCCEEDED`, `FAILED_VALIDATION`, `NOT_UPLOADED`
- `archiveRecord` (ArchiveRecord, optional, nullable) — ArchiveRecord Resource if the file is archived. This is null if the file is not archived.
- `createdAt` (datetime, optional) — Date and time the file was created
- `creator` (FileCreator, optional) — UserSummary of the user who created the file
- `customFields` (map from string to CustomField, optional) — Custom field values of the file
- `displayId` (string, optional) — User-friendly ID of the file
- `filename` (string, optional)
- `folderId` (string, optional) — ID of the folder that contains the file
- `id` (string, optional)
- `modifiedAt` (datetime, optional) — Date and time the file was last modified
- `name` (string, optional)

## Errors

### 400 Bad Request Error

Bad Request

- `error` (BadRequestErrorError, optional)

### 403 Forbidden Error

Forbidden

- `error` (ForbiddenErrorError, optional)

## Types

### CustomField

- `value` (string, optional)

### ArchiveRecord

- `reason` (string, optional)

### FileCreator

UserSummary of the user who created the file

- `handle` (string, optional)
- `id` (string, optional)
- `name` (string, optional)

### BadRequestErrorError

- `message` (string, optional)
- `type` (enum, optional)
  - Allowed values: `invalid_request_error`
- `userMessage` (string, optional)

### ForbiddenErrorError

- `invalidId` (string, optional)
- `message` (string, optional)
- `type` (string, optional)
- `userMessage` (string, optional)

## Examples

**Request**

```json
{}
```

**Response**

```json
{
  "errorMessage": null,
  "uploadStatus": "NOT_UPLOADED",
  "folderId": "lib_bf0636",
  "id": "file_Of5GuBSq",
  "name": "IC50Chart.png"
}
```

**SDK Code**

```python Files_createFile_example
import requests

url = "https://{tenant_name}.benchling.com/api/v2-beta/files"

payload = {}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Files_createFile_example
const url = 'https://{tenant_name}.benchling.com/api/v2-beta/files';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{}'
};

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