> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tktchurch.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Resend Verification Email

> Resend the email verification link to a user

<Note>
  This is a public endpoint that does not require authentication.
</Note>

### Request Body

<ParamField body="email" type="string" required={true}>
  The email address of the user who needs a new verification link. Must be a valid email format.
</ParamField>

### Response

A successful request returns HTTP 200 OK status. A new verification email will be sent to the provided email address if:

1. The user exists in the system
2. Their email is not already verified

### Error Responses

<ResponseField name="error" type="object">
  Error details when the request fails

  <Expandable title="Error Object">
    <ResponseField name="status" type="integer">
      HTTP status code
    </ResponseField>

    <ResponseField name="reason" type="string">
      Error message explaining why the request failed
    </ResponseField>
  </Expandable>
</ResponseField>

<Note>
  Common error cases:

  * 400 Bad Request: Invalid email format
  * 400 Bad Request: Email is already verified
  * 404 Not Found: User not found
</Note>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://api.tktchurch.com/v1/auth/resend-verification" \
    -H "Content-Type: application/json" \
    -d '{
      "email": "john.doe@example.com"
    }'
  ```

  ```javascript JavaScript theme={null}
  const resendVerification = async (email) => {
    const response = await fetch(
      'https://api.tktchurch.com/v1/auth/resend-verification',
      {
        method: 'POST',
        headers: {
          'Content-Type': 'application/json',
        },
        body: JSON.stringify({ email })
      }
    );

    if (!response.ok) {
      const error = await response.json();
      throw new Error(error.error.reason);
    }

    return response.status === 200;
  };

  // Usage
  try {
    await resendVerification('john.doe@example.com');
    console.log('Verification email sent successfully');
  } catch (error) {
    console.error('Failed to resend verification:', error.message);
  }
  ```

  ```swift Swift theme={null}
  struct ResendVerificationRequest: Encodable {
      let email: String
  }

  func resendVerification(email: String) async throws {
      let request = ResendVerificationRequest(email: email)
      
      var urlRequest = URLRequest(url: URL(string: "https://api.tktchurch.com/v1/auth/resend-verification")!)
      urlRequest.httpMethod = "POST"
      urlRequest.setValue("application/json", forHTTPHeaderField: "Content-Type")
      urlRequest.httpBody = try? JSONEncoder().encode(request)
      
      let (data, response) = try await URLSession.shared.data(for: urlRequest)
      guard let httpResponse = response as? HTTPURLResponse else {
          throw URLError(.badServerResponse)
      }
      
      if httpResponse.statusCode != 200 {
          let error = try JSONDecoder().decode(ErrorResponse.self, from: data)
          throw error
      }
  }

  // Usage
  do {
      try await resendVerification(email: "john.doe@example.com")
      print("Verification email sent successfully")
  } catch {
      print("Failed to resend verification: \(error.localizedDescription)")
  }
  ```

  ```kotlin Kotlin theme={null}
  data class ResendVerificationRequest(
      val email: String
  )

  class EmailVerificationService(private val client: OkHttpClient) {
      suspend fun resendVerification(email: String) {
          val request = ResendVerificationRequest(email)
          
          val requestBody = request.toJson()
              .toRequestBody("application/json".toMediaType())

          val httpRequest = Request.Builder()
              .url("https://api.tktchurch.com/v1/auth/resend-verification")
              .post(requestBody)
              .header("Content-Type", "application/json")
              .build()

          client.newCall(httpRequest).execute().use { response ->
              if (!response.isSuccessful) {
                  val error = response.body?.string()?.fromJson<ErrorResponse>()
                  throw Exception(error?.reason ?: "Failed to resend verification")
              }
          }
      }
  }

  // Usage
  try {
      emailVerificationService.resendVerification("john.doe@example.com")
      println("Verification email sent successfully")
  } catch (e: Exception) {
      println("Failed to resend verification: ${e.message}")
  }
  ```

  ```typescript React Native theme={null}
  import axios from 'axios';

  interface ResendVerificationRequest {
    email: string;
  }

  const resendVerification = async (email: string): Promise<boolean> => {
    try {
      const response = await axios.post(
        'https://api.tktchurch.com/v1/auth/resend-verification',
        { email },
        {
          headers: {
            'Content-Type': 'application/json',
          },
        }
      );
      
      return response.status === 200;
    } catch (error) {
      if (axios.isAxiosError(error)) {
        throw new Error(error.response?.data?.error?.reason || 'Failed to resend verification');
      }
      throw error;
    }
  };

  // Usage
  try {
    await resendVerification('john.doe@example.com');
    console.log('Verification email sent successfully');
  } catch (error) {
    console.error('Failed to resend verification:', error.message);
  }
  ```
</RequestExample>

<ResponseExample>
  ```json 200 Success theme={null}
  {
    "status": 200,
    "message": "Verification email sent successfully"
  }
  ```

  ```json 400 Invalid Email theme={null}
  {
    "error": {
      "status": 400,
      "reason": "Invalid email format"
    }
  }
  ```

  ```json 400 Already Verified theme={null}
  {
    "error": {
      "status": 400,
      "reason": "Email is already verified"
    }
  }
  ```

  ```json 404 User Not Found theme={null}
  {
    "error": {
      "status": 404,
      "reason": "User not found"
    }
  }
  ```
</ResponseExample>
