Skip to content
Download Beeper

Upload an asset

client.assets.upload(AssetUploadParams { file, fileName, mimeType } body, RequestOptionsoptions?): AssetUploadResponse { duration, error, fileName, 6 more }
POST/v1/assets/upload

Upload a file to a temporary location using multipart/form-data. Returns an uploadID that can be referenced when sending messages with attachments.

ParametersExpand Collapse
body: AssetUploadParams { file, fileName, mimeType }

The file to upload (max 500 MB).

fileName?: string

Original filename. Defaults to the uploaded file name if omitted

mimeType?: string

MIME type. Auto-detected from magic bytes if omitted

ReturnsExpand Collapse
AssetUploadResponse { duration, error, fileName, 6 more }
duration?: number

Duration in seconds (audio/videos)

error?: string

Error message if upload failed

fileName?: string

Resolved filename

fileSize?: number

File size in bytes

height?: number

Height in pixels (images/videos)

mimeType?: string

Detected or provided MIME type

srcURL?: string

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

uploadID?: string

Unique upload ID for this asset

width?: number

Width in pixels (images/videos)

Upload an asset

import BeeperDesktop from '@beeper/desktop-api';

const client = new BeeperDesktop();

const response = await client.assets.upload({ file: fs.createReadStream('path/to/file') });

console.log(response.width);
{
  "duration": 0,
  "error": "error",
  "fileName": "fileName",
  "fileSize": 0,
  "height": 0,
  "mimeType": "mimeType",
  "srcURL": "srcURL",
  "uploadID": "uploadID",
  "width": 0
}
Returns Examples
{
  "duration": 0,
  "error": "error",
  "fileName": "fileName",
  "fileSize": 0,
  "height": 0,
  "mimeType": "mimeType",
  "srcURL": "srcURL",
  "uploadID": "uploadID",
  "width": 0
}