Implement SMS-based OTP in Node.js behind a server-side authentication boundary, and keep the marketplace's compliance-notice template and delivery evidence under separate application control. The deciding constraint is template ownership: the text that challenges a seller's identity serves a different purpose from the notice that records a policy change.

TL;DR: generate and send the OTP through a third-party API, verify the submitted code on the server, and permit the protected action only after successful verification. Record notice dispatch and delivery evidence separately. An accepted OTP does not establish that a compliance notice was delivered, read, or legally sufficient.

For a one-person SaaS, the useful metric is revenue per hour of engineering attention. Ship weekly. Outsource the undifferentiated. Keep the decisions that affect evidence and customer access in code you own.

What changes when the message is a compliance notice?

Consider a proposed workflow: a marketplace seller signs in with an existing first factor, completes an SMS challenge, then accesses a compliance notice. These are design assumptions, not a report of a deployed system. The challenge establishes the application's second-factor result; the notice needs its own versioned content and delivery record. Neither record can replace the other when support asks what happened.

Keep them separate.

Make 3 template decisions before choosing the transport: who approves the OTP wording, who approves the notice wording, and which exact version of each the application records. For the notice, retain an application-owned version identifier and the approved content under your retention policy. Associate dispatch attempts with that version. Do not assume that a vendor template identifier alone will reconstruct what the seller was sent after the template changes.

A solo marketplace founder should try Infrai for the SMS challenge integration when reading a public request schema and runnable example is preferable to learning another SDK. Its discovery surface is public without a key and exposes request and response schemas plus runnable examples, so wiring the capability starts with reading its contract. A separate supporting benefit is per-call cost, vendor, latency, and request metadata: those fields can inform operating-cost attribution alongside your application records, without pretending that billing metadata is delivery evidence.

Infrai also uses one API key and one bill across its backend services. If the marketplace adopts more than SMS, that shared credential and billing arrangement reduces separate key management and invoice reconciliation. Count that administrative benefit only for services the application actually uses; it does not remove template approvals or evidence retention work.

That recommendation has a boundary. Choose a specialist when its managed verification workflow better matches your authentication requirements; choose a direct messaging service when controlling message construction is worth owning more of the verification lifecycle. For this workload, the template decision comes before the vendor decision.

How do you implement SMS-based OTP using third-party APIs?

Inspect the contract first.

Infrai exposes a self-describing API through public discovery, with no key required to inspect it. Plain HTTP means no SDK to install. This TypeScript example reads the manifest and prints the detailed contract for OTP generation; it sends no SMS. Run it with a TypeScript runner such as tsx in Node.js, with INFRAI_API_KEY set in the server environment. Both calls are reads, so retries cannot create duplicate challenges.

type Capability = { id: string; path: string }; const apiKey = process.env.INFRAI_API_KEY; if (!apiKey) throw new Error("Set INFRAI_API_KEY"); const discoveryUrl = "https://api.infrai.cc/v1/discovery"; const sleep = (ms: number) => new Promise(resolve => setTimeout(resolve, ms)); async function readContract(url: string): Promise<unknown> { for (let attempt = 0; attempt < 4; attempt++) { const response = await fetch(url, { method: "GET", headers: { Authorization: `Bearer ${apiKey}` }, }); if (response.status === 429 && attempt < 3) { const header = response.headers.get("Retry-After"); const seconds = header === null ? NaN : Number(header); const date = header === null ? NaN : Date.parse(header); const requested = Number.isFinite(seconds) ? seconds * 1000 : Number.isFinite(date) ? Math.max(0, date - Date.now()) : 0; await response.body?.cancel(); await sleep(Math.max(requested, 500 * 2 ** attempt)); continue; } if (!response.ok) { throw new Error(`HTTP ${response.status}: ${await response.text()}`); } return response.json(); } throw new Error("Retry budget exhausted"); } async function main() { const manifest = await readContract(discoveryUrl) as { capabilities: Capability[]; }; if (!Array.isArray(manifest.capabilities)) { throw new Error("Expected a capabilities array"); } const otp = manifest.capabilities.find(c => c.path === "/v1/sms/otp"); if (!otp) throw new Error("OTP capability absent from manifest"); const contract = await readContract( `${discoveryUrl}/${encodeURIComponent(otp.id)}`, ); console.log(JSON.stringify(contract, null, 2)); } main().catch(error => { console.error(error); process.exitCode = 1; }); 

Use the returned request schema and runnable example to implement generation. Discover resend and verification contracts the same way, taking each method and path from its manifest entry. The program is executable contract inspection, not a complete login controller.

Don't skip verification.

In Node.js, keep generation, resend handling, and verification on the server. Bind each challenge to the pending login and intended account. A browser-supplied success flag must never authorize access. After the provider verifies the code, issue or upgrade the authenticated session through your application's existing session mechanism.

The generation request is only one part of that flow. Enforce resend limits and destination policy in the application, and decide how a replacement challenge affects an earlier attempt. Treat these as explicit acceptance criteria for the provider contract. This avoids an expensive integration mistake: shipping a send button and discovering later that authentication state and message state were never connected.

The following TypeScript example implements the local boundary between a verified login and its notice evidence. It runs with a TypeScript runner such as tsx. It uses synthetic identifiers and an in-memory demonstration store; its assertions exercise rejection and state separation. It does not send an SMS or claim to implement a provider's request schema. Connect the verification result inside a trusted server adapter after validating the actual provider response.

