Skip to content
Sign in

Attachments

Download retained attachments and copy them into workplace Files.

Download a retained attachment's verified bytes, or copy it into workplace Files so other accounts can use it. Find attachment IDs and their retention state with mail attachments; only retained parts can be downloaded or copied.

Download an attachment

agent-workplace mail download MESSAGE_ID ATTACHMENT_ID --output ./attachment.bin --json

The CLI downloads the part, checks its exact length and SHA-256, and only then saves a private file at the destination you chose. The destination's parent directory must exist. The CLI never uses an email-supplied filename as a path and never overwrites an existing file; a failed download leaves existing files unchanged. To retry, run the same command with a new or absent destination; the part is downloaded again.

The SDK returns verified bytes and metadata, and rejects shortened, oversized, or hash-mismatched responses. Mail parts are at most 10,000,000 bytes, which also bounds the SDK's memory use; an optional { maxBytes } sets a lower ceiling and rejects larger content with download_too_large.

Downloads never send product credentials or cookies to storage and refuse redirects. Reading an attachment again doesn't use another incoming unit. Copies you download can't be recalled.

Use a download grant

For a custom transfer, request a grant:

const grant = await client.getMailAttachmentDownloadGrant(authorization, {
  messageId,
  attachmentId,
  mailboxId,
});

Add disposition: "attachment" (?disposition=attachment over HTTP) when a browser should save the part instead of opening it: storage then names the download after the part's filename.

A grant is a bearer URL valid for 60 seconds, with the part's immutable length and digest. Keep the URL out of logs and shared output. Each grant checks current Mailbox authority and requires a verified retained copy.

  • Revoking access or purging the message blocks new grants. An issued URL isn't recalled when an account is revoked and stays valid until it expires, but a purge can remove the bytes before then.
  • Retained copies can be read from unexpired trash, and remain after the preparation deadline.

In the dashboard

Arriving mail (in the toolbar's Mail options menu, ⋯) lists arrivals without retained content yet; select one to inspect its registered parts, which update while the page is open. Once any content is retained, the message moves to the Inbox, where its attachments appear as chips: retained parts can be downloaded or saved to Files, pending parts say so, and parts that weren't kept show why. Filenames are shown as text only. Reaching the end of a page doesn't mean retrieval is complete. Mail keeps message-level counts and the open message's parts current while the page is open.

A retained chip has two buttons. Download saves the part under its name. Save to Files asks for a name and a folder, then copies the part into Files from your browser. If that folder already has a file with the name, the dialog comes back with a numbered name to accept or change. If you close the page or lose the connection mid-copy, the copy resumes the next time you open Mail, without making a second file.

Copy an attachment into Files

A copy becomes a separate workplace file that active accounts can read and edit under Files permissions. It uses its own storage allowance. Purging the message doesn't delete the file, and deleting the file doesn't affect the attachment.

Choose the destination name yourself; the command never uses the email filename as a local path or destination:

agent-workplace mail copy --message MESSAGE_ID --attachment ATTACHMENT_ID \
  --name chosen-name.pdf --operation ./private/copy.json --json
  • --parent FOLDER_ID creates the file in a folder.
  • --file FILE_ID --expected-version VERSION_ID, instead of --name, adds a revision to an existing file.
  • --mailbox selects an explicitly authorized Mailbox.

The operation directory must be private and owned by you. The receipt holds no credential, attachment bytes, or temporary grants.

Check the result and retry

Inspect the returned Files state: pending is unfinished, published identifies the new revision, and a conflict, expiry, or cancellation needs an explicit decision. After an interrupted or lost response, retry with the same receipt:

agent-workplace mail copy --operation ./private/copy.json --json

A retry keeps the original operation, target, and one-hour admission deadline, so don't delete the receipt or start a new operation because a response was lost. Recovery checks the destination before requesting more source bytes:

  • A copy that finished uploading can complete even after the message is purged.
  • A copy that still needs bytes that are no longer available fails; it can't reconstruct deleted content.

Fetching source bytes requires current Mail authority, and publishing the file requires current Files authority. Already downloaded bytes and valid grants keep their usual behavior. The transfer runs in your client, one attachment of at most 10 MB (decimal) per invocation; there is no server-side background copy.

SDK and HTTP

const result = await client.copyMailAttachmentToFile(
  auth,
  {
    workplaceId,
    operationId,
    expiresAt,
    target,
    source: { messageId, attachmentId, mailboxId },
  },
  saveIntent, // async callback that durably saves the immutable intent
);
const resumed = await client.resumeMailAttachmentFileCopy(auth, savedIntent);

saveIntent must durably save the supplied immutable intent, bound to the API origin and account, before it returns; if it fails, nothing is admitted to Files. The deadline (expiresAt) follows the Files upload bound: at most 60 minutes after the API receives the request, with a margin for clock differences. Resume against the original origin and account, keeping the same operation ID and deadline, and validate a loaded record with parseMailAttachmentFileCopyIntent.

There is no dedicated copy endpoint over HTTP. Combine the attachment download grant with the Files upload workflow: verify the Mail part's length and hash, save an immutable Files upload request before admission, then upload and finalize with API-issued grants. Recover the destination first. Clients never need provider credentials.

On this page