Mailcandor keeps every file from a received email. You fetch a short-lived link and download from it.
What you get about each attachment
In the email.received webhook and in every received email from the API:
{
"id": "a4f2c1d0-5b6e-4f7a-8c9d-0e1f2a3b4c5d",
"filename": "proof.pdf",
"content_type": "application/pdf",
"content_disposition": "attachment",
"content_id": null,
"size": 48213
}
content_dispositionisattachmentfor attached files and usuallyinlinefor images shown in the body.content_idis set for inline parts; the HTML refers to it ascid:....sizeis in bytes.- Files without a name are called
attachment-0,attachment-1and so on.
To download in the dashboard
- Open Received and select the email.
- Under Attachments, select the file name.
The link works for 30 minutes.
To download with the API
Use a full-access key.
1. Get the link:
curl https://api.mailcandor.com/v1/emails/receiving/EMAIL_ID/attachments/ATTACHMENT_ID \
-H "Authorization: Bearer $MAILCANDOR_KEY"
{
"object": "attachment",
"id": "a4f2c1d0-5b6e-4f7a-8c9d-0e1f2a3b4c5d",
"filename": "proof.pdf",
"content_type": "application/pdf",
"content_disposition": "attachment",
"content_id": null,
"size": 48213,
"download_url": "https://.../inbound/attachments/a4f2c1d0-...?expires=...&signature=...",
"expires_at": "2026-11-15T11:20:00Z"
}
2. Download the file, no API key needed:
curl -L -o proof.pdf "DOWNLOAD_URL"
To get links for every file on an email at once:
curl https://api.mailcandor.com/v1/emails/receiving/EMAIL_ID/attachments \
-H "Authorization: Bearer $MAILCANDOR_KEY"
It returns {"object": "list", "data": [...]}, each with its own download_url.
In Node.js
const headers = { Authorization: `Bearer ${process.env.MAILCANDOR_KEY}` };
const base = 'https://api.mailcandor.com/v1/emails/receiving';
const { data } = await (await fetch(`${base}/${emailId}/attachments`, { headers })).json();
for (const file of data) {
if (file.content_disposition === 'inline') continue; // skip logos and signatures
const bytes = Buffer.from(await (await fetch(file.download_url)).arrayBuffer());
await saveFile(file.filename, file.content_type, bytes);
}
Handle files safely
Received files come from anyone who can email you.
- Check the Virus check verdict on the email in the dashboard before trusting files.
- Do not trust
filenamefor paths on your server. Generate your own name. - Do not trust
content_typealone. Check the file itself before you process it. - Do not share
download_urllinks publicly. Anyone with a link can download the file until it expires.
If it does not work
- The link answers 403: it expired or was changed. Ask the API for a new one.
404 not_found“No attachment with this id on that email.”: the attachment id belongs to a different email. Use the ids from that email’sattachments.403 restricted_api_key: use a full-access key.- A file you expected is missing: some mail apps put content in the body instead of as a file. Check
htmlandtextfromGET /v1/emails/receiving/{id}.