Skip to content

drafts

ListDraftsQueryParams = TypedDict('ListDraftsQueryParams', {None: get_type_hints(ListQueryParams), 'subject': NotRequired[str], 'any_email': NotRequired[List[str]], 'from': NotRequired[List[str]], 'to': NotRequired[List[str]], 'cc': NotRequired[List[str]], 'bcc': NotRequired[List[str]], 'in': NotRequired[List[str]], 'unread': NotRequired[bool], 'starred': NotRequired[bool], 'thread_id': NotRequired[str], 'has_attachment': NotRequired[bool]}) module-attribute

Query parameters for listing drafts.

Attributes:

Name Type Description
subject

Return messages with matching subject.

any_email

Return messages that have been sent or received by this comma-separated list of email addresses.

from

Return messages sent from this email address.

to

Return messages sent to this email address.

cc

Return messages cc'd to this email address.

bcc

Return messages bcc'd to this email address.

in

Return messages in this specific folder or label, specified by ID.

unread

Filter messages by unread status.

starred

Filter messages by starred status.

has_attachment

Filter messages by whether they have an attachment.

limit NotRequired[int]

The maximum number of objects to return. This field defaults to 50. The maximum allowed value is 200.

page_token NotRequired[str]

An identifier that specifies which page of data to return. This value should be taken from a ListResponse object's next_cursor parameter.

UpdateDraftRequest = CreateDraftRequest module-attribute

A request to update a draft.

CreateDraftRequest

Bases: TypedDict

A request to create a draft.

Attributes:

Name Type Description
subject NotRequired[str]

The subject of the message.

to NotRequired[List[EmailName]]

The recipients of the message.

cc NotRequired[List[EmailName]]

The CC recipients of the message.

bcc NotRequired[List[EmailName]]

The BCC recipients of the message.

reply_to NotRequired[List[EmailName]]

The reply-to recipients of the message.

starred NotRequired[bool]

Whether the message is starred.

body NotRequired[str]

The body of the message.

attachments NotRequired[List[CreateAttachmentRequest]]

The attachments on the message.

send_at NotRequired[int]

Unix timestamp to send the message at.

reply_to_message_id NotRequired[str]

The ID of the message that you are replying to.

tracking_options NotRequired[TrackingOptions]

Options for tracking opens, links, and thread replies.

custom_headers NotRequired[List[CustomHeader]]

Custom headers to add to the message.

Source code in nylas/models/drafts.py
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
class CreateDraftRequest(TypedDict):
    """
    A request to create a draft.

    Attributes:
        subject: The subject of the message.
        to: The recipients of the message.
        cc: The CC recipients of the message.
        bcc: The BCC recipients of the message.
        reply_to: The reply-to recipients of the message.
        starred: Whether the message is starred.
        body: The body of the message.
        attachments: The attachments on the message.
        send_at: Unix timestamp to send the message at.
        reply_to_message_id: The ID of the message that you are replying to.
        tracking_options: Options for tracking opens, links, and thread replies.
        custom_headers: Custom headers to add to the message.
    """

    body: NotRequired[str]
    subject: NotRequired[str]
    to: NotRequired[List[EmailName]]
    bcc: NotRequired[List[EmailName]]
    cc: NotRequired[List[EmailName]]
    reply_to: NotRequired[List[EmailName]]
    attachments: NotRequired[List[CreateAttachmentRequest]]
    starred: NotRequired[bool]
    send_at: NotRequired[int]
    reply_to_message_id: NotRequired[str]
    tracking_options: NotRequired[TrackingOptions]
    custom_headers: NotRequired[List[CustomHeader]]

CustomHeader

Bases: TypedDict

A key-value pair representing a header that can be added to drafts and outgoing messages.

Attributes:

Name Type Description
name str

The name of the custom header.

value str

The value of the custom header.

Source code in nylas/models/drafts.py
60
61
62
63
64
65
66
67
68
69
70
class CustomHeader(TypedDict):
    """
    A key-value pair representing a header that can be added to drafts and outgoing messages.

    Attributes:
        name: The name of the custom header.
        value: The value of the custom header.
    """

    name: str
    value: str

Draft dataclass

Bases: Message

A Draft object.

Attributes:

Name Type Description
id str

Globally unique object identifier.

grant_id str

The grant that this message belongs to.

from_ List[EmailName]

The sender of the message.

date int

The date the message was received.

object str

The type of object.

thread_id Optional[str]

The thread that this message belongs to.

subject Optional[str]

The subject of the message.

to Optional[List[EmailName]]

The recipients of the message.

cc Optional[List[EmailName]]

The CC recipients of the message.

bcc Optional[List[EmailName]]

The BCC recipients of the message.

