Authenticate, manage numbers, receive SMS messages, and integrate with your stack.
The 2fact.io API allows your application to receive SMS-based Two-Factor Authentication (2FA) codes securely using your dedicated number(s). Each organization receives its own API key and webhook URL.
Each API request must include your API Key in the header:
Authorization: Bearer YOUR_API_KEY Content-Type: application/json
Your API Key is found in your Dashboard → API Keys.
https://api.2fact.io/v1/
GET /numbers Authorization: Bearer YOUR_API_KEYExample Response:
{
"numbers": [
{
"phone": "+15105550123",
"assigned_to": "production",
"status": "active",
"last_message": "Your Amazon OTP is 448921"
}
]
}
GET /messages?limit=50 Authorization: Bearer YOUR_API_KEYExample Response:
{
"messages": [
{
"id": "msg_001",
"timestamp": "2025-01-01T14:22:00Z",
"from": "Amazon",
"to": "+15105550123",
"message": "Your OTP is 338192"
}
]
}
When your number receives an SMS, 2fact.io will POST the event to your webhook URL.
POST /your-webhook-endpoint
{
"number": "+15105550123",
"sender": "Amazon",
"message": "Your OTP code is 004211",
"received_at": "2025-02-01T10:00:00Z"
}
curl --location "https://api.2fact.io/v1/numbers" \ --header "Authorization: Bearer YOUR_API_KEY"
For assistance, email support@2fact.io