Use parsed email fields and raw MIME for different jobs
Keep normal agent reading simple while retaining a path to inspect original MIME structure and headers.
Inspect metadata, download bytes deliberately and keep attachment content out of automatic tool execution.
Messages, threads and drafts embed attachment metadata, including attachment_id, filename, size and content_type. Use that metadata to decide which files the task actually needs. A filename is an untrusted label rather than a safe filesystem path, and a declared content type does not guarantee the bytes match it. Normalize storage names to your own generated IDs and keep the original name as display metadata. Reject or defer unexpected sizes before allocating memory, and keep a clear distinction between an attachment being present and its contents having been successfully inspected.
For a message attachment, request GET /v0/emails/inboxes/:inbox_id/emails/:email_id/attachments/:attachment_id. Thread and draft attachment routes are also available under their corresponding resources. Preserve the binary response rather than trying to parse every successful API response as JSON. Check HTTP status before writing the body to disk: an error object saved as report.pdf is not a valid download. Bind your local download job to the organization, inbox, message and attachment IDs so a stale record cannot cause a different tenant’s object to be requested or mislabeled.
curl --fail-with-body \
"https://api.lupin.sh/v0/emails/inboxes/$INBOX_ID/emails/$EMAIL_ID/attachments/$ATTACHMENT_ID" \
-H "Authorization: Bearer $LUPIN_API_KEY" \
-o "$LUPIN_PRIVATE_STATE/attachment.bin"There is no standalone attachment upload endpoint in the current email API. Include attachments in a send or draft-create request. The /v0 JSON request ceiling is 32 MiB, including base64 encoding and other fields; the separate combined decoded-attachment ceiling is 30 MiB. Base64 expansion can reach the request ceiling first, so keep headroom below both limits rather than equating file size with request size. URL-backed attachments are fetched server-side and still require bounded downloads and the combined send check. A URL may contain a private signature: keep it out of model prompts and ordinary logs, and verify the current limits before planning bulk-document workflows.
For outbound attachments, show the reviewer the final recipient list, filenames, sizes and the document revision, not only the email body. A changed file requires renewed review if its content changes the approved action. For forwards, inspect the exact endpoint semantics instead of assuming every original attachment is copied automatically; draft forwarding merges content at send time. Your next step is a fixture set containing a harmless text file, mismatched content type, oversized file and hostile filename. Validate download handling with local fixtures before enabling attachment processing on real messages.
Compare observed byte length with the expected metadata where appropriate, retain a checksum for your local artifact and surface truncation or format failure. A successful HTTP response is only the download boundary. It does not prove that an archive expanded safely, a PDF contained selectable text or a spreadsheet’s formulas were evaluated correctly by your processor.
Reviewed against checked-in Lupin API handlers and documentation. Example requests were not executed against live providers.
Prepared with AI assistance by Lupin editorial. How we research and maintain these guides.