Skip to content

Teams, users and feedback

Teams (V2, beta; Affinity API 2026-09-17+): the teams the caller may see.

Source code in affinity/services/org.py
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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
class TeamService:
    """Teams (V2, beta; Affinity API 2026-09-17+): the teams the caller may see."""

    def __init__(self, client: HTTPClient):
        self._client = client

    def list(
        self,
        *,
        ids: Sequence[int] | None = None,
        name: str | None = None,
        name_contains: str | None = None,
        order_by: str | None = None,
        includes: bool | Sequence[str] | None = None,
        limit: int | None = None,
        total_count: bool = False,
        cursor: str | None = None,
    ) -> PaginatedResponse[Team]:
        """One page of teams, by name unless ``order_by`` says otherwise.

        ``name`` matches exactly, ``name_contains`` anywhere (case-insensitive).
        ``order_by``: ``name``, ``-name``, ``createdAt`` or ``-createdAt``. ``includes=True``
        (or ``["membersPreview"]`` / ``["accessibleListsPreview"]``) fills the first members
        and accessible lists, with totals. ``limit`` is 1-100.
        """
        ids = materialize_ids(ids)
        check_cursor_alone(cursor, ids, name, name_contains, order_by, includes, limit, total_count)
        if cursor is not None:
            return page_of(
                Team, self._client.get_url(cursor, min_api_version=TEAMS_MIN_API_VERSION)
            )
        params = team_params(
            ids=ids,
            name=name,
            name_contains=name_contains,
            order_by=order_by,
            includes=includes,
            limit=limit,
            total_count=total_count,
        )
        if no_ids(ids):
            return empty_page(Team, total_count=total_count)
        return page_of(
            Team,
            self._client.get(
                "/teams", params=params or None, min_api_version=TEAMS_MIN_API_VERSION
            ),
        )

    def iter(
        self,
        *,
        ids: Sequence[int] | None = None,
        name: str | None = None,
        name_contains: str | None = None,
        order_by: str | None = None,
        includes: bool | Sequence[str] | None = None,
        limit: int | None = None,
    ) -> Iterator[Team]:
        """All teams matching the filters (every page); see :meth:`list`."""

        def fetch_page(next_url: str | None) -> PaginatedResponse[Team]:
            if next_url:
                return self.list(cursor=next_url)
            return self.list(
                ids=ids,
                name=name,
                name_contains=name_contains,
                order_by=order_by,
                includes=includes,
                limit=limit,
            )

        return PageIterator(fetch_page)

    def get(self, team_id: int, *, includes: bool | Sequence[str] | None = None) -> Team:
        """One team (``includes`` as in :meth:`list`)."""
        params = [("includes", v) for v in team_includes(includes)]
        return Team.model_validate(
            self._client.get(
                f"/teams/{int(team_id)}",
                params=params or None,
                min_api_version=TEAMS_MIN_API_VERSION,
            )
        )

    def _team_page(
        self,
        model: type[T],
        path: str,
        *,
        limit: int | None,
        total_count: bool,
        cursor: str | None,
    ) -> PaginatedResponse[T]:
        check_cursor_alone(cursor, limit, total_count)
        if cursor is not None:
            return page_of(
                model, self._client.get_url(cursor, min_api_version=TEAMS_MIN_API_VERSION)
            )
        return page_of(
            model,
            self._client.get(
                path,
                params=team_page_params(limit, total_count) or None,
                min_api_version=TEAMS_MIN_API_VERSION,
            ),
        )

    def list_members(
        self,
        team_id: int,
        *,
        limit: int | None = None,
        total_count: bool = False,
        cursor: str | None = None,
    ) -> PaginatedResponse[TeamMember]:
        """One page of a team's members (V2, beta; API 2026-09-17+): every member, where
        ``get(includes=True)`` gives only the first ones. ``limit`` is 1-100."""
        return self._team_page(
            TeamMember,
            f"/teams/{int(team_id)}/members",
            limit=limit,
            total_count=total_count,
            cursor=cursor,
        )

    def iter_members(self, team_id: int) -> Iterator[TeamMember]:
        """Every member of a team (all pages); see :meth:`list_members`."""
        return PageIterator(
            lambda c: (
                self.list_members(team_id, cursor=c) if c else self.list_members(team_id, limit=100)
            )
        )

    def list_accessible_lists(
        self,
        team_id: int,
        *,
        limit: int | None = None,
        total_count: bool = False,
        cursor: str | None = None,
    ) -> PaginatedResponse[ListSummary]:
        """One page of the lists a team has access to (V2, beta; API 2026-09-17+). ``limit`` is
        1-100."""
        return self._team_page(
            ListSummary,
            f"/teams/{int(team_id)}/accessible-lists",
            limit=limit,
            total_count=total_count,
            cursor=cursor,
        )

    def iter_accessible_lists(self, team_id: int) -> Iterator[ListSummary]:
        """Every list a team has access to (all pages); see :meth:`list_accessible_lists`."""
        return PageIterator(
            lambda c: (
                self.list_accessible_lists(team_id, cursor=c)
                if c
                else self.list_accessible_lists(team_id, limit=100)
            )
        )

