Verify Code

Verify a one-time password submitted by the user.

Verify a Code

verify.ts
import { YourSend } from 'yoursend';

const ys = new YourSend({ apiKey: 'ys_live_...' });

const result = await ys.check({
  message_id: '8f14e45f-ceea-467a-9b3a-1d2c3e4f5a6b',  // from the send response
  code: '123456',                                       // user-provided code
});

if (result.verified) {
  // Code is correct — grant access
} else {
  // Wrong code — result.remaining_attempts shows tries left
}

Response

Success response
{
  "message_id": "8f14e45f-ceea-467a-9b3a-1d2c3e4f5a6b",
  "status": "verified",
  "verified": true
}
Wrong code (HTTP 200)
{
  "message_id": "8f14e45f-ceea-467a-9b3a-1d2c3e4f5a6b",
  "status": "pending",
  "verified": false,
  "remaining_attempts": 4
}

Error Handling

OutcomeHTTPMeaning
verified: false200Code doesn't match. remaining_attempts shows tries left.
expired400The code has expired (default: 10 min)
already_verified400The code has already been used
max_attempts400Too many wrong attempts (5 max)
not_found404No OTP found for this message_id