> ## Documentation Index
> Fetch the complete documentation index at: https://docs.leavo.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Manage Uploads

> Query, update status, and delete files

## Get Upload by ID

```bash theme={null}
GET /backend/uploads/{id}
```

**Response (200):**

```json theme={null}
{
  "id": "uuid",
  "tenant_id": "uuid",
  "filename": "product_photo",
  "file_type": "media",
  "file_url": "https://api.leavo.ai/media/proxy/tenant_id/uuid.jpg",
  "mime_type": "image/jpeg",
  "size": 1048576,
  "status": "PENDING",
  "created_at": "2024-01-15T10:30:00Z",
  "updated_at": "2024-01-15T10:30:00Z"
}
```

## List Tenant Uploads

```bash theme={null}
GET /backend/uploads/tenant/{tenantId}
```

Returns all tenant uploads, ordered by creation date.

## Update Status

```bash theme={null}
PUT /backend/uploads/{id}/status
```

**Body:**

```json theme={null}
{
  "status": "ASSOCIATED"
}
```

| Status       | Description                                         |
| ------------ | --------------------------------------------------- |
| `PENDING`    | Upload not yet linked                               |
| `ASSOCIATED` | Upload linked to an entity (protected from cleanup) |

## Delete Upload

```bash theme={null}
DELETE /backend/uploads/{id}
```

Removes the file from storage and the database record.

**Response:** 200 OK

## Cleanup Orphaned Uploads

```bash theme={null}
POST /backend/uploads/cleanup?hours=24
```

Removes uploads with `PENDING` status older than the specified number of hours.

| Parameter | Type    | Default | Description                  |
| --------- | ------- | ------- | ---------------------------- |
| `hours`   | integer | 24      | Minimum hours since creation |

## Public File Access

Files can be accessed publicly through the media proxy:

```
GET /media/proxy/{path}
```

The proxy sets the following headers:

* `Content-Type`: file MIME type
* `Cache-Control`: `public, max-age=86400` (24 hours)
* `Access-Control-Allow-Origin`: `*`
