Skip to main content

Overview

The otp.failed event is triggered when an OTP delivery attempt fails. This event includes error details and a resend endpoint for retrying the OTP delivery.

Example Payload

{
  "eventType": "otp.failed",
  "requestId": "68c6b2c3d4e5f6789012345",
  "issuerDid": "did:via:org-abc123",
  "user": {
    "contact": "+1234567890",
    "did": "did:via:user-xyz789",
    "internalId": "user_otp_001"
  },
  "decisionDate": "2024-01-15T22:45:00.000Z",
  "otp": {
    "resendEndpoint": "/v1/requests/68c6b2c3d4e5f6789012345/resend",
    "error": {
      "code": "INVALID_PHONE_NUMBER",
      "message": "The phone number format is invalid for the selected country"
    }
  }
}

Base Fields

All OTP failed events include these common fields:
FieldTypeRequiredDescription
eventTypestringYesAlways "otp.failed"
requestIdstringYesRequest identifier
internalIdstringNoYour internal identifier for the request
issuerDidstringYesDID of the organization/issuer
userobjectYesObject containing user identity fields
decisionDateDateYesTimestamp when the OTP failure was recorded

User Object

FieldTypeRequiredDescription
contactstringYesContact that failed (phone number or email)
didstringYesDID of the user/subject
internalIdstringNoYour internal identifier for the user

OTP Object

The otp field contains failure details and retry information:
FieldTypeRequiredDescription
resendEndpointstringYesAPI endpoint to resend the OTP
errorobjectYesError details

Error Object

The error field contains details about why the OTP delivery failed:
FieldTypeRequiredDescription
codestringYesSpecific error code indicating the failure reason
messagestringYesHuman-readable error message

Common Error Codes

CodeDescription
INVALID_PHONE_NUMBERPhone number format is invalid
UNDELIVERABLEMessage could not be delivered to the carrier
CARRIER_REJECTEDCarrier rejected the message
RATE_LIMITEDToo many attempts, rate limit exceeded
BLOCKED_DESTINATIONDestination is blocked or blacklisted
INVALID_EMAILEmail address format is invalid
EMAIL_BOUNCEDEmail bounced back
SPAM_DETECTEDMessage was flagged as spam

Handling OTP Failures

When you receive an otp.failed event:
  1. Log the error - Record the error.code and error.message for debugging
  2. Notify the user - Inform the user about the delivery failure and provide options
  3. Retry if appropriate - Use the otp.resendEndpoint to attempt OTP delivery again

Resending OTP

To retry OTP delivery, make a POST request to the otp.resendEndpoint:
curl -X POST https://api.humanos.id/v1/requests/68c6b2c3d4e5f6789012345/resend \
  -H "Authorization: Bearer YOUR_API_KEY"
The resend endpoint may have rate limiting. Check the response headers for X-RateLimit-Remaining before retrying.