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

# Upload a file

POST https://platform.labric.co/api/v1/files
Content-Type: multipart/form-data

Upload a file.

Accepts a multipart/form-data file upload, stores it in GCS, and returns the
created file record. At least one of job_execution_id and instrument_id is
required: pass a job_execution_id for an artifact of a job running in a
sandbox, which also records provenance linking the file to that execution,
and pass an instrument_id for data captured off-platform by an instrument the
Sync app cannot reach, which attaches the file to that instrument so
instrument triggers and parsers pick it up.

Requires an API key with the `write` scope.

Reference: https://docs.labric.co/api-reference/labric-api/files/upload

## Authentication

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

## Request

### Body (multipart/form-data)

This endpoint expects a multipart form containing a file.

- `file` (file, required)
- `job_execution_id` (string, optional)
- `instrument_id` (string, optional)

## Response

### 200

OK

- `file_id` (string, required) — The ID of the uploaded file.
- `file_name` (string, required) — The original file name.
- `size_kilobytes` (integer, required, nullable) — File size in kilobytes.

## Errors

### 400 Bad Request Error

Bad Request

- `detail` (string, required)

### 401 Unauthorized Error

Unauthorized

- `detail` (string, required)

### 403 Forbidden Error

Forbidden

- `detail` (string, required)

### 404 Not Found Error

Not Found

- `detail` (string, required)

### 409 Conflict Error

Conflict

- `detail` (string, required)

### 422 Unprocessable Entity Error

Unprocessable Content

- `detail` (list of map from string to any, required)

### 500 Internal Server Error

Internal Server Error

- `detail` (string, required)

## Examples

**Request**

```json
{
  "file": "<file: [object Object]>",
  "instrument_id": {
    "type": "json"
  },
  "job_execution_id": {
    "type": "json"
  }
}
```

**Response**

```json
{
  "file_id": "string",
  "file_name": "string",
  "size_kilobytes": 1
}
```

**SDK Code**

```python
from labric import Labric

client = Labric(
    api_key="YOUR_TOKEN_HERE",
)

client.files.upload(
    file="example_file",
)

```