API 문서로

OTP API

이메일 인증 코드 발송 및 검증을 위한 API입니다.

필요 권한: otp

POST /api/v1/otp/send

인증 코드를 이메일로 발송합니다.

Request Body

{
  "email": "user@example.com",
  "template": "login",           // optional: login, signup, reset
  "expires_in": 300,             // optional: seconds (default: 300)
  "code_length": 6               // optional: 4-8 (default: 6)
}

Response

{
  "success": true,
  "data": {
    "session_id": "abc123...",
    "email": "user@example.com",
    "expires_at": "2026-01-10T12:05:00Z"
  }
}
POST /api/v1/otp/verify

인증 코드를 검증합니다.

Request Body

{
  "session_id": "abc123...",
  "code": "123456"
}

Response (Success)

{
  "success": true,
  "data": {
    "verified": true,
    "email": "user@example.com"
  }
}

Response (Failed)

{
  "success": false,
  "error": {
    "code": "INVALID_CODE",
    "message": "The verification code is invalid or expired."
  }
}
POST /api/v1/otp/resend

인증 코드를 재발송합니다.

Request Body

{
  "session_id": "abc123..."
}

Response

{
  "success": true,
  "data": {
    "session_id": "abc123...",
    "expires_at": "2026-01-10T12:05:00Z"
  }
}
GET /api/v1/otp/status/{session_id}

OTP 세션 상태를 확인합니다.

Response

{
  "success": true,
  "data": {
    "session_id": "abc123...",
    "email": "user@example.com",
    "status": "pending",          // pending, verified, expired
    "attempts": 2,
    "max_attempts": 5,
    "expires_at": "2026-01-10T12:05:00Z"
  }
}

사용 예제

cURL

# 1. Send OTP
curl -X POST https://www.mailpass.im/api/v1/otp/send \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"email": "user@example.com"}'

# 2. Verify OTP
curl -X POST https://www.mailpass.im/api/v1/otp/verify \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"session_id": "abc123...", "code": "123456"}'

JavaScript (fetch)

// Send OTP
const response = await fetch('https://www.mailpass.im/api/v1/otp/send', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({ email: 'user@example.com' })
});
const data = await response.json();

쿠키를 사용합니다

사용자 경험 향상을 위해 쿠키를 사용합니다. 허용할 쿠키 카테고리를 선택할 수 있습니다. 자세히 보기