Skip to main content

agentmail/types/
attachments.rs

1use serde::{Deserialize, Serialize};
2
3/// Attachment metadata as returned in message, thread, and draft responses.
4/// `download_url` (a short-lived presigned URL) is populated only by the
5/// attachment-download endpoints; the other fields describe the attachment in
6/// list and get responses.
7#[derive(Clone, Debug, Deserialize)]
8pub struct Attachment {
9    /// Unique attachment id.
10    pub attachment_id: String,
11    /// File name.
12    #[serde(default)]
13    pub filename: Option<String>,
14    /// Size in bytes.
15    #[serde(default)]
16    pub size: Option<u64>,
17    /// MIME content type.
18    #[serde(default)]
19    pub content_type: Option<String>,
20    /// Content-Disposition (e.g. `inline` or `attachment`).
21    #[serde(default)]
22    pub content_disposition: Option<String>,
23    /// Content-ID, for inline attachments referenced by the HTML body.
24    #[serde(default)]
25    pub content_id: Option<String>,
26    /// Short-lived presigned URL to download the bytes; populated only by the
27    /// attachment-download endpoints.
28    #[serde(default)]
29    pub download_url: Option<String>,
30    /// When `download_url` expires (RFC 3339).
31    #[serde(default)]
32    pub expires_at: Option<String>,
33    /// Presigned URL to the API's text extraction of this attachment, when
34    /// one exists (attachment-download responses).
35    #[serde(default)]
36    pub text_url: Option<String>,
37}
38
39/// An attachment to include on an outgoing message or draft. Supply the bytes
40/// inline as base64 `content`, or a `url` for the API to fetch; set `content_id`
41/// to reference the attachment inline from the HTML body.
42#[derive(Clone, Debug, Default, Serialize)]
43pub struct SendAttachment {
44    /// File name.
45    #[serde(skip_serializing_if = "Option::is_none")]
46    pub filename: Option<String>,
47    /// MIME content type.
48    #[serde(skip_serializing_if = "Option::is_none")]
49    pub content_type: Option<String>,
50    /// Content-Disposition (e.g. `inline` or `attachment`).
51    #[serde(skip_serializing_if = "Option::is_none")]
52    pub content_disposition: Option<String>,
53    /// Content-ID, to reference this attachment inline from the HTML body.
54    #[serde(skip_serializing_if = "Option::is_none")]
55    pub content_id: Option<String>,
56    /// The attachment bytes, base64-encoded.
57    #[serde(skip_serializing_if = "Option::is_none")]
58    pub content: Option<String>,
59    /// A URL for the API to fetch the attachment from, instead of `content`.
60    #[serde(skip_serializing_if = "Option::is_none")]
61    pub url: Option<String>,
62}