Skip to content

workspaces

Workspaces

Bases: ListableApiResource, FindableApiResource, CreatableApiResource, UpdatablePatchApiResource, DestroyableApiResource

Nylas Workspaces API

The Nylas Workspaces API allows you to group grants in a Nylas application by email domain. Grants can be auto-grouped by matching email domain or manually assigned and removed.

Source code in nylas/resources/workspaces.py
 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
 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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
class Workspaces(
    ListableApiResource,
    FindableApiResource,
    CreatableApiResource,
    UpdatablePatchApiResource,
    DestroyableApiResource,
):
    """
    Nylas Workspaces API

    The Nylas Workspaces API allows you to group grants in a Nylas application by email
    domain. Grants can be auto-grouped by matching email domain or manually assigned and
    removed.
    """

    def list(self, overrides: RequestOverrides = None) -> ListResponse[Workspace]:
        """
        Return all workspaces for the application.

        Args:
            overrides: The request overrides to apply to the request.

        Returns:
            The list of workspaces.
        """
        return super().list(
            path="/v3/workspaces", response_type=Workspace, overrides=overrides
        )

    def find(
        self, workspace_id: str, overrides: RequestOverrides = None
    ) -> Response[Workspace]:
        """
        Return a workspace.

        Args:
            workspace_id: The ID of the workspace to retrieve. Accepts a UUID or a domain.
            overrides: The request overrides to apply to the request.

        Returns:
            The workspace.
        """
        return super().find(
            path=f"/v3/workspaces/{workspace_id}",
            response_type=Workspace,
            overrides=overrides,
        )

    def create(
        self, request_body: CreateWorkspaceRequest, overrides: RequestOverrides = None
    ) -> Response[Workspace]:
        """
        Create a workspace.

        Args:
            request_body: The values to create the workspace with.
            overrides: The request overrides to apply to the request.

        Returns:
            The created workspace.
        """
        return super().create(
            path="/v3/workspaces",
            request_body=request_body,
            response_type=Workspace,
            overrides=overrides,
        )

    def update(
        self,
        workspace_id: str,
        request_body: UpdateWorkspaceRequest,
        overrides: RequestOverrides = None,
    ) -> Response[Workspace]:
        """
        Update a workspace.

        The Workspaces API only supports updating via PATCH; the workspace must be
        addressed by its UUID (a domain path value is not accepted on update).

        Args:
            workspace_id: The UUID of the workspace to update.
            request_body: The values to update the workspace with.
            overrides: The request overrides to apply to the request.

        Returns:
            The updated workspace.
        """
        return super().patch(
            path=f"/v3/workspaces/{workspace_id}",
            request_body=request_body,
            response_type=Workspace,
            overrides=overrides,
        )

    def destroy(
        self, workspace_id: str, overrides: RequestOverrides = None
    ) -> DeleteResponse:
        """
        Delete a workspace.

        Args:
            workspace_id: The ID of the workspace to delete. Accepts a UUID or a domain.
            overrides: The request overrides to apply to the request.

        Returns:
            The deletion response (request ID only).
        """
        return super().destroy(
            path=f"/v3/workspaces/{workspace_id}", overrides=overrides
        )

    def auto_group(
        self,
        request_body: WorkspaceAutoGroupRequest = None,
        overrides: RequestOverrides = None,
    ) -> Response[WorkspaceAutoGroupResponse]:
        """
        Start a background job that auto-groups grants into workspaces by email domain.

        This endpoint is rate-limited to one call per minute per application.

        Args:
            request_body: Optional filters to scope which grants are grouped.
            overrides: The request overrides to apply to the request.

        Returns:
            The started auto-group job.
        """
        res, headers = self._http_client._execute(
            method="POST",
            path="/v3/workspaces/auto-group",
            request_body=request_body,
            overrides=overrides,
        )
        return Response.from_dict(res, WorkspaceAutoGroupResponse, headers)

    def manual_assign(
        self,
        workspace_id: str,
        request_body: WorkspaceManualAssignRequest,
        overrides: RequestOverrides = None,
    ) -> Response[WorkspaceManualAssignResponse]:
        """
        Manually assign grants to or remove grants from a workspace.

        Args:
            workspace_id: The ID of the workspace. Accepts a UUID or a domain.
            request_body: The grants to assign and/or remove.
            overrides: The request overrides to apply to the request.

        Returns:
            The grants that were assigned and removed.
        """
        res, headers = self._http_client._execute(
            method="POST",
            path=f"/v3/workspaces/{workspace_id}/manual-assign",
            request_body=request_body,
            overrides=overrides,
        )
        return Response.from_dict(res, WorkspaceManualAssignResponse, headers)

auto_group(request_body=None, overrides=None)

Start a background job that auto-groups grants into workspaces by email domain.

This endpoint is rate-limited to one call per minute per application.

Parameters:

Name Type Description Default
request_body WorkspaceAutoGroupRequest

Optional filters to scope which grants are grouped.

None
overrides RequestOverrides

The request overrides to apply to the request.

None

Returns:

Type Description
Response[WorkspaceAutoGroupResponse]

The started auto-group job.

Source code in nylas/resources/workspaces.py
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
def auto_group(
    self,
    request_body: WorkspaceAutoGroupRequest = None,
    overrides: RequestOverrides = None,
) -> Response[WorkspaceAutoGroupResponse]:
    """
    Start a background job that auto-groups grants into workspaces by email domain.

    This endpoint is rate-limited to one call per minute per application.

    Args:
        request_body: Optional filters to scope which grants are grouped.
        overrides: The request overrides to apply to the request.

    Returns:
        The started auto-group job.
    """
    res, headers = self._http_client._execute(
        method="POST",
        path="/v3/workspaces/auto-group",
        request_body=request_body,
        overrides=overrides,
    )
    return Response.from_dict(res, WorkspaceAutoGroupResponse, headers)

