Read attachment metadata on inbound mail, mint short-lived download links, or fetch the raw bytes.
Files on inbound mail arrive as metadata — filename, content type, size — never as inline bytes. When you need the file, mint a short-lived signed link you can hand to a browser or another service, or download the bytes directly. Every attachment read uses the messages:read scope.
Treat every inbound attachment as untrusted. Received files come from arbitrary senders and can carry malware, exploits, or phishing content. A Dairo-hosted download link only means Dairo serves the link — it is not a safety judgment about the file. Never auto-open, auto-execute, or feed attachment bytes into a shell, parser, or renderer. Scan with antivirus, enforce content-type and size limits, process in a sandbox, and require human review before opening files you didn't create.
Read attachment metadata
Attachment ids come from the attachments array on a fetched message. Fetch one to get its filename, content type, size, and the message it belongs to.
The disposition is attachment for a normal file or inline for one referenced from the HTML body (an embedded image, say).
Get the file
Three endpoints serve the file, each for a different consumer:
| Endpoint | What you get |
|---|---|
GET /v1/attachments/{id}/url | A signed downloadUrl plus a human-friendly shareUrl, both time-boxed. |
GET /v1/attachments/{id}/link | The same response shape, always minted as Dairo-branded links. |
GET /v1/attachments/{id}/download | The raw bytes, served with the file's content type and filename. |
On /url and /link, expiryHours sets how long the links stay valid — an integer from 1 to 168 (one week). Omit it and the links last five minutes.
Dairo scans inbound files for malware. Until a file passes, downloadUrl is a short-lived direct link for you alone and shareUrl is null; GET /v1/attachments/{id}/link, which only returns branded links, answers 409 until then. Once the scan passes you get the branded links shown above. A file the scan flags is withheld — requests for it return 403.
Share a file by link
The shareUrl is a human-friendly download page — handy when you want to hand a file to someone in an email. Dairo never inserts links into your mail for you: mint the link, then place it in your text or html deliberately.
Two things to keep in mind when sharing inbound files onward:
- A share link exists only for an inbound file that passed Dairo's malware scan; until then there is no
shareUrlto hand out. - Sharing a file onward means vouching for a file you didn't author. The page is hosted by Dairo, but the file behind it is whatever the sender attached — confirm it's safe before distributing the link.
Next steps
- Send an email — attach files to outbound mail.
- Share links — the same short-lived links over files in your own storage buckets.
- API reference — every endpoint, with copy-paste requests.