scute.users manages the app's users with the secret key. Methods return the API's JSON as Python dicts and lists. Errors raise APIError; see Errors.
from scute import Scutescute = Scute()user = scute.users.create("ada@example.com", meta={"plan": "pro"})Create and invite#
scute.users.create(identifier: str, meta: dict | None = None)scute.users.invite(identifier: str, meta: dict | None = None)identifier is an email address or a phone number. create adds the user (POST /v1/auth/:app_id/users). invite adds the user and sends an invitation with a magic link (POST /v1/:app_id/users/invite).
meta keys must be user meta fields declared for the app in the dashboard. Undeclared keys are left out on create and listed in the response's user_meta_errors.
Creating a user is a server-started sign-in, so pass the person's IP address to have it checked against the workspace's IP rules:
scute.with_client_ip(request_ip).users.create("ada@example.com")See Client configuration.
Read#
scute.users.get(user_id: str)scute.users.list(**params)scute.users.find_by_identifier(identifier: str) -> dict | None- get returns one user (GET /v1/:app_id/users/:id).
- list passes keyword arguments as query parameters (GET /v1/:app_id/users). None values are dropped. The response has users and next_page.
- find_by_identifier returns the user whose email matches exactly (case-insensitive) or whose phone number has the same digits, or None. Include the country code in phone numbers. It never creates a user.
find_by_identifier searches with list(q=..., limit=100, page=n) and keeps only exact matches. It reads at most 10 pages (Users.FIND_MAX_PAGES), so it looks at the first 1,000 loose matches.
user = scute.users.find_by_identifier("+1 415 555 0100")if user is None: ...Update#
scute.users.update(user_id: str, **attributes)Keyword arguments become the JSON body of PATCH /v1/:app_id/users/:id.
scute.users.update(user_id, user_meta={"plan": "team"})Undeclared user_meta keys are refused on update.
Activate, deactivate, delete#
scute.users.activate(user_id: str)scute.users.deactivate(user_id: str)scute.users.delete(user_id: str)A user who was deactivated and then deleted cannot sign in again (403, account_deactivated) until you bring the account back.
Previous accounts#
A deleted user who signs in again gets a new account with a new id. The earlier account stays deleted, with its history.
scute.users.previous_accounts(user_id: str) -> list[dict]scute.users.merge(user_id: str, from_id: str) -> dictprevious_accounts lists the person's earlier, deleted accounts in this app, newest first. Each entry has id, status, created_at, deleted_at, merged_into (once merged) and what it still holds: role and passkey counts and the mfa_methods list.
merge moves roles, resource roles, passkeys, MFA methods and unused backup codes from from_id into the live account user_id. Meta and attributes are combined; the live account wins on conflicts. History stays on the old account. The response is:
{ "user_id": "user_id", "merged": "from_id", "moved": { "roles": 2, "resource_roles": 0, "passkeys": 1, "mfa_methods": 1, "backup_codes": 8 } }Each account merges once. Merging it again raises APIError with status 422 and code already_merged.
Support access#
Signing in as a user is off until the app turns it on. The session is short, is never refreshed, and its token names who is acting (Session.actor, see Verify tokens).
tokens = scute.users.impersonate( user_id, reason="Ticket 4411", actor={"email": "support@acme.com"}, minutes=15,)scute.users.impersonations(user_id) # list[dict]scute.users.stop_impersonating(user_id) # every support session of the userscute.users.stop_impersonating(user_id, session_id)Arguments left as None are not sent. The call is POST /v1/apps/:app_id/users/:id/impersonate, and it returns the API's answer with the session's tokens.