Skip to main content
The BlueBubbles SDK exposes all attachment operations through client.attachments. You can upload files before embedding them in multipart messages, download attachments by GUID, force-download files not yet cached on the Mac, fetch metadata, generate blur hashes for progressive image loading, and retrieve live photo videos. Each method corresponds to an endpoint on your BlueBubbles Server.

Upload an attachment for multipart messages

When you want to include a file inside a multipart message, you must upload it first. The two-step flow is:
1

Upload the file

Call uploadAttachment() with a multipart form body containing your file. The server stores the file and returns a unique UUID you reference in the next step.
The response shape looks like:
2

Reference the UUID in a multipart message

Pass the hash value from the upload response as the attachment field in the corresponding part:
This two-step upload flow is only required for multipart messages. If you just want to send a single file to a chat, use client.messages.sendAttachment() directly instead — no pre-upload needed.

Download an attachment

Use download() to retrieve the raw file bytes for an attachment you already have the GUID for. This is the standard download path — it works when the attachment is already cached on the Mac.
You can get attachment GUIDs from message query results. When you call client.messages.list() with "with": ["attachment"], each message object includes an attachments array with GUIDs you can pass directly to download().

Force-download an attachment

If an attachment exists in the database but hasn’t been downloaded to the Mac yet, download() returns a 404. In that case, use forceDownloadAttachment() to trigger the Mac to fetch the file from iCloud first.
forceDownloadAttachment() requires the Private API to be enabled on your BlueBubbles Server.
Use forceDownloadAttachment() when building apps that need to reliably retrieve older messages. Attachments from messages received before the BlueBubbles Server was installed may not be locally cached.

Fetch attachment metadata

Use get() to retrieve the database record for an attachment without downloading the file. This is useful for checking the MIME type, filename, or size before deciding whether to download.

Generate a blur hash

getAttachmentBlurhash() generates a BlurHash string for an image attachment. You can use the hash to render a blurred placeholder in your UI before the full image loads.
Generating a BlurHash is CPU-intensive on the server. For large images, the server resizes internally before hashing. Expect slightly longer response times compared to other attachment endpoints.

Retrieve a live photo

Use getAttachmentLivePhoto() to retrieve the video component of a Live Photo. If the attachment is not an image or doesn’t have a live version, the server returns an error.
Check the attachment’s MIME type with get() before calling getAttachmentLivePhoto(). Live photos are associated with image/jpeg or image/heic attachments that also have a paired video file.