Sending Two Factor Authentication (2FA) codes by SMS API
Back to Articles
News SMS API Security Two Factor Authentication News

Sending Two Factor Authentication (2FA) codes by SMS API

July 31, 2018 1 min
Aivis Olsteins

Aivis Olsteins

We have discussed the topic of two factor authentication previously several times, here regarding voice call ( https://datatechlabs.com/posts/56/two-factor-authentication-api-with-phone-call ), here in general ( https://datatechlabs.com/posts/48/two-factor-authentication-with-sms-and-voice-calling ) and here regarding one time passwords: https://datatechlabs.com/posts/32/usecase-one-time-password-generator-for-application-security

Now let's see how to do with SMS, simply by using our API. In general, sending SMS is as simple as constructing this simple request:

 

POST /sms/send

{
"to": "recipient",
"from": "sender",
"content": "hello, World!"
}

In this simple example above, the API will just send a hello, world! message to recipient. There are, however, ways to have more control about the sending process, like, for example: getting to know if the message was delivered or not, or sending non-latin encoded texts:

This request will ask for a delivery receipt (DLR) after the message was delivered:


POST /sms/send

{
"to": "recipient",
"from": "sender",
"content": "hello, World!",
"dlr": true
"dlr-level": 3,
"dlr-url": "http://server.host.com/path",
"dlr-method": "POST"
}

Now, upon successful delivery, the API will do a HTTP POST to the address of the server specified in dlr-url and report on the on the success of delivery. The values of dlr-level attribute are integers, where 1 - means SMS-C delivery report, 2 - means endusers terminal delivery report and 3 means both of them.

In the case we need to send non-Latin characters, we can set desired character set with coding attribute:

POST /sms/send

{
"to": "recipient",
"from": "sender",
"content": "hello, World!",
"dlr": true
"dlr-level": 3,
"dlr-url": "http://server.host.com/path",
"dlr-method": "POST",
"coding": "UTF-8"
}

Note, however, that most SMS carriers actually charge per bits of message sent (see https://datatechlabs.com/posts/13/anatomy-of-a-short-message ), i.e. only the messages with are 7-bit encoded (ASCII) are allowed to be 160 characters long before they are split into multiple segments.

Share this article

Aivis Olsteins

Aivis Olsteins

An experienced telecommunications professional with expertise in network architecture, cloud communications, and emerging technologies. Passionate about helping businesses leverage modern telecom solutions to drive growth and innovation.

Related Articles

How Voice AI Reduces Agent Burnout and Boosts Satisfaction

How Voice AI Reduces Agent Burnout and Boosts Satisfaction

Reduce Burnout with Voice AI: Offload Repetitive Calls, Real‑Time Agent Assist, 40–80% Less ACW, Calmer Escalations, Healthier Occupancy, Proactive Deflection & PCI‑Safe Flows—Happier Agents, Faster Resolutions, Better Coaching, Faster Ramp

Read Article
Seamless Voice AI Integrations: Salesforce, HubSpot, and ERP Systems

Seamless Voice AI Integrations: Salesforce, HubSpot, and ERP Systems

Seamless Voice AI Integrations with Your Stack: Salesforce & HubSpot CRM + SAP/Oracle/NetSuite/Dynamics ERP; OAuth2 & mTLS Security; Real‑Time Read/Write (Cases, Orders, Payments, Scheduling); Warm Transfers, Context; Audit Logs, SLAs, iPaaS Support

Read Article
Measuring Voice AI Success: The KPIs That Matter—CSAT, Containment, Speed, Accuracy, Reliability, and ROI

Measuring Voice AI Success: The KPIs That Matter—CSAT, Containment, Speed, Accuracy, Reliability, and ROI

Voice AI KPI Scorecard: CSAT/NPS, FCR & Containment, Time‑to‑First‑Word & p95 Latency, Intent/Slot Accuracy & ASR WER, Groundedness, Tool Success (Payments/IDV/Scheduling), Warm Xfers, Uptime/Reliability, Consent/Redact, Cost per Resolution & ROI

Read Article
Sensitive Data in Voice AI: PCI‑Safe Payments, HIPAA‑Compliant PHI, Redaction & Tokenization

Sensitive Data in Voice AI: PCI‑Safe Payments, HIPAA‑Compliant PHI, Redaction & Tokenization

Managing Sensitive Data in Voice AI: PCI‑Safe Payments (DTMF Masking, Tokenization), HIPAA‑Compliant PHI Segregation, Redaction/De‑Identification, End‑to‑End Encryption, Zero‑Trust Access, Residency/Retention, DSAR Deletion, SIEM‑Audited Trails

Read Article

SUBSCRIBE TO OUR NEWSLETTER

Stay up to date with the latest news and updates from our telecom experts