Overview
The Inmobiliaria API supports traditional email and password authentication with automatic email verification and password reset functionality. All authentication flows are handled by Better Auth.Sign Up Flow
1. Register New User
Create a new user account with email and password:POST /api/auth/sign-up/email
Request Body
User’s email address (must be unique)
User’s password (minimum 8 characters recommended)
User’s full name
Response
After successful registration, a session is automatically created and a verification email is sent to the user’s email address.
2. Email Verification
After registration, users receive a verification email with a link:Verification Email Configuration
The system uses Resend to send verification emails:Verify Email Endpoint
GET /api/auth/verify-email
The verification token from the email
URL to redirect to after verification (defaults to FRONTEND_URL)
Response
Successful verification redirects to the callback URL. The user’semailVerified field is set to true.
Sign In Flow
Authenticate an existing user with email and password:POST /api/auth/sign-in/email
The
-c cookies.txt flag saves the session cookie for subsequent requests.Request Body
User’s email address
User’s password
Extend session duration (optional)
Response
Session Cookie
Successful sign-in sets an HTTP-only cookie:Password Reset Flow
1. Request Password Reset
Send a password reset email:POST /api/auth/forget-password
Request Body
Email address of the account to reset
URL to redirect to after clicking the reset link
Response
For security reasons, the API always returns success even if the email doesn’t exist.
Password Reset Email Configuration
2. Reset Password
Submit a new password with the reset token:POST /api/auth/reset-password
Request Body
Password reset token from the email
New password for the account
Response
Sign Out
Invalidate the current session:POST /api/auth/sign-out
Response
Client Implementation Example
Security Best Practices
Password Requirements
Password Requirements
While the API doesn’t enforce strict password requirements, we recommend:
- Minimum 8 characters
- Mix of uppercase and lowercase letters
- At least one number
- At least one special character
Rate Limiting
Rate Limiting
Implement rate limiting on your frontend to prevent:
- Brute force attacks on sign-in
- Spam account creation
- Password reset abuse
express-rate-limit on the backend.HTTPS Only
HTTPS Only
Always use HTTPS in production to protect:
- User credentials during transmission
- Session cookies from interception
- API tokens and sensitive data
Email Verification
Email Verification
Enforce email verification before allowing full access:
Troubleshooting
Cookies Not Being Set
Cookies Not Being Set
Email Not Sending
Email Not Sending
Check:
RESEND_API_KEYis set correctlyEMAIL_FROMdomain is verified in Resend- Email templates are properly imported
- Check server logs for Resend API errors
Token Expired
Token Expired
Verification and reset tokens expire after 1 hour. Users must:
- Click the email link within 1 hour
- Request a new verification/reset email if expired
Next Steps
Session Management
Learn how to manage and validate sessions
OAuth Authentication
Add Google sign-in to your application
Protected Routes
Implement authentication middleware
User Profile
Access and update user information