Skip to content

threads

Threads

Bases: ListableApiResource, FindableApiResource, UpdatableApiResource, DestroyableApiResource

Nylas Threads API

The threads API allows you to find, update, and delete threads.

Source code in nylas/resources/threads.py
11
12
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
class Threads(
    ListableApiResource,
    FindableApiResource,
    UpdatableApiResource,
    DestroyableApiResource,
):
    """
    Nylas Threads API

    The threads API allows you to find, update, and delete threads.
    """

    def list(
        self, identifier: str, query_params: ListThreadsQueryParams = None
    ) -> ListResponse[Thread]:
        """
        Return all Threads.

        Args:
            identifier: The identifier of the grant to get threads for.
            query_params: The query parameters to filter threads by.

        Returns:
            A list of Threads.
        """
        return super().list(
            path=f"/v3/grants/{identifier}/threads",
            response_type=Thread,
            query_params=query_params,
        )

    def find(self, identifier: str, thread_id: str) -> Response[Thread]:
        """
        Return a Thread.

        Args:
            identifier: The identifier of the grant to get the thread for.
            thread_id: The identifier of the thread to get.

        Returns:
            The requested Thread.
        """
        return super().find(
            path=f"/v3/grants/{identifier}/threads/{thread_id}",
            response_type=Thread,
        )

    def update(
        self,
        identifier: str,
        thread_id: str,
        request_body: UpdateThreadRequest,
    ) -> Response[Thread]:
        """
        Update a Thread.

        Args:
            identifier: The identifier of the grant to update the thread for.
            thread_id: The identifier of the thread to update.
            request_body: The request body to update the thread with.

        Returns:
            The updated Thread.
        """
        return super().update(
            path=f"/v3/grants/{identifier}/threads/{thread_id}",
            response_type=Thread,
            request_body=request_body,
        )

    def destroy(self, identifier: str, thread_id: str) -> DeleteResponse:
        """
        Delete a Thread.

        Args:
            identifier: The identifier of the grant to delete the thread for.
            thread_id: The identifier of the thread to delete.

        Returns:
            The deletion response.
        """
        return super().destroy(
            path=f"/v3/grants/{identifier}/threads/{thread_id}",
        )

destroy(identifier, thread_id)

Delete a Thread.

Parameters:

Name Type Description Default
identifier str

The identifier of the grant to delete the thread for.

required
thread_id str

The identifier of the thread to delete.

required

Returns:

Type Description
DeleteResponse

The deletion response.

Source code in nylas/resources/threads.py
81
82
83
84
85
86
87
88
89
90
91
92
93
94
def destroy(self, identifier: str, thread_id: str) -> DeleteResponse:
    """
    Delete a Thread.

    Args:
        identifier: The identifier of the grant to delete the thread for.
        thread_id: The identifier of the thread to delete.

    Returns:
        The deletion response.
    """
    return super().destroy(
        path=f"/v3/grants/{identifier}/threads/{thread_id}",
    )

find(identifier, thread_id)

Return a Thread.

Parameters:

Name Type Description Default
identifier str

The identifier of the grant to get the thread for.

required
thread_id str

The identifier of the thread to get.

required

Returns:

Type Description
Response[Thread]

The requested Thread.

Source code in nylas/resources/threads.py
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
def find(self, identifier: str, thread_id: str) -> Response[Thread]:
    """
    Return a Thread.

    Args:
        identifier: The identifier of the grant to get the thread for.
        thread_id: The identifier of the thread to get.

    Returns:
        The requested Thread.
    """
    return super().find(
        path=f"/v3/grants/{identifier}/threads/{thread_id}",
        response_type=Thread,
    )

list(identifier, query_params=None)

Return all Threads.

Parameters:

Name Type Description Default
identifier str

The identifier of the grant to get threads for.

required
query_params ListThreadsQueryParams

The query parameters to filter threads by.

None

Returns:

Type Description
ListResponse[Thread]

A list of Threads.

Source code in nylas/resources/threads.py
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
def list(
    self, identifier: str, query_params: ListThreadsQueryParams = None
) -> ListResponse[Thread]:
    """
    Return all Threads.

    Args:
        identifier: The identifier of the grant to get threads for.
        query_params: The query parameters to filter threads by.

    Returns:
        A list of Threads.
    """
    return super().list(
        path=f"/v3/grants/{identifier}/threads",
        response_type=Thread,
        query_params=query_params,
    )

update(identifier, thread_id, request_body)

Update a Thread.

Parameters:

Name Type Description Default
identifier str

The identifier of the grant to update the thread for.

required
thread_id str

The identifier of the thread to update.

required
request_body UpdateThreadRequest

The request body to update the thread with.

required

Returns:

Type Description
Response[Thread]

The updated Thread.

Source code in nylas/resources/threads.py
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
def update(
    self,
    identifier: str,
    thread_id: str,
    request_body: UpdateThreadRequest,
) -> Response[Thread]:
    """
    Update a Thread.

    Args:
        identifier: The identifier of the grant to update the thread for.
        thread_id: The identifier of the thread to update.
        request_body: The request body to update the thread with.

    Returns:
        The updated Thread.
    """
    return super().update(
        path=f"/v3/grants/{identifier}/threads/{thread_id}",
        response_type=Thread,
        request_body=request_body,
    )