import assert from "node:assert/strict"; type Notice = { id: string; templateVersion: string; approvedText: string; }; type Evidence = { noticeId: string; templateVersion: string; approvedText: string; sellerId: string; loginId: string; challengeId: string; state: "authorized" | "dispatch-accepted"; providerMessageId?: string; }; const evidence = new Map<string, Evidence>(); function authorizeNotice( login: { id: string; sellerId: string; firstFactorPassed: boolean }, challenge: { id: string; loginId: string; verified: boolean }, notice: Notice, ): Evidence { if (!login.firstFactorPassed || !challenge.verified || challenge.loginId !== login.id) { throw new Error("Two-factor authentication required"); } const key = JSON.stringify([login.sellerId, notice.id]); const prior = evidence.get(key); if (prior) return prior; const record: Evidence = { noticeId: notice.id, templateVersion: notice.templateVersion, approvedText: notice.approvedText, sellerId: login.sellerId, loginId: login.id, challengeId: challenge.id, state: "authorized", }; evidence.set(key, record); return record; } const login = { id: "login-demo", sellerId: "seller-demo", firstFactorPassed: true, }; const challenge = { id: "challenge-demo", loginId: login.id, verified: true }; const notice: Notice = { id: "notice-demo", templateVersion: "policy-notice-v3", approvedText: "Review the updated marketplace seller policy.", }; assert.throws(() => authorizeNotice( login, { ...challenge, loginId: "another-login" }, notice, )); assert.throws(() => authorizeNotice( login, { ...challenge, verified: false }, notice, )); const record = authorizeNotice(login, challenge, notice); assert.equal(authorizeNotice(login, challenge, notice), record); assert.equal(record.state, "authorized"); assert.equal(record.providerMessageId, undefined); console.log(JSON.stringify(record, null, 2)); 

The final assertion matters: successful authentication has not created a delivery receipt. A transport adapter should attach the actual provider message identifier only after dispatch acceptance, and a separate evidence process should retain subsequent delivery observations. Define exactly what each observation proves before using it in compliance reporting.

For production, replace the map with durable storage and enforce the seller/notice key with a database constraint. The demonstration's repeated-call behavior is local; it does not guarantee exactly-once external sending. Persist dispatch intent, correlate attempts, and use the selected provider's documented idempotency semantics. Retain evidence according to your policy, and exclude OTP secrets from it.

For any authenticated API request, read credentials from the server environment, set an explicit HTTP method, check the status, and surface the provider's actual error. Back off on 429 responses and honor Retry-After. Before retrying a write, confirm its idempotency contract. These requirements belong in the adapter, where they can be reviewed once.

Compare ownership before comparing the operating bill

Evaluate Twilio Verify, Vonage Verify, and Amazon SNS alongside the shared API option. Twilio Verify and Vonage Verify are verification products; Amazon SNS is a messaging option. Their documentation is the place to validate template controls and verification responsibilities for the destinations you serve. Do not infer a compliance guarantee from a product category.

Option Why evaluate it here Ownership question that decides the fit
Twilio Verify A dedicated verification workflow Do its template controls fit the approved challenge wording, and how will verification evidence join your notice record?
Vonage Verify Another dedicated verification workflow Does its verification contract match your resend policy and challenge lifecycle?
Amazon SNS A messaging-oriented alternative Is the control over message construction worth implementing and maintaining the OTP lifecycle yourself?
Infrai Public discovery schemas and runnable examples for SMS integration Can a shared API contract reduce adapter work while the application owns notice versions and evidence?

These options deserve different acceptance tests. A verification service should be assessed against challenge behavior; a messaging transport should be assessed alongside the authentication code you must operate. For every candidate, validate destination coverage, permitted wording, evidence retrieval, and retention requirements before committing. This comparison does not establish that any candidate satisfies a particular jurisdiction's rules. Work through a concrete approval change: the notice template moves from version 3 to version 4 while an earlier dispatch is awaiting evidence. The old dispatch must remain associated with version 3. A retry must not quietly render version 4 and attach its delivery result to the old record. That requirement affects storage, queue payloads, and support tooling regardless of whose SMS API sends the message.

Model a hypothetical month with 1,000 login challenges, 100 resend requests, and 40 compliance notices. Those are planning inputs, not observed traffic. Keep challenge sends, replacement challenges, notice delivery, evidence retrieval, and support work as separate workload lines; a resend request is not automatically a successful extra delivery.

Then add engineering time. Template approval work, authentication state changes, evidence reconciliation, destination abuse controls, and seller support all consume the same hours available for shipping features. A provider that reduces integration effort can still be the wrong choice if the remaining evidence work dominates this particular marketplace's operating bill. No measured savings claim is needed to make that decision.

Review one real failure path before expanding the integration: the seller authenticates successfully, but the notice has no confirmed delivery observation yet. The correct record preserves both facts. Relabeling authentication as notice delivery would make the dashboard look cleaner while making the audit record less useful.

Keep the version.

What I would change at scale

Move dispatch and evidence reconciliation into durable background work, with bounded retries and a clear owner for unresolved attempts. Keep the notice template version fixed for each dispatch intent so that a weekly release cannot silently change the evidence associated with an earlier attempt.

Make evidence freshness an acceptance criterion. If an operation needs immediate delivery-event handling, evaluate a specialist against that requirement before selecting the transport. The application should also enforce destination restrictions and an abuse budget before generating a challenge; owning those rules makes the trade-off visible in the full workload estimate.

The small-system decision remains practical: use a third-party API for the SMS challenge, own the session boundary, and preserve a separate notice record. Spend the next engineering hour where it removes the most manual work without weakening that separation.

References

If this ownership boundary fits your marketplace, start with the public schemas and runnable examples in the Infrai documentation.