Skip to main content
im.attachments uploads file bytes to the server, reads attachment metadata, and downloads attachments in chunks. Sending an attachment message is a two-step flow: upload the file to get an attachment GUID, then pass that GUID to the messages API. Message sends accept server attachment GUIDs. They do not accept local file paths.

What You Can Do

Upload an Attachment

A regular attachment needs two fields: fileName and data. After upload, send uploaded.attachment.guid.
upload(...) returns UploadAttachmentResult. For a regular attachment, use the attachment field:
Input shape:
The file extension is not strictly required. The server first tries to detect MIME / UTI from the bytes, then falls back to the fileName extension. Files without an extension can still upload, but unknown types may be labeled application/octet-stream / public.data, which usually gives recipients a worse preview. Keep extensions for documents, archives, and Office files. Each uploaded file is limited to 100 MiB by default.

Common Formats

The SDK uploads raw bytes and the server stores them as-is. Messages.app and Apple’s delivery path decide how the recipient sees the file: inline preview, file attachment, transcoded media, or an iCloud link.
Apple may reject, compress, or convert payloads that are too large or not supported by the recipient path. The SDK uploads bytes; it does not control the final presentation.

Upload a Live Photo

A Live Photo is a paired upload: the primary file is a HEIC/HEIF image, and companion.data is the matching QuickTime .MOV video. When sending, still pass only livePhoto.attachment.guid.
When the Live Photo upload succeeds, UploadAttachmentResult includes both attachment and companion:
The primary file and companion file are counted separately. Each defaults to the 100 MiB upload limit.
Do not pass a .MOV file as the primary fileName. A Live Photo primary file should be HEIC/HEIF; the MOV belongs in companion.data.

Get Metadata

You do not need get(...) before sending an attachment. Use it when you need to inspect attachment state, display file information, or confirm that a file is ready before downloading.
Returns AttachmentInfo. Use transferState to decide whether the attachment is ready to download. Missing or unresolvable attachments throw NotFoundError.
transferState can be:

Stream Downloads

Before downloading, check that transferState === "finished" when you can. Otherwise the server may throw attachmentNotReady.
The stream emits one header frame first, followed by data chunks. Regular attachments only emit primaryChunk; Live Photos may also emit companionChunk.
Breaking out of the for await loop cancels the download. If an attachment is not ready, poll get(...) until transferState becomes "finished", then call downloadStream(...). Minimal save-to-file example:

Next Steps

  1. Messages — send attachment messages with attachment GUIDs
  2. Error Handling — handle NotFoundError, ValidationError, and attachmentNotReady
  3. Chats — create a chat and get chat.guid