Skip to content

Auth & user management

Every method for creating an end user, signing them in, verifying their email, resetting their password, and reading or deleting their account. All arguments are keyword-only.

The session lives on the client

login_user() stores a cookie on the client's requests.Session, and every later call on that client acts as that user. In a script that is exactly what you want. In a web server it is a serious bug: one shared client would hand the first visitor's session to the next.

In a web application, either construct a short-lived client per request, or use a shared secret-key client that never signs anyone in and pass user_id explicitly — taken from a session your server has verified, never from the request.

signup_user

Session cookie

POST /api/users/signup

Python
authix.signup_user(
    *, name: str, email: str, password: str,
    username: str | None = None,
    phone: str | None = None,
    address: str | None = None,
) -> dict
ParamTypeRequiredDescription
namestrYesDisplay name.
emailstrYesUnique within this app. The same address can exist in another app.
passwordstrYesSent over HTTPS and stored as a bcrypt hash. Never stored in plaintext.
usernamestrNoOptional handle, usable with get_user().
phonestrNoOptional.
addressstrNoOptional.

Returns: dict — the created user

Python
1user = authix.signup_user(
2    name="Ada Lovelace",
3    email="[email protected]",
4    password="a-long-passphrase",
5)
6
7print(user["user"]["id"])
Signing up does not verify the email. Call request_email_verification_otp() next if your app requires a verified address.

login_user

Session cookie

POST /api/users/login

Python
authix.login_user(*, email: str, password: str) -> dict
ParamTypeRequiredDescription
emailstrYesThe user's email.
passwordstrYesTheir password.

Returns: dict — the signed-in user

Python
1result = authix.login_user(email="[email protected]", password="…")
2
3# The cookie is now on this client. Subsequent calls act as Ada.
4print(result["user"]["id"])

logout_user

Session cookie

POST /api/users/logout

Python
authix.logout_user() -> dict

Returns: dict

Python
1authix.logout_user()
2
3authix.check_user_session()
4# {"authenticated": False}
Clears the cookie both server-side and on the local session, so the client is genuinely signed out rather than merely appearing to be.

check_user_session

Session cookie

GET /api/users/session

Python
authix.check_user_session() -> dict

Returns: dict — {"authenticated": bool, "user": dict | None}

Python
1session = authix.check_user_session()
2
3if session["authenticated"]:
4    print(session["user"]["email"])
5else:
6    prompt_login()
Never raises for a missing or expired session — the server answers 200 with authenticated: False, because 'not signed in' is an answer rather than a failure. Safe to call on every request without a try/except.

change_password

Session cookie

PUT /api/users/change-password/:id

Python
authix.change_password(
    *, user_id: str, current_password: str, new_password: str,
) -> dict
ParamTypeRequiredDescription
user_idstrYesWhose password to change.
current_passwordstrYesVerified before the change is applied.
new_passwordstrYesThe replacement.

Returns: dict

Python
1authix.change_password(
2    user_id=user_id,
3    current_password=old,
4    new_password=new,
5)
6# Every session for this user is now invalid, including this one.
Bumps the user's token version, which invalidates every session they have anywhere. The device that made the change must sign in again too — that is the correct trade, because it is also what stops a stolen session surviving a password change.

request_email_verification_otp

Session cookie

POST /api/users/send-verify-otp/:id

Python
authix.request_email_verification_otp(*, user_id: str, email: str) -> dict
ParamTypeRequiredDescription
user_idstrYesThe user to verify.
emailstrYesWhere to send the code.

Returns: dict

Python
1authix.request_email_verification_otp(user_id=user_id, email=email)
The code is stored hashed and expires shortly after it is issued. Five wrong guesses discard it, and the user must request a new one.

verify_email

Session cookie

POST /api/users/verify-email

Python
authix.verify_email(*, email: str, otp: str) -> dict
ParamTypeRequiredDescription
emailstrYesThe address being confirmed.
otpstrYesThe code from the email.

Returns: dict

Python
1authix.verify_email(email=email, otp=code)

request_reset_user_password_otp

Session cookie

POST /api/users/forgot-password

Python
authix.request_reset_user_password_otp(*, email: str) -> dict
ParamTypeRequiredDescription
emailstrYesWhere to send the reset code.

Returns: dict

Python
1authix.request_reset_user_password_otp(email="[email protected]")
Always answers 200 with 'If an account exists…', whether or not the address is registered, so the response cannot be used to discover which emails exist. Show the same confirmation either way. Five wrong guesses at the emailed code discard it.

reset_user_password

Session cookie

POST /api/users/reset-password

Python
authix.reset_user_password(
    *, email: str, otp: str, new_password: str,
) -> dict
ParamTypeRequiredDescription
emailstrYesThe account being reset.
otpstrYesThe emailed code.
new_passwordstrYesThe new password.

Returns: dict

Python
1authix.reset_user_password(
2    email=email,
3    otp=code,
4    new_password=new_password,
5)
Also invalidates every existing session for that user — which is the point, since a reset usually means the account may have been compromised.

get_user_profile

Session cookie

POST /api/users/profile

Python
authix.get_user_profile(*, user_id: str) -> dict
ParamTypeRequiredDescription
user_idstrYesWhose profile to read.

Returns: dict

Python
1profile = authix.get_user_profile(user_id=user_id)
With a publishable key the server pins this to the signed-in user, so passing someone else's id returns the signed-in user's own record rather than the other person's — and with no live session it raises NoUserSessionError (401). A secret key reads whichever user_id you pass.

get_user

No session neededSecret key, server only

GET /api/users/:appId/user

Python
authix.get_user(
    *, id: str | None = None, username: str | None = None,
) -> dict
ParamTypeRequiredDescription
idstrNoLook up by id. Pass this or username.
usernamestrNoLook up by handle.

Returns: dict

Python
1user = authix.get_user(username="ada")
Requires a secret key — server only. It can read any user on the account.

update_user

Session cookie

PUT /api/users/update/:id

Python
authix.update_user(*, user_id: str, **fields) -> dict
ParamTypeRequiredDescription
user_idstrYesWho to update.
**fieldsAnyYesProfile fields to change: name, username, phone, address, avatar_url.

Returns: dict

Python
1authix.update_user(user_id=user_id, name="Ada L.", phone="+44…")
Profile fields only. Passwords go through change_password, and email changes go through the verification flow. With a publishable key the target is the signed-in user whatever user_id says, and role, isActive and packageInfo cannot be set — those need a secret key on your server.

delete_user

Session cookie

DELETE /api/users/delete/:userId

Python
authix.delete_user(*, user_id: str) -> dict
ParamTypeRequiredDescription
user_idstrYesWho to delete.

Returns: dict

Python
1authix.delete_user(user_id=user_id)
Deletes the user and every record they own, permanently. There is no recycle bin and no undo — export first if the data matters.

check_if_user_exists

No session neededSecret key, server only

GET /api/users/check-user/:id

Python
authix.check_if_user_exists(user_id: str) -> dict
ParamTypeRequiredDescription
user_idstrYesPositional, unlike the rest of the SDK.

Returns: dict

Python
1if authix.check_if_user_exists(user_id)["exists"]:
2    ...
The one method taking a positional argument. Requires a secret key — server only.

Do not build your own authorisation on these

A successful check_user_session() tells you who someone is. It does not tell you what they may do. Ownership is enforced by the API on every request, and your own rules — which screens, which records, which actions — belong in your code.

Related