OTP

Latest test code

Fetch the latest code created by a test-mode key for an email and purpose.

Copy page
GET/v1/test/latest-code

Fetch test code

cURL
curl --request GET \
  --url "https://api.sendotp.email/v1/test/[email protected]&purpose=report-access" \
  --header "Authorization: Bearer $SENDOTP_TEST_API_KEY"

200

A test-mode challenge exists for this email and purpose.
{
  "id": "otp_01JZ4NQ8F2T7G2A9J6P0G5QX3K",
  "email": "[email protected]",
  "purpose": "report-access",
  "code": "493021",
  "expiresAt": 1700000600
}

Overview

Use sk_test keys in CI to exercise the same send and verify API flow without delivering email. Test OTP records are isolated from live-key OTP records for the same account.

Authorization

Bearer API keyAuthorizationrequired

Requires the same sk_test API key used to send the code. Live keys receive test_key_required.

Request

emailquery stringrequired

Recipient email address used with the test-mode send request.

purposequery stringrequired

Purpose used with the test-mode send request.

Responses

200

A test-mode challenge exists for this email and purpose.

{
  "id": "otp_01JZ4NQ8F2T7G2A9J6P0G5QX3K",
  "email": "[email protected]",
  "purpose": "report-access",
  "code": "493021",
  "expiresAt": 1700000600
}
403

The request used a live key instead of a test key.

{
  "error": "test_key_required"
}
404

No test-mode challenge has been sent for this email and purpose.

{
  "error": "not_found"
}