## Upload a file

`$client->assets->upload(string file, ?string fileName, ?string mimeType): AssetUploadResponse`

**post** `/v1/assets/upload`

Upload a file to a temporary location using multipart/form-data. Returns an uploadID that can be referenced when sending a message or creating a draft attachment.

### Parameters

- `file: string`

  The file to upload (max 500 MB).

- `fileName?:optional string`

  Original filename. Defaults to the uploaded file name if omitted

- `mimeType?:optional string`

  MIME type. Auto-detected from magic bytes if omitted

### Returns

- `AssetUploadResponse`

  - `?float duration`

    Duration in seconds (audio/videos)

  - `?string error`

    Error message if upload failed

  - `?string fileName`

    Resolved filename

  - `?float fileSize`

    File size in bytes

  - `?float height`

    Height in pixels (images/videos)

  - `?string mimeType`

    Detected or provided MIME type

  - `?string srcURL`

    Local file URL (file://) for the uploaded file

  - `?string uploadID`

    Unique upload ID for this temporary file

  - `?float width`

    Width in pixels (images/videos)

### Example

```php
<?php

require_once dirname(__DIR__) . '/vendor/autoload.php';

$client = new Client(accessToken: 'My Access Token');

$response = $client->assets->upload(
  file: 'file', fileName: 'fileName', mimeType: 'mimeType'
);

var_dump($response);
```

#### Response

```json
{
  "duration": 0,
  "error": "error",
  "fileName": "fileName",
  "fileSize": 0,
  "height": 0,
  "mimeType": "mimeType",
  "srcURL": "srcURL",
  "uploadID": "uploadID",
  "width": 0
}
```