get(team_id: int, *, includes: bool | Sequence[str] | None = None) -> Team

One team (includes as in :meth:list).

Source code in affinity/services/org.py
213
214
215
216
217
218
219
220
221
222
def get(self, team_id: int, *, includes: bool | Sequence[str] | None = None) -> Team:
    """One team (``includes`` as in :meth:`list`)."""
    params = [("includes", v) for v in team_includes(includes)]
    return Team.model_validate(
        self._client.get(
            f"/teams/{int(team_id)}",
            params=params or None,
            min_api_version=TEAMS_MIN_API_VERSION,
        )
    )

iter(*, ids: Sequence[int] | None = None, name: str | None = None, name_contains: str | None = None, order_by: str | None = None, includes: bool | Sequence[str] | None = None, limit: int | None = None) -> Iterator[Team]

All teams matching the filters (every page); see :meth:list.

Source code in affinity/services/org.py
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
def iter(
    self,
    *,
    ids: Sequence[int] | None = None,
    name: str | None = None,
    name_contains: str | None = None,
    order_by: str | None = None,
    includes: bool | Sequence[str] | None = None,
    limit: int | None = None,
) -> Iterator[Team]:
    """All teams matching the filters (every page); see :meth:`list`."""

    def fetch_page(next_url: str | None) -> PaginatedResponse[Team]:
        if next_url:
            return self.list(cursor=next_url)
        return self.list(
            ids=ids,
            name=name,
            name_contains=name_contains,
            order_by=order_by,
            includes=includes,
            limit=limit,
        )

    return PageIterator(fetch_page)

iter_accessible_lists(team_id: int) -> Iterator[ListSummary]

Every list a team has access to (all pages); see :meth:list_accessible_lists.

Source code in affinity/services/org.py
291
292
293
294
295
296
297
298
299
def iter_accessible_lists(self, team_id: int) -> Iterator[ListSummary]:
    """Every list a team has access to (all pages); see :meth:`list_accessible_lists`."""
    return PageIterator(
        lambda c: (
            self.list_accessible_lists(team_id, cursor=c)
            if c
            else self.list_accessible_lists(team_id, limit=100)
        )
    )

iter_members(team_id: int) -> Iterator[TeamMember]

Every member of a team (all pages); see :meth:list_members.

Source code in affinity/services/org.py
265
266
267
268
269
270
271
def iter_members(self, team_id: int) -> Iterator[TeamMember]:
    """Every member of a team (all pages); see :meth:`list_members`."""
    return PageIterator(
        lambda c: (
            self.list_members(team_id, cursor=c) if c else self.list_members(team_id, limit=100)
        )
    )

list(*, ids: Sequence[int] | None = None, name: str | None = None, name_contains: str | None = None, order_by: str | None = None, includes: bool | Sequence[str] | None = None, limit: int | None = None, total_count: bool = False, cursor: str | None = None) -> PaginatedResponse[Team]

One page of teams, by name unless order_by says otherwise.

name matches exactly, name_contains anywhere (case-insensitive). order_by: name, -name, createdAt or -createdAt. includes=True (or ["membersPreview"] / ["accessibleListsPreview"]) fills the first members and accessible lists, with totals. limit is 1-100.

