Authentication
User authentication endpoints
Register#
Create a new user account.
emailstringrequired
User's email address
passwordstringrequired
Password (minimum 8 characters)
namestringrequired
User's display name
curl -X POST http://localhost:3000/api/v2/auth/register \
-H "Content-Type: application/json" \
-d '{
"email": "user@example.com",
"password": "securepassword123",
"name": "John Doe"
}'
Response#
{
"user": {
"id": "user-uuid",
"email": "user@example.com",
"name": "John Doe"
},
"accessToken": "eyJhbGciOiJIUzI1NiIs...",
"refreshToken": "eyJhbGciOiJIUzI1NiIs..."
}
Login#
Authenticate and receive tokens.
emailstringrequired
User's email address
passwordstringrequired
User's password
curl -X POST http://localhost:3000/api/v2/auth/login \
-H "Content-Type: application/json" \
-d '{
"email": "user@example.com",
"password": "securepassword123"
}'
Response#
{
"user": {
"id": "user-uuid",
"email": "user@example.com",
"name": "John Doe"
},
"accessToken": "eyJhbGciOiJIUzI1NiIs...",
"refreshToken": "eyJhbGciOiJIUzI1NiIs..."
}
Refresh Token#
Get a new access token using a refresh token.
refreshTokenstringrequired
Valid refresh token
curl -X POST http://localhost:3000/api/v2/auth/refresh \
-H "Content-Type: application/json" \
-d '{
"refreshToken": "eyJhbGciOiJIUzI1NiIs..."
}'
Response#
{
"accessToken": "eyJhbGciOiJIUzI1NiIs...",
"refreshToken": "eyJhbGciOiJIUzI1NiIs..."
}
Logout#
Invalidate the current session.
curl -X POST http://localhost:3000/api/v2/auth/logout \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
Response#
{
"message": "Logged out successfully"
}
Get Current User#
Get the authenticated user's profile.
curl http://localhost:3000/api/v2/auth/me \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
Response#
{
"user": {
"id": "user-uuid",
"email": "user@example.com",
"name": "John Doe",
"organizationId": "org-uuid",
"role": "owner",
"createdAt": "2024-01-28T12:00:00.000Z"
}
}
Token Expiry#
| Token Type | Expiry |
|---|---|
| Access Token | 15 minutes |
| Refresh Token | 7 days |
Access tokens expire quickly for security. Use refresh tokens to get new access tokens without re-authenticating.
Error Responses#
| Error | Status | Description |
|---|---|---|
INVALID_CREDENTIALS | 401 | Wrong email or password |
EMAIL_EXISTS | 409 | Email already registered |
TOKEN_EXPIRED | 401 | Token has expired |
INVALID_TOKEN | 401 | Token is malformed or invalid |