Overview
This endpoint allows you to download email attachments using the email ID and filename. The attachment URL is automatically provided in webhook payloads for easy access.This endpoint is typically used with the
downloadUrl
field provided in webhook payloads, but you can also construct the URL manually if needed.Authentication
Bearer token for API authentication. Format:
Bearer YOUR_API_KEY
Path Parameters
The structured email ID (the email’s unique identifier in Inbound).
The filename of the attachment to download. Must be URL-encoded if it contains special characters.
Response
The endpoint returns the raw file content with appropriate headers:- Content-Type: The attachment’s MIME type (e.g.,
application/pdf
,image/png
) - Content-Disposition: Set to
attachment; filename="..."
for proper download behavior - Content-Length: Size of the file in bytes
- Cache-Control: Set to
private, max-age=3600
for secure caching
Examples
Download from Webhook Payload
Save to Cloud Storage
Error Responses
Important Notes
Authentication Required: You must include a valid API key in the
Authorization
header to download attachments. Only the email owner can download attachments.Smart Content Retrieval: The endpoint automatically tries S3 storage first, then falls back to direct email content if S3 is unavailable.
URL Encoding: If the filename contains special characters, it should be URL-encoded in the download URL. The
downloadUrl
in webhook payloads is already properly encoded.Usage in Webhook Handlers
The most common use case is downloading attachments from webhook payloads:Security Considerations
1
API Key Protection
Never expose your API key in client-side code. Always download attachments from server-side code.
2
User Verification
The endpoint automatically verifies that the requesting user owns the email before allowing downloads.
3
Content Type Validation
Always validate the content type before processing downloaded files to prevent security issues.
Related Endpoints
Get Email
Retrieve complete email details including attachment metadata
Webhook Structure
View the complete webhook payload structure
Notes
- Attachments are downloaded as raw binary data
- The endpoint respects S3 storage location and falls back to direct content
- Only the email owner (authenticated user) can download attachments
- The filename in the URL is used for proper Content-Disposition headers
- Large attachments may take longer to download depending on size
- Download URLs in webhook payloads are automatically URL-encoded
1.0 - ✅