Source code in affinity/services/org.py
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
182
183
184
185
def list(
    self,
    *,
    ids: Sequence[int] | None = None,
    name: str | None = None,
    name_contains: str | None = None,
    order_by: str | None = None,
    includes: bool | Sequence[str] | None = None,
    limit: int | None = None,
    total_count: bool = False,
    cursor: str | None = None,
) -> PaginatedResponse[Team]:
    """One page of teams, by name unless ``order_by`` says otherwise.

    ``name`` matches exactly, ``name_contains`` anywhere (case-insensitive).
    ``order_by``: ``name``, ``-name``, ``createdAt`` or ``-createdAt``. ``includes=True``
    (or ``["membersPreview"]`` / ``["accessibleListsPreview"]``) fills the first members
    and accessible lists, with totals. ``limit`` is 1-100.
    """
    ids = materialize_ids(ids)
    check_cursor_alone(cursor, ids, name, name_contains, order_by, includes, limit, total_count)
    if cursor is not None:
        return page_of(
            Team, self._client.get_url(cursor, min_api_version=TEAMS_MIN_API_VERSION)
        )
    params = team_params(
        ids=ids,
        name=name,
        name_contains=name_contains,
        order_by=order_by,
        includes=includes,
        limit=limit,
        total_count=total_count,
    )
    if no_ids(ids):
        return empty_page(Team, total_count=total_count)
    return page_of(
        Team,
        self._client.get(
            "/teams", params=params or None, min_api_version=TEAMS_MIN_API_VERSION
        ),
    )

list_accessible_lists(team_id: int, *, limit: int | None = None, total_count: bool = False, cursor: str | None = None) -> PaginatedResponse[ListSummary]

One page of the lists a team has access to (V2, beta; API 2026-09-17+). limit is 1-100.

Source code in affinity/services/org.py
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
def list_accessible_lists(
    self,
    team_id: int,
    *,
    limit: int | None = None,
    total_count: bool = False,
    cursor: str | None = None,
) -> PaginatedResponse[ListSummary]:
    """One page of the lists a team has access to (V2, beta; API 2026-09-17+). ``limit`` is
    1-100."""
    return self._team_page(
        ListSummary,
        f"/teams/{int(team_id)}/accessible-lists",
        limit=limit,
        total_count=total_count,
        cursor=cursor,
    )

list_members(team_id: int, *, limit: int | None = None, total_count: bool = False, cursor: str | None = None) -> PaginatedResponse[TeamMember]

One page of a team's members (V2, beta; API 2026-09-17+): every member, where get(includes=True) gives only the first ones. limit is 1-100.

Source code in affinity/services/org.py
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
def list_members(
    self,
    team_id: int,
    *,
    limit: int | None = None,
    total_count: bool = False,
    cursor: str | None = None,
) -> PaginatedResponse[TeamMember]:
    """One page of a team's members (V2, beta; API 2026-09-17+): every member, where
    ``get(includes=True)`` gives only the first ones. ``limit`` is 1-100."""
    return self._team_page(
        TeamMember,
        f"/teams/{int(team_id)}/members",
        limit=limit,
        total_count=total_count,
        cursor=cursor,
    )

The organization's internal users (V2, beta).

Source code in affinity/services/org.py
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
class UserService:
    """The organization's internal users (V2, beta)."""

    def __init__(self, client: HTTPClient):
        self._client = client

    def list(
        self,
        *,
        term: str | None = None,
        ids: Sequence[UserId] | None = None,
        status: UserStatus | str | None = None,
        limit: int | None = None,
        cursor: str | None = None,
    ) -> PaginatedResponse[UserAccount]:
        """One page of users. ``term`` matches first name, last name or primary email;
        ``status`` is active, invited or deactivated. ``limit`` is 1-100."""
        ids = materialize_ids(ids)
        check_cursor_alone(cursor, term, ids, status, limit)
        if cursor is not None:
            return page_of(UserAccount, self._client.get_url(cursor))
        params = user_params(term=term, ids=ids, status=status, limit=limit)
        if no_ids(ids):
            return empty_page(UserAccount)
        return page_of(UserAccount, self._client.get("/users", params=params or None))

    def iter(
        self,
        *,
        term: str | None = None,
        ids: Sequence[UserId] | None = None,
        status: UserStatus | str | None = None,
        limit: int | None = None,
    ) -> Iterator[UserAccount]:
        """All users matching the filters (every page); see :meth:`list`."""

        def fetch_page(next_url: str | None) -> PaginatedResponse[UserAccount]:
            if next_url:
                return self.list(cursor=next_url)
            return self.list(term=term, ids=ids, status=status, limit=limit)

        return PageIterator(fetch_page)

    def get(self, user_id: UserId) -> UserAccount:
        """One user (the id is also the user's person id)."""
        return UserAccount.model_validate(self._client.get(f"/users/{int(user_id)}"))

