Repository navigation
feat: manage team API tokens - #47
Merged
Merged
Conversation
Add `team.api_tokens` with `list`, `iterate`, `create` and `delete` for the team's API tokens (team token), on the sync and async clients. A new token can only have abilities that the requesting token has, copies its IP allowlist and can't outlive it. `create` returns the token value once. The surface test now checks every operation again.
bjornftw
approved these changes
Oct 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
Adds
team.api_tokens, a sub-client for the team's API tokens, next toteam.membersandteam.invitesand in the same style (team token), on bothLettermintandAsyncLettermint:list(query=None, *, timeout=None)GET /team/api-tokens({"page": {"size", "cursor"}, "sort": [...]})ListTeamApiTokensResponse(CursorPage[TeamApiToken])iterate(query=None, *, timeout=None)next_cursorIterator[TeamApiToken](AsyncIteratoron the async client)create(body, *, timeout=None)POST /team/api-tokenswithStoreTeamApiTokenDataTeamApiTokenCreatedResponse(201)delete(token_id, *, timeout=None)DELETE /team/api-tokens/{tokenId}MessageResponsecreatetakes aname, theabilities(for exampleread:domains) and an optionalexpires_at(ISO 8601 orNone). The new token can only have abilities that the requesting token has. It copies the requesting token's IP allowlist, and it can't outlive the requesting token:expires_atdefaults to, and can't be later than, its expiry.createreturns the token value once, indata["token"]. The docstring and README say to store it right away; as with project tokens, the SDK does not redact response dicts.listanditeratereturn token metadata only.deletestops the token from working immediately; a token can only delete tokens whose abilities it also has.PermissionDeniedError, a 422 the existingValidationError. No new exception classes...token IDs are rejected before any request, as for the other methods.Idempotency-Key, so there is noidempotency_keyargument.TeamApiTokensandAsyncTeamApiTokensare exported, likeTeamInvites.team.api_tokensis in the Team API table, with a short section and example.Stacked on #46. Non-breaking. Suggested bump: minor.
Usage
Checks
On this branch:
python -m ruff check src tests scripts: passedpython -m ruff format --check src tests scripts: passedpython -m mypy: no issues in 36 source filespython scripts/unasync.py --check:_syncup to datepython scripts/generate.py --check: generated files up to date with the pinned spec, headers OKpython -m pytest tests/: 332 passed on Python 3.10, 3.11, 3.12, 3.13 and 3.14python -m buildandtwine check --strict dist/*: passed; the wheel installs in a fresh venv and imports (UPGRADE.mdandpy.typedincluded)Not run locally
Nothing; every CI step was run locally.
Suggested release tag
v3.3.0(minor), together with #46 once both are merged.