Skip to main content

Sign Up

Create a new user account with email and password.
POST /api/auth/sign-up/email

Request Body

email
string
required
User’s email address. Must be valid and unique.
password
string
required
User’s password. Should meet minimum security requirements.
name
string
User’s display name.

Request Example

curl -X POST "{NEXT_PUBLIC_APP_URL}/api/auth/sign-up/email" \
  -H "Content-Type: application/json" \
  -d '{
    "email": "[email protected]",
    "password": "securePassword123",
    "name": "John Doe"
  }'

Response

user
object
The created user object
user.id
string
Unique user identifier
user.email
string
User’s email address
user.name
string
User’s display name
user.email_verified
boolean
Email verification status (false on signup)
user.created_at
timestamp
Account creation timestamp
session
object
Created session object

Response Example

{
  "user": {
    "id": "usr_abc123",
    "email": "[email protected]",
    "name": "John Doe",
    "email_verified": false,
    "created_at": "2024-01-15T10:30:00Z",
    "updated_at": "2024-01-15T10:30:00Z"
  },
  "session": {
    "id": "ses_xyz789",
    "user_id": "usr_abc123",
    "expires_at": "2024-01-16T10:30:00Z"
  }
}
After signup, a verification email is automatically sent. Users must verify their email before creating organizations.

Sign In

Authenticate with email and password.
POST /api/auth/sign-in/email

Request Body

email
string
required
User’s email address
password
string
required
User’s password

Request Example

curl -X POST "{NEXT_PUBLIC_APP_URL}/api/auth/sign-in/email" \
  -H "Content-Type: application/json" \
  -d '{
    "email": "[email protected]",
    "password": "securePassword123"
  }'

Response

user
object
The authenticated user object
session
object
Created session object with active organization info
subscription
object
User’s current subscription status
subscription.isSubscribed
boolean
Whether user has an active subscription
subscription.productId
string
Active product ID (pro, teams, etc.)

Response Example

{
  "user": {
    "id": "usr_abc123",
    "email": "[email protected]",
    "name": "John Doe",
    "email_verified": true,
    "created_at": "2024-01-15T10:30:00Z"
  },
  "session": {
    "id": "ses_xyz789",
    "user_id": "usr_abc123",
    "active_organization_id": "org_456",
    "expires_at": "2024-01-16T10:30:00Z"
  },
  "subscription": {
    "isSubscribed": true,
    "productId": "prod_pro_monthly"
  }
}
If the user’s email is not verified, a verification email will be sent on sign-in.

Verify Email

Verify user’s email address using the token from the verification email.
GET /api/auth/verify-email

Query Parameters

token
string
required
Email verification token from the verification email link

Request Example

curl -X GET "{NEXT_PUBLIC_APP_URL}/api/auth/verify-email?token=verify_token_123"

Response

{
  "success": true,
  "message": "Email verified successfully"
}

Request Password Reset

Request a password reset email.
POST /api/auth/forget-password

Request Body

email
string
required
Email address of the account to reset
redirectTo
string
Optional redirect URL after password reset

Request Example

curl -X POST "{NEXT_PUBLIC_APP_URL}/api/auth/forget-password" \
  -H "Content-Type: application/json" \
  -d '{
    "email": "[email protected]",
    "redirectTo": "/dashboard"
  }'

Response

{
  "success": true,
  "message": "Password reset email sent"
}

Reset Password

Reset password using the token from the reset email.
POST /api/auth/reset-password

Request Body

token
string
required
Password reset token from the email
password
string
required
New password

Request Example

curl -X POST "{NEXT_PUBLIC_APP_URL}/api/auth/reset-password" \
  -H "Content-Type: application/json" \
  -d '{
    "token": "reset_token_123",
    "password": "newSecurePassword456"
  }'

Response

{
  "success": true,
  "message": "Password reset successfully"
}

Sign Out

End the current session.
POST /api/auth/sign-out

Request Example

curl -X POST "{NEXT_PUBLIC_APP_URL}/api/auth/sign-out" \
  -H "Cookie: session=session_token_here"

Response

{
  "success": true
}

Get Session

Retrieve current session information.
GET /api/auth/get-session

Request Example

curl -X GET "{NEXT_PUBLIC_APP_URL}/api/auth/get-session" \
  -H "Cookie: session=session_token_here"

Response

user
object
Current user information
session
object
Current session details
subscription
object
Current subscription status

Response Example

{
  "user": {
    "id": "usr_abc123",
    "email": "[email protected]",
    "name": "John Doe",
    "email_verified": true
  },
  "session": {
    "id": "ses_xyz789",
    "user_id": "usr_abc123",
    "active_organization_id": "org_456",
    "expires_at": "2024-01-16T10:30:00Z",
    "ip_address": "192.168.1.1",
    "user_agent": "Mozilla/5.0..."
  },
  "subscription": {
    "isSubscribed": true,
    "productId": "prod_teams_yearly"
  }
}

Generate JWT Token

Generate a JWT token for API access.
POST /api/auth/token

Request Example

curl -X POST "{NEXT_PUBLIC_APP_URL}/api/auth/token" \
  -H "Cookie: session=session_token_here"

Response

token
string
JWT token valid for 1 hour

Response Example

{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}
JWT tokens expire after 1 hour. Generate a new token before the expiration to maintain API access.

Error Responses

All authentication endpoints may return the following error responses:

400 Bad Request

{
  "error": "INVALID_EMAIL",
  "message": "Email address is invalid"
}

401 Unauthorized

{
  "error": "INVALID_CREDENTIALS",
  "message": "Email or password is incorrect"
}

409 Conflict

{
  "error": "USER_EXISTS",
  "message": "User with this email already exists"
}

429 Too Many Requests

{
  "error": "RATE_LIMIT_EXCEEDED",
  "message": "Too many requests, please try again later"
}

Build docs developers (and LLMs) love