get(user_id: UserId) -> UserAccount

One user (the id is also the user's person id).

Source code in affinity/services/org.py
507
508
509
def get(self, user_id: UserId) -> UserAccount:
    """One user (the id is also the user's person id)."""
    return UserAccount.model_validate(self._client.get(f"/users/{int(user_id)}"))

iter(*, term: str | None = None, ids: Sequence[UserId] | None = None, status: UserStatus | str | None = None, limit: int | None = None) -> Iterator[UserAccount]

All users matching the filters (every page); see :meth:list.

Source code in affinity/services/org.py
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
def iter(
    self,
    *,
    term: str | None = None,
    ids: Sequence[UserId] | None = None,
    status: UserStatus | str | None = None,
    limit: int | None = None,
) -> Iterator[UserAccount]:
    """All users matching the filters (every page); see :meth:`list`."""

    def fetch_page(next_url: str | None) -> PaginatedResponse[UserAccount]:
        if next_url:
            return self.list(cursor=next_url)
        return self.list(term=term, ids=ids, status=status, limit=limit)

    return PageIterator(fetch_page)

list(*, term: str | None = None, ids: Sequence[UserId] | None = None, status: UserStatus | str | None = None, limit: int | None = None, cursor: str | None = None) -> PaginatedResponse[UserAccount]

One page of users. term matches first name, last name or primary email; status is active, invited or deactivated. limit is 1-100.

Source code in affinity/services/org.py
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
def list(
    self,
    *,
    term: str | None = None,
    ids: Sequence[UserId] | None = None,
    status: UserStatus | str | None = None,
    limit: int | None = None,
    cursor: str | None = None,
) -> PaginatedResponse[UserAccount]:
    """One page of users. ``term`` matches first name, last name or primary email;
    ``status`` is active, invited or deactivated. ``limit`` is 1-100."""
    ids = materialize_ids(ids)
    check_cursor_alone(cursor, term, ids, status, limit)
    if cursor is not None:
        return page_of(UserAccount, self._client.get_url(cursor))
    params = user_params(term=term, ids=ids, status=status, limit=limit)
    if no_ids(ids):
        return empty_page(UserAccount)
    return page_of(UserAccount, self._client.get("/users", params=params or None))

Feedback to Affinity's product team about the API, the MCP server, or anything else.

Source code in affinity/services/org.py
562
563
564
565
566
567
568
569
570
571
class FeedbackService:
    """Feedback to Affinity's product team about the API, the MCP server, or anything else."""

    def __init__(self, client: HTTPClient):
        self._client = client

    def send(self, kind: FeedbackType, subject: str, body: str) -> None:
        """Send feedback to Affinity. ``kind`` is ``"api"``, ``"mcp"`` or ``"other"``; ``subject``
        up to 255 characters, ``body`` up to 10,000. It reaches Affinity's team: be specific."""
        self._client.post("/feedback", json=feedback_body(kind, subject, body))

send(kind: FeedbackType, subject: str, body: str) -> None

Send feedback to Affinity. kind is "api", "mcp" or "other"; subject up to 255 characters, body up to 10,000. It reaches Affinity's team: be specific.

Source code in affinity/services/org.py
568
569
570
571
def send(self, kind: FeedbackType, subject: str, body: str) -> None:
    """Send feedback to Affinity. ``kind`` is ``"api"``, ``"mcp"`` or ``"other"``; ``subject``
    up to 255 characters, ``body`` up to 10,000. It reaches Affinity's team: be specific."""
    self._client.post("/feedback", json=feedback_body(kind, subject, body))