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}
34
35/// An attachment to include on an outgoing message or draft. Supply the bytes
36/// inline as base64 `content`, or a `url` for the API to fetch; set `content_id`
37/// to reference the attachment inline from the HTML body.
38#[derive(Clone, Debug, Default, Serialize)]
39pub struct SendAttachment {
40 /// File name.
41 #[serde(skip_serializing_if = "Option::is_none")]
42 pub filename: Option<String>,
43 /// MIME content type.
44 #[serde(skip_serializing_if = "Option::is_none")]
45 pub content_type: Option<String>,
46 /// Content-Disposition (e.g. `inline` or `attachment`).
47 #[serde(skip_serializing_if = "Option::is_none")]
48 pub content_disposition: Option<String>,
49 /// Content-ID, to reference this attachment inline from the HTML body.
50 #[serde(skip_serializing_if = "Option::is_none")]
51 pub content_id: Option<String>,
52 /// The attachment bytes, base64-encoded.
53 #[serde(skip_serializing_if = "Option::is_none")]
54 pub content: Option<String>,
55 /// A URL for the API to fetch the attachment from, instead of `content`.
56 #[serde(skip_serializing_if = "Option::is_none")]
57 pub url: Option<String>,
58}