Skip to main content

Verify Email Address

curl -X POST https://api.sociapp.com/auth/verify-email \
  -H "Content-Type: application/json" \
  -d '{
    "email": "[email protected]",
    "code": "123456"
  }'
{
  "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}

Endpoint

POST /auth/verify-email

Request Body

email
string
required
User’s email address to verify
code
string
required
6-digit verification code sent to email (must match exactly)

Response

Upon successful verification, the user is automatically logged in and receives authentication tokens.
access_token
string
JWT access token valid for 15 minutes. Use this token in the Authorization header for authenticated requests.
The refresh token is automatically set as an HTTP-only cookie and is not returned in the response body.

Verification Code Details

  • Format: 6-digit numeric code
  • Expiration: Codes expire after 10 minutes
  • Generation: Automatically sent upon registration
  • Resend: Use /auth/resend-code endpoint to request a new code

Auto-Login on Verification

When email verification succeeds:
  1. User account is marked as verified (isVerified = true)
  2. Verification code is cleared from database
  3. JWT tokens are generated (access + refresh)
  4. Refresh token stored in HTTP-only cookie
  5. Access token returned in response

Security Features

  • Rate Limiting: Standard rate limits apply (60 requests per minute)
  • Code Expiration: Prevents use of old verification codes
  • Single Use: Verification codes cannot be reused
  • Secure Cookies: Refresh token stored in HTTP-only, secure cookie

Common Error Scenarios

ErrorCauseSolution
Invalid codeWrong code or expiredRequest new code via /auth/resend-code
User not foundEmail doesn’t existCheck email spelling or register
Code expiredMore than 10 minutes passedRequest new code

Example Workflow

1

User registers

User submits registration form, receives verification email
2

Check email

User receives email with 6-digit code (valid for 10 minutes)
3

Submit verification

User enters code in verification form, app calls this endpoint
4

Auto-login

Upon success, user is logged in and redirected to dashboard

Build docs developers (and LLMs) love