Skip to content

Authentication Endpoints

These endpoints handle user registration, login, logout, and session refresh.

Create a new user account.

POST /auth/register
{
"email": "user@example.com",
"password": "secure_password_123",
"name": "John Doe"
}
FieldTypeRequiredDescription
emailstringYesValid email address
passwordstringYesMinimum 8 characters
namestringYesUser’s full name
{
"success": true,
"data": {
"userId": "user_123456",
"email": "user@example.com",
"name": "John Doe",
"createdAt": "2024-01-15T10:30:00.000Z"
}
}
StatusCodeDescription
400VALIDATION_ERRORInvalid email or password too short
409CONFLICTEmail already registered

Authenticate and receive access credentials.

POST /auth/login
{
"email": "user@example.com",
"password": "secure_password_123"
}
FieldTypeRequiredDescription
emailstringYesRegistered email address
passwordstringYesUser’s password
{
"success": true,
"data": {
"accessToken": "eyJhbGciOiJIUzI1NiIs...",
"refreshToken": "dGhpcyBpcyBhIHJlZnJlc2g...",
"expiresIn": 3600,
"user": {
"userId": "user_123456",
"email": "user@example.com",
"name": "John Doe"
}
}
}
StatusCodeDescription
401UNAUTHORIZEDInvalid email or password

Invalidate the current session.

POST /auth/logout
Authorization: Bearer {access_token}
{
"success": true,
"data": {
"message": "Logged out successfully"
}
}

Obtain a new access token using a refresh token.

POST /auth/refresh
{
"refreshToken": "dGhpcyBpcyBhIHJlZnJlc2g..."
}
{
"success": true,
"data": {
"accessToken": "eyJhbGciOiJIUzI1NiIs...",
"expiresIn": 3600
}
}
StatusCodeDescription
401UNAUTHORIZEDInvalid or expired refresh token
Terminal window
# Register
curl -X POST https://api.momail.io/v1/auth/register \
-H "Content-Type: application/json" \
-d '{
"email": "user@example.com",
"password": "secure_password_123",
"name": "John Doe"
}'
# Login
curl -X POST https://api.momail.io/v1/auth/login \
-H "Content-Type: application/json" \
-d '{
"email": "user@example.com",
"password": "secure_password_123"
}'