create(request_body, overrides=None)

Create a workspace.

Parameters:

Name Type Description Default
request_body CreateWorkspaceRequest

The values to create the workspace with.

required
overrides RequestOverrides

The request overrides to apply to the request.

None

Returns:

Type Description
Response[Workspace]

The created workspace.

Source code in nylas/resources/workspaces.py
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
def create(
    self, request_body: CreateWorkspaceRequest, overrides: RequestOverrides = None
) -> Response[Workspace]:
    """
    Create a workspace.

    Args:
        request_body: The values to create the workspace with.
        overrides: The request overrides to apply to the request.

    Returns:
        The created workspace.
    """
    return super().create(
        path="/v3/workspaces",
        request_body=request_body,
        response_type=Workspace,
        overrides=overrides,
    )

destroy(workspace_id, overrides=None)

Delete a workspace.

Parameters:

Name Type Description Default
workspace_id str

The ID of the workspace to delete. Accepts a UUID or a domain.

required
overrides RequestOverrides

The request overrides to apply to the request.

None

Returns:

Type Description
DeleteResponse

The deletion response (request ID only).

Source code in nylas/resources/workspaces.py
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
def destroy(
    self, workspace_id: str, overrides: RequestOverrides = None
) -> DeleteResponse:
    """
    Delete a workspace.

    Args:
        workspace_id: The ID of the workspace to delete. Accepts a UUID or a domain.
        overrides: The request overrides to apply to the request.

    Returns:
        The deletion response (request ID only).
    """
    return super().destroy(
        path=f"/v3/workspaces/{workspace_id}", overrides=overrides
    )

find(workspace_id, overrides=None)

Return a workspace.

Parameters:

Name Type Description Default
workspace_id str

The ID of the workspace to retrieve. Accepts a UUID or a domain.

required
overrides RequestOverrides

The request overrides to apply to the request.

None

Returns:

Type Description
Response[Workspace]

The workspace.

Source code in nylas/resources/workspaces.py
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
def find(
    self, workspace_id: str, overrides: RequestOverrides = None
) -> Response[Workspace]:
    """
    Return a workspace.

    Args:
        workspace_id: The ID of the workspace to retrieve. Accepts a UUID or a domain.
        overrides: The request overrides to apply to the request.

    Returns:
        The workspace.
    """
    return super().find(
        path=f"/v3/workspaces/{workspace_id}",
        response_type=Workspace,
        overrides=overrides,
    )

list(overrides=None)

Return all workspaces for the application.

Parameters:

Name Type Description Default
overrides RequestOverrides

The request overrides to apply to the request.

None

Returns:

Type Description
ListResponse[Workspace]

The list of workspaces.

Source code in nylas/resources/workspaces.py
36
37
38
39
40
41
42
43
44
45
46
47
48
def list(self, overrides: RequestOverrides = None) -> ListResponse[Workspace]:
    """
    Return all workspaces for the application.

    Args:
        overrides: The request overrides to apply to the request.

    Returns:
        The list of workspaces.
    """
    return super().list(
        path="/v3/workspaces", response_type=Workspace, overrides=overrides
    )

manual_assign(workspace_id, request_body, overrides=None)

Manually assign grants to or remove grants from a workspace.

Parameters:

Name Type Description Default
workspace_id str

The ID of the workspace. Accepts a UUID or a domain.

required
request_body WorkspaceManualAssignRequest

The grants to assign and/or remove.

required
overrides RequestOverrides

The request overrides to apply to the request.

None

Returns:

Type Description
Response[WorkspaceManualAssignResponse]

The grants that were assigned and removed.

Source code in nylas/resources/workspaces.py
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
def manual_assign(
    self,
    workspace_id: str,
    request_body: WorkspaceManualAssignRequest,
    overrides: RequestOverrides = None,
) -> Response[WorkspaceManualAssignResponse]:
    """
    Manually assign grants to or remove grants from a workspace.

    Args:
        workspace_id: The ID of the workspace. Accepts a UUID or a domain.
        request_body: The grants to assign and/or remove.
        overrides: The request overrides to apply to the request.

    Returns:
        The grants that were assigned and removed.
    """
    res, headers = self._http_client._execute(
        method="POST",
        path=f"/v3/workspaces/{workspace_id}/manual-assign",
        request_body=request_body,
        overrides=overrides,
    )
    return Response.from_dict(res, WorkspaceManualAssignResponse, headers)

update(workspace_id, request_body, overrides=None)

Update a workspace.

The Workspaces API only supports updating via PATCH; the workspace must be addressed by its UUID (a domain path value is not accepted on update).

Parameters:

Name Type Description Default
workspace_id str

The UUID of the workspace to update.

required
request_body UpdateWorkspaceRequest

The values to update the workspace with.

required
overrides RequestOverrides

The request overrides to apply to the request.

None

Returns:

Type Description
Response[Workspace]

The updated workspace.

Source code in nylas/resources/workspaces.py
 89
 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
def update(
    self,
    workspace_id: str,
    request_body: UpdateWorkspaceRequest,
    overrides: RequestOverrides = None,
) -> Response[Workspace]:
    """
    Update a workspace.

    The Workspaces API only supports updating via PATCH; the workspace must be
    addressed by its UUID (a domain path value is not accepted on update).

    Args:
        workspace_id: The UUID of the workspace to update.
        request_body: The values to update the workspace with.
        overrides: The request overrides to apply to the request.

    Returns:
        The updated workspace.
    """
    return super().patch(
        path=f"/v3/workspaces/{workspace_id}",
        request_body=request_body,
        response_type=Workspace,
        overrides=overrides,
    )