Auth & User Management

Cookie-based authentication and user lifecycle management. Auth routes use session cookies (withCredentials: true). No manual token storage required.

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  publishableKey: "pk_live_xxxxxxxx_xxxxxxxxxxxxxxxx",
7  appId: "your_app_id_here",
8});

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});

Requires session cookie (withCredentials: true).

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 appId. Uses session cookie.

getUserProfile

POST /users/profile

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

Accepts { userId }, not JWT.

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});

Uses session cookie. 'appId' is required to verify app ownership.

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});

User or admin password change.

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.

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});

Public endpoint (no session required).

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.

checkIfUserExists

GET /users/check-user/:userId

ParamTypeRequiredDescription
userIdstringYesUser ID

Returns: CheckUserResponse

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

API key only check.

deleteUser

DELETE /users/delete/:userId

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

Uses session cookie.

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