Skip to content

attachments

Attachment dataclass

An attachment on a message.

Attributes:

Name Type Description
id Optional[str]

Globally unique object identifier.

grant_id Optional[str]

The grant ID of the attachment.

size Optional[int]

Size of the attachment in bytes.

filename Optional[str]

Name of the attachment.

content_type Optional[str]

MIME type of the attachment.

content_id Optional[str]

The content ID of the attachment.

content_disposition Optional[str]

The content disposition of the attachment.

is_inline Optional[bool]

Whether the attachment is inline.

Source code in nylas/models/attachments.py
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
@dataclass_json
@dataclass
class Attachment:
    """
    An attachment on a message.

    Attributes:
        id: Globally unique object identifier.
        grant_id: The grant ID of the attachment.
        size: Size of the attachment in bytes.
        filename: Name of the attachment.
        content_type: MIME type of the attachment.
        content_id: The content ID of the attachment.
        content_disposition: The content disposition of the attachment.
        is_inline: Whether the attachment is inline.
    """

    id: Optional[str] = None
    grant_id: Optional[str] = None
    filename: Optional[str] = None
    content_type: Optional[str] = None
    size: Optional[int] = None
    content_id: Optional[str] = None
    content_disposition: Optional[str] = None
    is_inline: Optional[bool] = None

AttachmentUploadSession dataclass

Upload session returned when creating a large-attachment upload session.

Attributes:

Name Type Description
attachment_id Optional[str]

Unique session ID — use when completing the session and when referencing the attachment in send/draft.

method Optional[str]

HTTP method to use when uploading to url. Always 'PUT'.

url Optional[str]

Pre-signed URL to upload file bytes (no Nylas auth header needed).

headers Optional[Dict[str, str]]

Headers to include when uploading to url.

expires_at Optional[str]

When the session expires (RFC 3339).

max_size Optional[int]

Maximum allowed file size in bytes (157286400).

size Optional[int]

Expected file size echoing the request; 0 if size was omitted.

content_type Optional[str]

MIME type of the file.

filename Optional[str]

Name of the file.

grant_id Optional[str]

Grant ID the session belongs to.

Source code in nylas/models/attachments.py
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
@dataclass_json
@dataclass
class AttachmentUploadSession:
    """
    Upload session returned when creating a large-attachment upload session.

    Attributes:
        attachment_id: Unique session ID — use when completing the session and when
                       referencing the attachment in send/draft.
        method: HTTP method to use when uploading to `url`. Always 'PUT'.
        url: Pre-signed URL to upload file bytes (no Nylas auth header needed).
        headers: Headers to include when uploading to `url`.
        expires_at: When the session expires (RFC 3339).
        max_size: Maximum allowed file size in bytes (157286400).
        size: Expected file size echoing the request; 0 if `size` was omitted.
        content_type: MIME type of the file.
        filename: Name of the file.
        grant_id: Grant ID the session belongs to.
    """

    attachment_id: Optional[str] = None
    method: Optional[str] = None
    url: Optional[str] = None
    headers: Optional[Dict[str, str]] = None
    expires_at: Optional[str] = None
    max_size: Optional[int] = None
    size: Optional[int] = None
    content_type: Optional[str] = None
    filename: Optional[str] = None
    grant_id: Optional[str] = None

AttachmentUploadSessionComplete dataclass

Result of completing a large-attachment upload session.

Attributes:

Name Type Description
attachment_id Optional[str]

The session ID.

grant_id Optional[str]

Grant ID the session belongs to.

status Optional[str]

Upload status; typically 'ready' after successful completion.

Source code in nylas/models/attachments.py
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
@dataclass_json
@dataclass
class AttachmentUploadSessionComplete:
    """
    Result of completing a large-attachment upload session.

    Attributes:
        attachment_id: The session ID.
        grant_id: Grant ID the session belongs to.
        status: Upload status; typically 'ready' after successful completion.
    """

    attachment_id: Optional[str] = None
    grant_id: Optional[str] = None
    status: Optional[str] = None

CreateAttachmentRequest

Bases: TypedDict

A request to create an attachment.

You can use attach_file_request_builder() to build this request.

Attributes:

Name Type Description
filename str

Name of the attachment.

content_type str

MIME type of the attachment.

content Union[str, BinaryIO]

Either a Base64 encoded content of the attachment or a pointer to a file.

size int

Size of the attachment in bytes.

content_id NotRequired[str]

The content ID of the attachment.

content_disposition NotRequired[str]

The content disposition of the attachment.

is_inline NotRequired[bool]

Whether the attachment is inline.

Source code in nylas/models/attachments.py
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
class CreateAttachmentRequest(TypedDict):
    """
    A request to create an attachment.

    You can use `attach_file_request_builder()` to build this request.

    Attributes:
        filename: Name of the attachment.
        content_type: MIME type of the attachment.
        content: Either a Base64 encoded content of the attachment or a pointer to a file.
        size: Size of the attachment in bytes.
        content_id: The content ID of the attachment.
        content_disposition: The content disposition of the attachment.
        is_inline: Whether the attachment is inline.
    """

    filename: str
    content_type: str
    content: Union[str, BinaryIO]
    size: int
    content_id: NotRequired[str]
    content_disposition: NotRequired[str]
    is_inline: NotRequired[bool]

CreateAttachmentUploadSessionRequest

Bases: TypedDict

Request body for creating a large-attachment upload session (Graph only).

Attributes:

Name Type Description
filename str

The name of the file as it will appear in the email.

content_type str

MIME type of the file (e.g. 'application/pdf').

size NotRequired[int]

Expected file size in bytes (max 157286400 / 150 MB). Recommended — Nylas validates the upload matches this size at completion.

Source code in nylas/models/attachments.py
74
75
76
77
78
79
80
81
82
83
84
85
86
87
class CreateAttachmentUploadSessionRequest(TypedDict):
    """
    Request body for creating a large-attachment upload session (Graph only).

    Attributes:
        filename: The name of the file as it will appear in the email.
        content_type: MIME type of the file (e.g. 'application/pdf').
        size: Expected file size in bytes (max 157286400 / 150 MB). Recommended —
              Nylas validates the upload matches this size at completion.
    """

    filename: str
    content_type: str
    size: NotRequired[int]

FindAttachmentQueryParams

Bases: TypedDict

Interface of the query parameters for finding an attachment.

Attributes:

Name Type Description
message_id str

Message ID to find the attachment in.

Source code in nylas/models/attachments.py
60
61
62
63
64
65
66
67
68
class FindAttachmentQueryParams(TypedDict):
    """
    Interface of the query parameters for finding an attachment.

    Attributes:
        message_id: Message ID to find the attachment in.
    """

    message_id: str