Request a new email verification code for the authenticated user.

Endpoint


GET /auth/verification-code

Request

Headers

NameRequiredDescription
AuthorizationYesBearer token
Content-TypeYesapplication/json

Response

Success Response

Code: 200 OK

Content example:

{
  "message": "Verification code sent."
}
FieldTypeDescription
messagestringConfirmation that the verification code was sent

Error Response

Code: 401 UNAUTHORIZED

Content example:

{
  "statusCode": 401,
  "message": "Unauthorized",
  "error": "Unauthorized"
}

Notes

  • The user must be authenticated (JWT required).
  • A verification code is generated and sent to the user’s registered email.

Example Usage

JavaScript (Fetch API)

async function requestVerificationCode(token) {
  const response = await fetch("http://your-api-url/auth/verification-code", {
    method: "GET",
    headers: {
      "Content-Type": "application/json",
      Authorization: `Bearer ${token}`,
    },
  });

  if (response.ok) {
    console.log("Verification code sent.");
  } else {
    console.error("Failed to send verification code.");
  }
}

Security Considerations

  • Use HTTPS to prevent interception of the token.
  • Ensure the user is authenticated before generating the verification code.