Skip to main content

Resend Verification Code

curl -X POST https://api.sociapp.com/auth/resend-code \
  -H "Content-Type: application/json" \
  -d '{
    "email": "[email protected]"
  }'
{
  "message": "Verification code sent to email"
}

Endpoint

POST /auth/resend-code

Request Body

email
string
required
Email address of the user who needs a new verification code

Use Cases

This endpoint is useful when:
  • Original verification code expired (after 10 minutes)
  • User didn’t receive the verification email
  • User accidentally deleted the verification email
  • User needs to re-verify their email address

Behavior

When this endpoint is called:
  1. Validates that user exists
  2. Checks that user is not already verified
  3. Generates new 6-digit verification code
  4. Updates verification code and expiration in database
  5. Sends new code via email
  6. Returns success message

Code Generation

  • Format: 6-digit random numeric code
  • Expiration: 10 minutes from generation
  • Previous Code: Old code is invalidated and replaced

Rate Limiting

This endpoint has standard rate limiting (60 requests per minute) to prevent abuse. Wait before requesting multiple codes.

Email Delivery

The verification email includes:
  • 6-digit code prominently displayed
  • Expiration time (10 minutes)
  • Link back to verification page
  • Sender: SociApp ([email protected])

Example Integration

async function resendVerificationCode(email) {
  try {
    const response = await fetch('/auth/resend-code', {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({ email })
    });
    
    if (response.ok) {
      alert('New verification code sent! Check your email.');
    } else {
      const error = await response.json();
      alert(error.message);
    }
  } catch (error) {
    console.error('Failed to resend code:', error);
  }
}

Build docs developers (and LLMs) love