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

# OTP Verification

> Send and verify email OTP codes for signup, login, and password resets.

# OTP Verification

LearnWay issues cryptographically random 6-digit one-time passwords (OTP) sent via Resend email service with a default 10-minute expiry time.

***

## Send OTP

Dispatches an OTP to a target email address.

### Endpoint

```http theme={null}
POST /api/v2/auth/send-otp
```

### Request Body

| Field     | Type     | Required | Description                                                                                |
| :-------- | :------- | :------- | :----------------------------------------------------------------------------------------- |
| `email`   | `string` | **Yes**  | Destination email address                                                                  |
| `purpose` | `string` | No       | Purpose of OTP: `SIGNUP`, `LOGIN`, `PASSWORD_RESET`, `WALLET_PIN_RESET` (Default: `LOGIN`) |

```json theme={null}
{
  "email": "learner@example.com",
  "purpose": "SIGNUP"
}
```

### Response (200 OK)

```json theme={null}
{
  "success": true,
  "data": {
    "email": "learner@example.com",
    "expiresInSeconds": 600
  },
  "message": "OTP code has been sent successfully"
}
```

***

## Verify OTP

Validates that an entered OTP code matches the issued token and has not expired.

### Endpoint

```http theme={null}
POST /api/v2/auth/verify-otp
```

### Request Body

| Field     | Type     | Required | Description                        |
| :-------- | :------- | :------- | :--------------------------------- |
| `email`   | `string` | **Yes**  | User email address                 |
| `otpCode` | `string` | **Yes**  | 6-digit numeric OTP code           |
| `purpose` | `string` | No       | Matching purpose used when sending |

```json theme={null}
{
  "email": "learner@example.com",
  "otpCode": "592014",
  "purpose": "SIGNUP"
}
```

### Response (200 OK)

```json theme={null}
{
  "success": true,
  "data": {
    "verified": true,
    "email": "learner@example.com"
  },
  "message": "OTP verified successfully"
}
```
