Send and verify OTP codes over WhatsApp or SMS from Node.js, and create WhatsApp OTP links, with the Hypersender OTP API. Expiry and checks in TypeScript.
Use the Hypersender OTP service from Node.js to send verification codes over WhatsApp or SMS, validate the codes your users enter, and generate passwordless WhatsApp links.
What you can do
Request OTP codes: Generate a one-time code and send it from a WhatsApp or SMS instance.
Validate codes: Check user-entered codes against the active OTP.
Generate OTP links (WhatsApp only): Create WhatsApp links that complete verification without typing. SMS instances can’t generate links.
Prerequisites
Node.js app with the hypersender-node package installed (Installation).
Hypersender API token and Instance UUID from the dashboard, set as HYPERSENDER_OTP_API_KEY and HYPERSENDER_OTP_INSTANCE_ID.
For SMS, an SMS instance with the Hypersender SMS app running on the linked Android phone. See SMS quick start.
Base URL and auth
Base URL: https://app.hypersender.com/api/otp/v2/{instance}Auth: Authorization: Bearer YOUR_API_TOKEN
The SDK adds the instance UUID to the URL and the token to the header for you.
Quick start (request and validate)
import { Hypersender } from "hypersender-node";import { HypersenderError } from "hypersender-node/models/errors";const codeFromUser = "482913"; // the code the user typed// 1) Send a codeconst result = await Hypersender.otp().requestCode({ chatId: "[email protected]", // WhatsApp chat ID length: 6, useNumber: true, useLetter: false, allCapital: false, name: "YourApp", expires: 300,});const chatId = result.data?.chatId ?? "[email protected]";// 2) Validate the code the user typedlet isValid = false;try { const validation = await Hypersender.otp().validateCode({ chatId, code: codeFromUser, }); isValid = validation.success === true;} catch (error) { if (!(error instanceof HypersenderError)) throw error; // Wrong, used, or expired code: error.statusCode is 422}
Both methods return the parsed, typed response body, with the OTP details under data. Any 4XX or 5XX response throws an error that extends HypersenderError; a wrong, used, or expired code throws with statusCode422.
Send the code over SMS
With an SMS instance, pass the phone number in international format as chatId. Spaces, dashes, dots, and parentheses are removed, and 00 at the start is read as +. WhatsApp chat IDs are rejected for SMS.
The user receives a short plain-text SMS, such as:
YourApp code: 482913
The wording rotates between six short versions, so carriers are less likely to drop it. Validate it with the same phone number. If you want your own message text, send the code yourself with the SMS API. See the SMS OTP guide.
Keep tokens and OTP codes out of logs. Use HTTPS for all calls.
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"Hypersender","description":"Send WhatsApp and SMS messages from your own numbers with the Hypersender API. Guides, REST API reference, webhook events, and Laravel SDK docs.","colors":{"primary":"#10b981","light":"#059669","dark":"#10b981"},"logo":{"light":"https://mintcdn.com/hypersender/RX4Bj-Mb6ti70ZQe/logo/light.svg?fit=max\u0026auto=format\u0026n=RX4Bj-Mb6ti70ZQe\u0026q=85\u0026s=e38aff8c21e09ed683da236a8ffe8e13","dark":"https://mintcdn.com/hypersender/RX4Bj-Mb6ti70ZQe/logo/dark.svg?fit=max\u0026auto=format\u0026n=RX4Bj-Mb6ti70ZQe\u0026q=85\u0026s=31d31abc2839f94267a1548817b83538","href":"https://docs.hypersender.com"},"favicon":"https://mintcdn.com/hypersender/dAZ_QYs7yJAVpPpO/favicon.svg?fit=max\u0026auto=format\u0026n=dAZ_QYs7yJAVpPpO\u0026q=85\u0026s=74d0e86aaf7cdfe05cbdf2c13a044dec","background":{"image":{"light":"https://mintcdn.com/hypersender/QHanPLHbv0ntvGTU/images/background.png?fit=max\u0026auto=format\u0026n=QHanPLHbv0ntvGTU\u0026q=85\u0026s=bfcb110c086b77caa501a84cab4586a4","dark":"https://mintcdn.com/hypersender/QHanPLHbv0ntvGTU/images/background-dark.png?fit=max\u0026auto=format\u0026n=QHanPLHbv0ntvGTU\u0026q=85\u0026s=3137c58a2031e6febc74d0c1ec3632ac"}},"navbar":{"links":[{"href":"mailto:[email protected]","label":"Support"}],"primary":{"type":"button","label":"Dashboard","href":"https://app.hypersender.com"}},"footer":{"socials":{"x":"https://x.com/hypersender","github":"https://github.com/hypersender","linkedin":"https://linkedin.com/company/hypersender"}},"search":{"prompt":"Search WhatsApp \u0026 SMS API docs"},"seo":{"metatags":{"canonical":"https://docs.hypersender.com","og:site_name":"Hypersender Docs","og:locale":"en_US","twitter:card":"summary_large_image","twitter:site":"@hypersender","robots":"index, follow","googlebot":"index, follow","author":"Hypersender","theme-color":"#10b981"},"organization":{"id":"https://hypersender.com/#organization","name":"Hypersender","url":"https://hypersender.com","sameAs":["https://x.com/hypersender","https://github.com/hypersender","https://linkedin.com/company/hypersender"]},"indexing":"navigable"},"styling":{"eyebrows":"breadcrumbs","latex":false},"contextual":{"options":["copy","view","chatgpt","claude","perplexity","mcp","cursor","vscode"],"display":"header"},"metadata":{"timestamp":true},"navigation":{"global":{"anchors":[{"anchor":"WhatsApp Support","icon":"whatsapp","href":"https://wa.me/201065684630"},{"anchor":"Discord Support","icon":"discord","href":"https://discord.gg/ysSmK32ykC"},{"anchor":"Blog","icon":"newspaper","href":"https://hypersender.com/blog"}]},"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"hypersender","hasAudioNarration":false,"actualSubdomain":"hypersender","customDomains":["docs.hypersender.com"],"gitSource":{"type":"github","owner":"hypersender","repo":"docs-v2","deployBranch":"main","contentDirectory":"","isPrivate":true,"mountPath":"","label":""},"entitlements":{},"buildId":"6b04604c34aba046b8b2d5ac","clientVersion":"0.0.4271","searchFilterCounts":[{"language":"default","tag":"Whatsapp API","count":72},{"language":"default","tag":"SMS API","count":60},{"language":"default","tag":"WhatsApp API","count":47},{"language":"default","tag":"Send Messages","count":36},{"language":"default","tag":"MCP","count":36},{"language":"default","tag":"Packages and SDKs","count":31},{"language":"default","tag":"Laravel","count":29},{"language":"default","tag":"SMS Webhooks","count":28},{"language":"default","tag":"Guides","count":23},{"language":"default","tag":"Enterprise WhatsApp API","count":22}]},"assistantConfig":{},"basePath":"","hasChatPermissions":false,"hasWebMcpPermissions":false,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-rbac-roles","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"site-roles","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-metadata","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"sso-setup-deadline-banner","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"live-agents","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"starter-pricing","enabled":true,"variant":{"name":"control","enabled":true,"payload":{"type":"string","value":"control"},"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"wildcard-email-auth","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":false},"customCss":[{"filePath":"style.css","content":".prose{--tw-prose-code: #10b981}.dark .prose{--tw-prose-code: #34d399}.prose :not(pre)>code,.mdx-prose :not(pre)>code,article :not(pre)>code{color:#10b981!important}.dark .prose :not(pre)>code,.dark .mdx-prose :not(pre)>code,.dark article :not(pre)>code{color:#34d399!important}img[src=\"/images/mcp.svg\"]{background-color:transparent!important}"}]}
{"page":{"pagePath":"v2/packages-and-sdks/node/otp/otp-with-node","slug":"/v2/packages-and-sdks/node/otp/otp-with-node","pageMetadata":{"title":"WhatsApp and SMS OTP in Node.js","sidebarTitle":"OTP with Node","description":"Send and verify OTP codes over WhatsApp or SMS from Node.js, and create WhatsApp OTP links, with the Hypersender OTP API. Expiry and checks in TypeScript.","keywords":["whatsapp otp","node js otp verification","send otp node js","how to send otp sms using node js","sms otp","otp api"],"href":"/v2/packages-and-sdks/node/otp/otp-with-node"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"Send and verify OTP codes over WhatsApp or SMS from Node.js, and create WhatsApp OTP links, with the Hypersender OTP API. Expiry and checks in TypeScript.\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,li:`li`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,ul:`ul`,..._provideComponents(),...props.components},{CodeBlock,Heading,Warning}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Warning)_missingMdxReference(`Warning`,true);return _jsxs(_Fragment,{children:[_jsx(_components.p,{children:`Use the Hypersender OTP service from Node.js to send verification codes over WhatsApp or SMS, validate the codes your users enter, and generate passwordless WhatsApp links.`}),`\n`,_jsx(Heading,{level:`2`,id:`what-you-can-do`,children:`What you can do`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Request OTP codes`}),`: Generate a one-time code and send it from a WhatsApp or SMS instance.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Validate codes`}),`: Check user-entered codes against the active OTP.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Generate OTP links (WhatsApp only)`}),`: Create WhatsApp links that complete verification without typing. SMS instances can’t generate links.`]}),`\n`]}),`\n`,_jsx(Heading,{level:`2`,id:`prerequisites`,children:`Prerequisites`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[`Node.js app with the `,_jsx(_components.code,{children:`hypersender-node`}),` package installed (`,_jsx(_components.a,{href:`/v2/packages-and-sdks/node/installation`,children:`Installation`}),`).`]}),`\n`,_jsxs(_components.li,{children:[`Hypersender `,_jsx(_components.strong,{children:`API token`}),` and `,_jsx(_components.strong,{children:`Instance UUID`}),` from the dashboard, set as `,_jsx(_components.code,{children:`HYPERSENDER_OTP_API_KEY`}),` and `,_jsx(_components.code,{children:`HYPERSENDER_OTP_INSTANCE_ID`}),`.`]}),`\n`,_jsxs(_components.li,{children:[`For SMS, an SMS instance with the Hypersender SMS app running on the linked Android phone. See `,_jsx(_components.a,{href:`/v2/hypersender/overview/sms/sms-quick-start`,children:`SMS quick start`}),`.`]}),`\n`]}),`\n`,_jsx(Heading,{level:`2`,id:`base-url-and-auth`,children:`Base URL and auth`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`Base`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` URL:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` https://app.hypersender.com/api/otp/v2/{instance}`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`Auth:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` Authorization:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` Bearer`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` YOUR_API_TOKEN`})]}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`The SDK adds the instance UUID to the URL and the token to the header for you.`}),`\n`,_jsx(Heading,{level:`2`,id:`quick-start-request-and-validate`,children:`Quick start (request and validate)`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`31`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`31`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`Hypersender`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"hypersender-node\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`HypersenderError`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"hypersender-node/models/errors\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` codeFromUser`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"482913\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`; `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// the code the user typed`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// 1) Send a code`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` result`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` Hypersender`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`otp`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`().`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`requestCode`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` chatId:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"[email protected]\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// WhatsApp chat ID`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` length:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 6`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` useNumber:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` true`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` useLetter:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` false`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` allCapital:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` false`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` name:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"YourApp\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` expires:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 300`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`});`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` chatId`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` result`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`data`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`?.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`chatId`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` ??`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"[email protected]\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// 2) Validate the code the user typed`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`let`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` isValid`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` false`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`try`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` validation`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` Hypersender`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`otp`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`().`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`validateCode`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` chatId`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` code:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` codeFromUser`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` });`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` isValid`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` validation`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`success`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` ===`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` true`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`} `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`catch`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`error`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`!`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`error`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` instanceof`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` HypersenderError`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`throw`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` error`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` // Wrong, used, or expired code: error.statusCode is 422`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`Both methods return the parsed, typed response body, with the OTP details under `,_jsx(_components.code,{children:`data`}),`. Any `,_jsx(_components.code,{children:`4XX`}),` or `,_jsx(_components.code,{children:`5XX`}),` response throws an error that extends `,_jsx(_components.code,{children:`HypersenderError`}),`; a wrong, used, or expired code throws with `,_jsx(_components.code,{children:`statusCode`}),` `,_jsx(_components.code,{children:`422`}),`.`]}),`\n`,_jsx(Heading,{level:`2`,id:`send-the-code-over-sms`,children:`Send the code over SMS`}),`\n`,_jsxs(_components.p,{children:[`With an SMS instance, pass the phone number in international format as `,_jsx(_components.code,{children:`chatId`}),`. Spaces, dashes, dots, and parentheses are removed, and `,_jsx(_components.code,{children:`00`}),` at the start is read as `,_jsx(_components.code,{children:`+`}),`. WhatsApp chat IDs are rejected for SMS.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`11`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`11`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`Hypersender`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"hypersender-node\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` result`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` Hypersender`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`otp`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`().`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`requestCode`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` chatId:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"+201001234567\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` length:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 6`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` useNumber:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` true`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` useLetter:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` false`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` allCapital:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` false`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` name:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"YourApp\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` expires:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 300`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`});`})}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`The user receives a short plain-text SMS, such as:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`YourApp code: 482913`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsxs(_components.p,{children:[`The wording rotates between six short versions, so carriers are less likely to drop it. Validate it with the same phone number. If you want your own message text, send the code yourself with the SMS API. See the `,_jsx(_components.a,{href:`/v2/hypersender/overview/sms/sms-otp-guide`,children:`SMS OTP guide`}),`.`]}),`\n`,_jsx(Warning,{children:_jsx(_components.p,{children:`Keep tokens and OTP codes out of logs. Use HTTPS for all calls.`})}),`\n`,_jsx(Heading,{level:`2`,id:`next-steps`,children:`Next steps`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsx(_components.li,{children:_jsx(_components.a,{href:`/v2/packages-and-sdks/node/otp/request-otp-code-node-sdk`,children:`Request OTP Code`})}),`\n`,_jsx(_components.li,{children:_jsx(_components.a,{href:`/v2/packages-and-sdks/node/otp/validate-otp-code-node-sdk`,children:`Validate OTP Code`})}),`\n`,_jsx(_components.li,{children:_jsx(_components.a,{href:`/v2/packages-and-sdks/node/otp/generate-whatsapp-otp-link-with-node`,children:`Generate OTP Link`})}),`\n`]})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"WhatsApp and SMS OTP in Node.js","sidebarTitle":"OTP with Node","description":"Send and verify OTP codes over WhatsApp or SMS from Node.js, and create WhatsApp OTP links, with the Hypersender OTP API. Expiry and checks in TypeScript.","keywords":["whatsapp otp","node js otp verification","send otp node js","how to send otp sms using node js","sms otp","otp api"],"href":"/v2/packages-and-sdks/node/otp/otp-with-node"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"What you can do","slug":"what-you-can-do","depth":2,"children":[]},{"title":"Prerequisites","slug":"prerequisites","depth":2,"children":[]},{"title":"Base URL and auth","slug":"base-url-and-auth","depth":2,"children":[]},{"title":"Quick start (request and validate)","slug":"quick-start-request-and-validate","depth":2,"children":[]},{"title":"Send the code over SMS","slug":"send-the-code-over-sms","depth":2,"children":[]},{"title":"Next steps","slug":"next-steps","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":[],"subdomain":"hypersender","siteName":"Hypersender","title":"WhatsApp and SMS OTP in Node.js - Hypersender","navMaps":{"firstHrefInVersion":{"v2":{"href":"/v2/packages-and-sdks/node/otp/otp-with-node","matchLevel":0},"v1":{"href":"/v1/hypersender/hypersender-api-for-whatsapp-and-sms-messaging","matchLevel":4}},"firstHrefInLanguage":{}},"lastModified":"2026-11-23T15:48:58.904Z","gitLastModified":"2026-11-23T15:48:25.000Z","originalFileLocation":"v2/packages-and-sdks/node/otp/otp-with-node.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Send and verify OTP codes over WhatsApp or SMS from Node.js, and create WhatsApp OTP links, with the Hypersender OTP API. Expiry and checks in TypeScript.\">\u003cmeta data-mint-head name=\"application-name\" content=\"Hypersender\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003cmeta data-mint-head name=\"robots\" content=\"index, follow\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/hypersender/YssXEy8fq447EilS/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/hypersender/YssXEy8fq447EilS/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/hypersender/YssXEy8fq447EilS/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/hypersender/YssXEy8fq447EilS/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/hypersender/YssXEy8fq447EilS/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/hypersender/YssXEy8fq447EilS/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/hypersender/YssXEy8fq447EilS/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/hypersender/YssXEy8fq447EilS/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/hypersender/YssXEy8fq447EilS/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"WhatsApp and SMS OTP in Node.js - Hypersender\">\u003cmeta data-mint-head property=\"og:description\" content=\"Send and verify OTP codes over WhatsApp or SMS from Node.js, and create WhatsApp OTP links, with the Hypersender OTP API. Expiry and checks in TypeScript.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Hypersender Docs\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.hypersender.com/v2/packages-and-sdks/node/otp/otp-with-node\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://hypersender.mintlify.site/_mintlify/api/og/v2?division=OTP\u0026amp;title=WhatsApp+and+SMS+OTP+in+Node.js\u0026amp;description=Send+and+verify+OTP+codes+over+WhatsApp+or+SMS+from+Node.js%2C+and+create+WhatsApp+OTP+links%2C+with+the+Hypersender+OTP+API.+Expiry+and+checks+in+TypeScript.\u0026amp;theme=99e6b81012c241153533187b\u0026amp;signature=cdabf08c1c5a33c473a2973335e4fb52b1d455bd3068dbbde7519bbdd965915c\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"WhatsApp and SMS OTP in Node.js - Hypersender\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Send and verify OTP codes over WhatsApp or SMS from Node.js, and create WhatsApp OTP links, with the Hypersender OTP API. Expiry and checks in TypeScript.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://hypersender.mintlify.site/_mintlify/api/og/v2?division=OTP\u0026amp;title=WhatsApp+and+SMS+OTP+in+Node.js\u0026amp;description=Send+and+verify+OTP+codes+over+WhatsApp+or+SMS+from+Node.js%2C+and+create+WhatsApp+OTP+links%2C+with+the+Hypersender+OTP+API.+Expiry+and+checks+in+TypeScript.\u0026amp;theme=99e6b81012c241153533187b\u0026amp;signature=cdabf08c1c5a33c473a2973335e4fb52b1d455bd3068dbbde7519bbdd965915c\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/hypersender/YssXEy8fq447EilS/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Hypersender\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#10b981\">\u003cmeta data-mint-head name=\"og:locale\" content=\"en_US\">\u003cmeta data-mint-head name=\"googlebot\" content=\"index, follow\">\u003cmeta data-mint-head name=\"author\" content=\"Hypersender\">\u003cmeta data-mint-head name=\"theme-color\" content=\"#10b981\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.hypersender.com/v2/packages-and-sdks/node/otp/otp-with-node\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/v2/packages-and-sdks/node/otp/otp-with-node.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://hypersender.com/#organization\",\"name\":\"Hypersender\",\"url\":\"https://hypersender.com\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/hypersender/RX4Bj-Mb6ti70ZQe/logo/light.svg?fit=max\u0026auto=format\u0026n=RX4Bj-Mb6ti70ZQe\u0026q=85\u0026s=e38aff8c21e09ed683da236a8ffe8e13\"},\"sameAs\":[\"https://x.com/hypersender\",\"https://github.com/hypersender\",\"https://linkedin.com/company/hypersender\"]},{\"@type\":\"WebSite\",\"@id\":\"https://docs.hypersender.com#website\",\"name\":\"Hypersender\",\"url\":\"https://docs.hypersender.com\",\"publisher\":{\"@id\":\"https://hypersender.com/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.hypersender.com/v2/packages-and-sdks/node/otp/otp-with-node#webpage\",\"url\":\"https://docs.hypersender.com/v2/packages-and-sdks/node/otp/otp-with-node\",\"name\":\"WhatsApp and SMS OTP in Node.js\",\"description\":\"Send and verify OTP codes over WhatsApp or SMS from Node.js, and create WhatsApp OTP links, with the Hypersender OTP API. Expiry and checks in TypeScript.\",\"dateModified\":\"2026-11-23T15:48:25.000Z\",\"isPartOf\":{\"@id\":\"https://docs.hypersender.com#website\"},\"breadcrumb\":{\"@id\":\"https://docs.hypersender.com/v2/packages-and-sdks/node/otp/otp-with-node#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.hypersender.com/v2/packages-and-sdks/node/otp/otp-with-node#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Node\",\"item\":\"https://docs.hypersender.com/v2/packages-and-sdks/node/installation\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"WhatsApp and SMS OTP in Node.js\",\"item\":\"https://docs.hypersender.com/v2/packages-and-sdks/node/otp/otp-with-node\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs.hypersender.com/v2/packages-and-sdks/node/otp/otp-with-node#article\",\"headline\":\"WhatsApp and SMS OTP in Node.js\",\"name\":\"WhatsApp and SMS OTP in Node.js\",\"description\":\"Send and verify OTP codes over WhatsApp or SMS from Node.js, and create WhatsApp OTP links, with the Hypersender OTP API. Expiry and checks in TypeScript.\",\"url\":\"https://docs.hypersender.com/v2/packages-and-sdks/node/otp/otp-with-node\",\"mainEntityOfPage\":{\"@id\":\"https://docs.hypersender.com/v2/packages-and-sdks/node/otp/otp-with-node#webpage\"},\"dateModified\":\"2026-11-23T15:48:25.000Z\",\"keywords\":\"whatsapp otp, node js otp verification, send otp node js, how to send otp sms using node js, sms otp, otp api\",\"publisher\":{\"@id\":\"https://hypersender.com/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.hypersender.com#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Hypersender\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"Hypersender\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/v2/packages-and-sdks/node/otp/otp-with-node.md","siteName":"Hypersender","nav":{"global":{"anchors":[{"anchor":"WhatsApp Support","icon":"whatsapp","href":"https://wa.me/201065684630"},{"anchor":"Discord Support","icon":"discord","href":"https://discord.gg/ysSmK32ykC"},{"anchor":"Blog","icon":"newspaper","href":"https://hypersender.com/blog"}]},"versions":[{"version":"v2","tabs":[{"tab":"Guides","icon":"book","pages":[{"title":"Guides","href":"/v2/hypersender/hypersender-api-for-whatsapp-and-sms-messaging"}]},{"tab":"MCP","icon":"https://mintlify.s3.us-west-1.amazonaws.com/hypersender/images/mcp.svg","pages":[{"title":"MCP","href":"/v2/hypersender/mcp/hypersender-mcp"}]},{"tab":"Whatsapp API","icon":"whatsapp","pages":[{"title":"Whatsapp API","href":"/v2/api-reference/whatsapp/whatsapp-api-introduction"}]},{"tab":"OTP API","icon":"lock","pages":[{"title":"OTP API","href":"/v2/api-reference/otp/otp-api-introduction"}]},{"tab":"SMS API","icon":"message","pages":[{"title":"SMS API","href":"/v2/api-reference/sms/sms-api-introduction"}]},{"tab":"Enterprise WhatsApp API","icon":"fire","pages":[{"title":"Enterprise WhatsApp API","href":"/v2/api-reference/enterprise/enterprise-whatsapp-api-introduction"}]},{"tab":"Packages and SDKs","icon":"box-open","groups":[{"group":"Overview","boost":3,"pages":[{"title":"Packages and SDKs Overview","href":"/v2/packages-and-sdks/packages-and-sdks-overview"}]},{"group":"Laravel","pages":[{"title":"Installation","href":"/v2/packages-and-sdks/laravel/installation"},{"group":"WhatsApp","pages":[{"title":"Send Messages","href":"/v2/packages-and-sdks/laravel/whatsapp/send-messages"},{"title":"Queued Requests","href":"/v2/packages-and-sdks/laravel/whatsapp/queued-requests"},{"title":"Message Management","href":"/v2/packages-and-sdks/laravel/whatsapp/message-management"},{"title":"Chat Status","href":"/v2/packages-and-sdks/laravel/whatsapp/chat-status"},{"title":"Contacts","href":"/v2/packages-and-sdks/laravel/whatsapp/contacts"},{"title":"WhatsApp Webhook Handling \u0026 Events","href":"/v2/packages-and-sdks/laravel/whatsapp/whatsapp-webhook-handling-and-events"},{"title":"WhatsApp Webhook Job","href":"/v2/packages-and-sdks/laravel/whatsapp/whatsapp-webhook-job"}]},{"group":"SMS","pages":[{"title":"Send and Manage SMS Messages","href":"/v2/packages-and-sdks/laravel/sms/send-and-manage-sms-messages"},{"title":"Thread Management","href":"/v2/packages-and-sdks/laravel/sms/thread-management"},{"title":"Heartbeat Management","href":"/v2/packages-and-sdks/laravel/sms/heartbeat-management"},{"title":"SMS Webhook Handling \u0026 Events","href":"/v2/packages-and-sdks/laravel/sms/sms-webhook-handling-and-events"},{"title":"SMS Webhook Job","href":"/v2/packages-and-sdks/laravel/sms/sms-webhook-job"}]},{"group":"OTP","pages":[{"title":"OTP with Laravel","href":"/v2/packages-and-sdks/laravel/otp/otp-with-laravel"},{"title":"Request OTP Code (Laravel SDK)","href":"/v2/packages-and-sdks/laravel/otp/request-otp-code-laravel-sdk"},{"title":"Validate OTP Code (Laravel SDK)","href":"/v2/packages-and-sdks/laravel/otp/validate-otp-code-laravel-sdk"},{"title":"Generate WhatsApp OTP Link with Laravel","href":"/v2/packages-and-sdks/laravel/otp/generate-whatsapp-otp-link-with-laravel"}]}]},{"group":"Node","pages":[{"title":"Node.js WhatsApp and SMS API SDK: Installation","sidebarTitle":"Installation","href":"/v2/packages-and-sdks/node/installation"},{"group":"WhatsApp","pages":[{"title":"Send WhatsApp Messages with Node.js","sidebarTitle":"Send Messages","href":"/v2/packages-and-sdks/node/whatsapp/send-messages"},{"title":"WhatsApp Queued Requests in Node.js","sidebarTitle":"Queued Requests","href":"/v2/packages-and-sdks/node/whatsapp/queued-requests"},{"title":"Manage WhatsApp Messages in Node.js","sidebarTitle":"Message Management","href":"/v2/packages-and-sdks/node/whatsapp/message-management"},{"title":"WhatsApp Typing Indicator in Node.js","sidebarTitle":"Chat Status","href":"/v2/packages-and-sdks/node/whatsapp/chat-status"},{"title":"WhatsApp Contacts and LIDs in Node.js","sidebarTitle":"Contacts","href":"/v2/packages-and-sdks/node/whatsapp/contacts"}]},{"group":"SMS","pages":[{"title":"Send SMS with Node.js: Android SMS Gateway","sidebarTitle":"Send and Manage SMS Messages","href":"/v2/packages-and-sdks/node/sms/send-and-manage-sms-messages"},{"title":"Manage SMS Threads with Node.js","sidebarTitle":"Thread Management","href":"/v2/packages-and-sdks/node/sms/thread-management"},{"title":"SMS Phone Heartbeats with Node.js","sidebarTitle":"Heartbeat Management","description":"Check that your Android SMS gateway phone is online from Node.js: list the heartbeats it sends every 15 minutes, with battery and charging state, in TypeScript.","href":"/v2/packages-and-sdks/node/sms/heartbeat-management"}]},{"group":"OTP","pages":[{"title":"WhatsApp and SMS OTP in Node.js","sidebarTitle":"OTP with Node","href":"/v2/packages-and-sdks/node/otp/otp-with-node"},{"title":"Send an OTP Code with Node.js","sidebarTitle":"Request OTP Code (Node SDK)","description":"Send a one-time password over WhatsApp or SMS from Node.js with the Hypersender OTP API. Set the code length, characters, app name, and expiry in TypeScript.","href":"/v2/packages-and-sdks/node/otp/request-otp-code-node-sdk"},{"title":"Verify an OTP Code with Node.js","sidebarTitle":"Validate OTP Code (Node SDK)","href":"/v2/packages-and-sdks/node/otp/validate-otp-code-node-sdk"},{"title":"WhatsApp OTP Link with Node.js","sidebarTitle":"Generate WhatsApp OTP Link with Node","href":"/v2/packages-and-sdks/node/otp/generate-whatsapp-otp-link-with-node"}]}]}]}]},{"version":"v1","pages":[{"title":"v1","href":"/v1/hypersender/hypersender-api-for-whatsapp-and-sms-messaging"}]}]},"basePath":"","title":"WhatsApp and SMS OTP in Node.js - Hypersender","deploymentId":"dpl_Em2U4NQQ2N2DE3HPbPUJVZLnAtvc","buildId":"dpl_Em2U4NQQ2N2DE3HPbPUJVZLnAtvc","dynamics":[],"chunks":[]}