Skip to content

Auth & User Management

Cookie-based authentication and user lifecycle management. Auth routes use session cookies (withCredentials: true). No manual token storage required. With a publishable key, methods that read or change an account act on the signed-in user only; methods marked "secret key only" must run on your server.

SDK Setup

TypeScript
1import { NeuctraAuthix } from "@neuctra/authix";
2
3const authix = new NeuctraAuthix({
4  appName: "MyApp",
5  baseUrl: "https://server.authix.neuctra.com/api",
6  // Publishable key in browser code; a secret key (sk_live_…) only on a server
7  apiKey: "pk_live_xxxxxxxx_xxxxxxxxxxxxxxxx",
8  appId: "your_app_id_here",
9});

signupUser

POST /users/signup

ParamTypeRequiredDescription
namestringYesDisplay name
emailstringYesEmail address
passwordstringYesPassword
usernamestringNoUnique username
phonestring | nullNoPhone number
addressstring | nullNoAddress
avatarUrlstring | nullNoAvatar URL
isActivebooleanNoActive status
rolestringNoUser role
TypeScript
1await authix.signupUser({
2  name: "John Doe",
3  email: "[email protected]",
4  password: "securePassword123",
5});

Works with a publishable or secret key and sets the HTTP-only session cookie (withCredentials: true). Public signup always creates role 'user'.

loginUser

POST /users/login

ParamTypeRequiredDescription
emailstringYesEmail address
passwordstringYesPassword
TypeScript
1await authix.loginUser({
2  email: "[email protected]",
3  password: "securePassword123",
4});

Sets HTTP-only session cookie.

logoutUser

POST /users/logout

Returns: { success: boolean }

TypeScript
1await authix.logoutUser();

Clears session cookie and reloads page in browser environments.

checkUserSession

GET /users/session

Returns: CheckSessionResponse

TypeScript
1const session = await authix.checkUserSession();

Returns { authenticated: false } on server (SSR safe).

getUser

GET /users/:appId/user?id=... or ?username=...

ParamTypeRequiredDescription
idstringNoUser ID
usernamestringNoUsername
TypeScript
1await authix.getUser({ id: "user_id" });

Requires a secret key — server only. Looks up any user in the app by id or username; a publishable key gets 403 INSUFFICIENT_SCOPE.

getUserProfile

POST /users/profile

ParamTypeRequiredDescription
userIdstringYesUser ID
TypeScript
1await authix.getUserProfile({ userId: "id" });

With a publishable key the user comes from the session cookie and userId is ignored (401 NO_USER_SESSION if nobody is signed in). A secret key reads any user by id.

updateUser

PUT /users/update/:userId

ParamTypeRequiredDescription
userIdstringYesUser ID to update
appIdstringYesRequired to verify app ownership
namestringNoDisplay name
usernamestring | nullNoUnique username
emailstringNoEmail
passwordstringNoPassword
phonestring | nullNoPhone
addressstring | nullNoAddress
avatarUrlstring | nullNoAvatar URL
isActivebooleanNoActive status
rolestringNoRole
settingsunknownNoArbitrary app-defined settings
packageInfounknownNoArbitrary app-defined package info
notificationsunknownNoArbitrary app-defined notifications
extraInfounknownNoArbitrary app-defined extra info
TypeScript
1await authix.updateUser({
2  userId: "id",
3  appId: "your_app_id_here",
4  name: "Updated Name",
5});

With a publishable key this updates the signed-in user only (userId is ignored): password, isActive and packageInfo are refused — use changePassword for passwords — role is ignored, and changing email needs currentPassword. A secret key may update any user and set every field.

changePassword

PUT /users/change-password/:userId

ParamTypeRequiredDescription
userIdstringYesUser ID
currentPasswordstringYesCurrent password
newPasswordstringYesNew password
TypeScript
1await authix.changePassword({
2  userId: "id",
3  currentPassword: "old",
4  newPassword: "new",
5});

Requires the current password. With a publishable key it changes the signed-in user's password; a secret key may name any user. Changing a password ends the user's existing sessions.

requestEmailVerificationOTP

POST /users/send-verify-otp/:userId

ParamTypeRequiredDescription
userIdstringYesUser ID
emailstringYesEmail
TypeScript
1await authix.requestEmailVerificationOTP({
2  userId: "id",
3  email: "[email protected]",
4});

OTP verification flow. Five wrong guesses discard the code; request a new one.

verifyEmail

POST /users/verify-email

ParamTypeRequiredDescription
emailstringYesEmail
otpstringYesOTP
TypeScript
1await authix.verifyEmail({
2  email: "[email protected]",
3  otp: "123456",
4});

Email verification endpoint.

requestResetUserPasswordOTP

POST /users/forgot-password

ParamTypeRequiredDescription
emailstringYesEmail
TypeScript
1await authix.requestResetUserPasswordOTP({
2  email: "[email protected]",
3});

No session required; works with a publishable key. Always returns 200 with 'If an account exists…', whether or not the email is registered.

resetUserPassword

POST /users/reset-password

ParamTypeRequiredDescription
emailstringYesEmail
otpstringYesOTP
newPasswordstringYesNew password
TypeScript
1await authix.resetUserPassword({
2  email: "[email protected]",
3  otp: "123456",
4  newPassword: "newPassword",
5});

Public password reset flow. Five wrong guesses discard the code. Resetting a password ends the user's existing sessions.

checkIfUserExists

GET /users/check-user/:userId

ParamTypeRequiredDescription
userIdstringYesUser ID

Returns: CheckUserResponse

TypeScript
1await authix.checkIfUserExists("user_id");

Requires a secret key — server only. A publishable key gets 403 INSUFFICIENT_SCOPE.

deleteUser

DELETE /users/delete/:userId

ParamTypeRequiredDescription
userIdstringYesUser ID
TypeScript
1await authix.deleteUser({ userId: "id" });

With a publishable key this deletes the signed-in user only (userId is ignored). A secret key may delete any user.

Security Model

Neuctra Authix uses secure HTTP-only cookies for authentication. Sessions are handled via withCredentials: true. The SDK auto-injects appId into requests.

Related docs