reply_to Optional[List[EmailName]]

The reply-to recipients of the message.

unread Optional[bool]

Whether the message is unread.

starred Optional[bool]

Whether the message is starred.

snippet Optional[str]

A snippet of the message body.

body Optional[str]

The body of the message.

attachments Optional[List[Attachment]]

The attachments on the message.

folders Optional[List[str]]

The folders that the message is in.

created_at Optional[int]

Unix timestamp of when the message was created.

Source code in nylas/models/drafts.py
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
@dataclass_json
@dataclass
class Draft(Message):
    """
    A Draft object.

    Attributes:
        id (str): Globally unique object identifier.
        grant_id (str): The grant that this message belongs to.
        from_ (List[EmailName]): The sender of the message.
        date (int): The date the message was received.
        object: The type of object.
        thread_id (Optional[str]): The thread that this message belongs to.
        subject (Optional[str]): The subject of the message.
        to (Optional[List[EmailName]]): The recipients of the message.
        cc (Optional[List[EmailName]]): The CC recipients of the message.
        bcc (Optional[List[EmailName]]): The BCC recipients of the message.
        reply_to (Optional[List[EmailName]]): The reply-to recipients of the message.
        unread (Optional[bool]): Whether the message is unread.
        starred (Optional[bool]): Whether the message is starred.
        snippet (Optional[str]): A snippet of the message body.
        body (Optional[str]): The body of the message.
        attachments (Optional[List[Attachment]]): The attachments on the message.
        folders (Optional[List[str]]): The folders that the message is in.
        created_at (Optional[int]): Unix timestamp of when the message was created.
    """

    object: str = "draft"

SendMessageRequest

Bases: CreateDraftRequest

A request to send a message.

Attributes:

Name Type Description
subject NotRequired[str]

The subject of the message.

to NotRequired[List[EmailName]]

The recipients of the message.

cc NotRequired[List[EmailName]]

The CC recipients of the message.

bcc NotRequired[List[EmailName]]

The BCC recipients of the message.

reply_to NotRequired[List[EmailName]]

The reply-to recipients of the message.

starred NotRequired[bool]

Whether the message is starred.

body NotRequired[str]

The body of the message.

attachments NotRequired[List[CreateAttachmentRequest]]

The attachments on the message.

send_at NotRequired[int]

Unix timestamp to send the message at.

reply_to_message_id NotRequired[str]

The ID of the message that you are replying to.

tracking_options NotRequired[TrackingOptions]

Options for tracking opens, links, and thread replies.

custom_headers(NotRequired[List[CustomHeader]]) NotRequired[TrackingOptions]

Custom headers to add to the message.

use_draft NotRequired[bool]

Whether or not to use draft support. This is primarily used when dealing with large attachments.

Source code in nylas/models/drafts.py
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
class SendMessageRequest(CreateDraftRequest):
    """
    A request to send a message.

    Attributes:
        subject (NotRequired[str]): The subject of the message.
        to (NotRequired[List[EmailName]]): The recipients of the message.
        cc (NotRequired[List[EmailName]]): The CC recipients of the message.
        bcc (NotRequired[List[EmailName]]): The BCC recipients of the message.
        reply_to (NotRequired[List[EmailName]]): The reply-to recipients of the message.
        starred (NotRequired[bool]): Whether the message is starred.
        body (NotRequired[str]): The body of the message.
        attachments (NotRequired[List[CreateAttachmentRequest]]): The attachments on the message.
        send_at (NotRequired[int]): Unix timestamp to send the message at.
        reply_to_message_id (NotRequired[str]): The ID of the message that you are replying to.
        tracking_options (NotRequired[TrackingOptions]): Options for tracking opens, links, and thread replies.
        custom_headers(NotRequired[List[CustomHeader]]): Custom headers to add to the message.
        use_draft: Whether or not to use draft support. This is primarily used when dealing with large attachments.
    """

    use_draft: NotRequired[bool]

TrackingOptions

Bases: TypedDict

The different tracking options for when a message is sent.

Attributes:

Name Type Description
label NotRequired[str]

The label to apply to tracked messages.

links NotRequired[bool]

Whether to track links.

opens NotRequired[bool]

Whether to track opens.

thread_replies NotRequired[bool]

Whether to track thread replies.

Source code in nylas/models/drafts.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
class TrackingOptions(TypedDict):
    """
    The different tracking options for when a message is sent.

    Attributes:
        label: The label to apply to tracked messages.
        links: Whether to track links.
        opens: Whether to track opens.
        thread_replies: Whether to track thread replies.
    """

    label: NotRequired[str]
    links: NotRequired[bool]
    opens: NotRequired[bool]
    thread_replies: NotRequired[bool]