{"templateId":"../../../@theme/Templates/SideBySide.tsx","sharedDataIds":{"sidebar":"sidebar-docs/sdks/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":["split","partial"]},"type":"markdown"},"seo":{"title":"Node.js SDK Reference Docs | Sinch","siteUrl":"https://developers.sinch.com","llmstxt":{"title":"Sinch Developer Documentation","description":"LLMs.txt containing a map of all the documentation files for Sinch.","sections":[{"title":"Numbers API","description":"The Numbers API enables you to search for, view, and activate numbers. It's considered a precursor to other APIs in the Sinch product family. The numbers API can be used in tandem with any of our APIs that perform messaging or calling.","includeFiles":["docs/numbers/**/*.md","docs/numbers/**/*.yaml"],"excludeFiles":["docs/numbers/index.md"]},{"title":"Conversation API","description":"Send and receive messages globally on many popular channels with ease and confidence when using Sinch's Conversation API. Conversation API is the preferred API for sending mobile messages on SMS and other social channels with Sinch. It is a simple API with unified error messages, consistent request payloads, and common webhook payloads that are channel-agnostic.","includeFiles":["docs/conversation/**/*.md","docs/conversation/**/*.yaml"],"excludeFiles":["docs/conversation/index.md"]},{"title":"Voice API","description":"The Voice API works as a big telephony switch. The Voice API handles incoming phone calls (also known as incoming call “legs”), sets up outgoing phone calls (or outgoing call “legs”), and bridges the two. The incoming call leg may come in over a data connection (from a smartphone or web application using the Sinch SDKs) or through a local phone number (from the PSTN network). Similarly, the outgoing call leg can be over data (to another smartphone or web application using the Sinch SDKs) or the PSTN network.","includeFiles":["docs/voice/**/*.md","docs/voice/**/*.yaml"],"excludeFiles":["docs/voice/index.md"]},{"title":"Verification API","description":"The Verification API is a platform for phone number verification. It consists of the API and different software development kits (the Sinch SDKs) that you integrate with your smartphone or web application and cloud based back-end services. Together they enable SMS, Flashcall, Phone Call and Data verification in your application.","includeFiles":["docs/verification/**/*.md","docs/verification/**/*.yaml"],"excludeFiles":["docs/verification/index.md"]},{"title":"Provisioning API","description":"Provisioning API allows you to programmatically set up your senders, accounts and templates on your favorite messaging platforms on the Conversation API. For now, you can create your first WhatsApp channel through Meta's Embedded sign up, you can configure your first SMS App and configure your webhooks. As development continues, we will be adding the most commonly used channels.","includeFiles":["docs/provisioning-api/**/*.md","docs/provisioning-api/**/*.json"],"excludeFiles":["docs/provisioning-api/index.md"]},{"title":"Elastic SIP Trunking API","description":"With Elastic SIP Trunking you can create and manage your SIP trunks and phone numbers programmatically.","includeFiles":["docs/est/**/*.md","docs/est/**/*.yaml"],"excludeFiles":["docs/est/index.md"]},{"title":"Fax API","description":"Send and receive HIPAA compliant faxes on our modern fax platform using our developer-friendly API.","includeFiles":["docs/fax/**/*.md","docs/fax/**/*.yaml"],"excludeFiles":["docs/fax/index.md"]},{"title":"In-app Voice and Video SDK","description":"The In-app Voice and Video SDK enables you to add voice and video calling capabilities directly into your mobile or web application using the Sinch SDKs.","includeFiles":["docs/in-app-calling/**/*.md"],"excludeFiles":["docs/in-app-calling/index.md"]},{"title":"Number Lookup API","description":"The Number Lookup API is designed to provide in-depth information about phone numbers, helping enterprises enhance their communication strategies and prevent fraud. By identifying the type of phone line (for example, mobile, landline, VoIP) and the associated carrier, the API allows businesses to optimize routing, reduce unnecessary costs, and improve customer engagement.","includeFiles":["docs/number-lookup-api-v2/**/*.md","docs/number-lookup-api-v2/**/*.yaml"],"excludeFiles":["docs/number-lookup-api-v2/index.md"]},{"title":"Functions","description":"Serverless compute for voice and messaging. Deploy your code and Sinch routes live calls and messages to it — no infrastructure to run.","includeFiles":["docs/functions/functions/**/*.md","docs/functions/concepts/**/*.md","docs/functions/reference/**/*.md"],"excludeFiles":["docs/functions/functions/index.md"]},{"title":"CLI","description":"One command line for every Sinch API and the full Functions lifecycle — scaffold, run locally, deploy, and manage.","includeFiles":["docs/functions/cli/**/*.md"],"excludeFiles":["docs/functions/cli/index.md"]}]},"description":"See all versions of the Sinch Node.js SDK reference documentation."},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Split","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"sinch-nodejs-sdk","__idx":0},"children":["Sinch Node.js SDK"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"img","attributes":{"src":"https://img.shields.io/badge/node.js-blue.svg","alt":"Node.js"},"children":[]}," ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://www.npmjs.com/package/@sinch/sdk-core"},"children":[{"$$mdtype":"Tag","name":"img","attributes":{"src":"https://img.shields.io/npm/v/@sinch/sdk-core?label=%40sinch%2Fsdk-core&labelColor=FFC658","alt":"Latest Release"},"children":[]}]}," ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/sinch/sinch-sdk-node/blob/main/LICENSE"},"children":[{"$$mdtype":"Tag","name":"img","attributes":{"src":"https://img.shields.io/badge/License-Apache_2.0-blue.svg","alt":"License"},"children":[]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Here you'll find documentation related to the Sinch Node SDK, including how to install it, initialize it, and start developing Node code using Sinch services."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["To use Sinch services, you'll need a Sinch account and access keys. You can sign up for an account and create access keys at ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://dashboard.sinch.com"},"children":["dashboard.sinch.com"]},"."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"table-of-contents","__idx":1},"children":["Table of contents:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#prerequisites"},"children":["Prerequisites"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#documentation"},"children":["Documentation"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#installation"},"children":["Installation"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#supported-apis"},"children":["Supported APIs"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#getting-started"},"children":["Getting started"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#logging"},"children":["Logging"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#handling-exceptions"},"children":["Handling exceptions"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#third-party-dependencies"},"children":["Third-party dependencies"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#examples"},"children":["Examples"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#changelog"},"children":["Changelog"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#license"},"children":["License"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#contact"},"children":["Contact"]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"prerequisites","__idx":2},"children":["Prerequisites"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Node.js ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://nodejs.org/en/download/archive/v18.20.8"},"children":["18.20.8"]},", ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://nodejs.org/en/download/archive/v20.20.2"},"children":["20.20.2"]},", or ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://nodejs.org/en/download/archive/v22.23.0"},"children":["22.23.0"]}," (LTS recommended)"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://www.npmjs.com/"},"children":["npm"]}," or ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://yarnpkg.com/"},"children":["yarn"]}," (recommended)"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://dashboard.sinch.com/"},"children":["Sinch account"]}]}]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Warning"]},":"," ","This SDK is intended for server-side (backend) use only. Do not use it in front-end or client-side applications (web, mobile, or desktop), regardless of language or framework. Doing so can expose your Sinch credentials to end-users."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"documentation","__idx":3},"children":["Documentation"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["For more information on the SDK, refer to the dedicated ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://developers.sinch.com/docs/sdks/node"},"children":["Node SDK documentation"]},"."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["For the SDK's programmatic API surface, see the online ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://developers.sinch.com/sdk/sinch-sdk-node/latest"},"children":["SDK reference"]},"."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["For broader Sinch product documentation, including the underlying REST APIs, visit the official ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://developers.sinch.com/"},"children":["Sinch developer portal"]},"."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"installation","__idx":4},"children":["Installation"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Run the following command to install the SDK:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"npm init\nnpm install @sinch/sdk-core\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["If you want to use yarn as a package manager, run:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"npm install --global yarn\nyarn init\nyarn add @sinch/sdk-core\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"supported-apis","__idx":5},"children":["Supported APIs"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"API Category"},"children":["API Category"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"API Name"},"children":["API Name"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Messaging"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://developers.sinch.com/docs/conversation"},"children":["Conversation API"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://developers.sinch.com/docs/sms"},"children":["SMS API"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Voice and Video"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://developers.sinch.com/docs/voice"},"children":["Voice API"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://developers.sinch.com/docs/est"},"children":["Elastic SIP Trunking API"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Numbers"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://developers.sinch.com/docs/numbers"},"children":["Numbers API"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Verification"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://developers.sinch.com/docs/verification"},"children":["Verification API"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://developers.sinch.com/docs/number-lookup-api-v2"},"children":["Number Lookup API"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Fax"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://developers.sinch.com/docs/fax"},"children":["Fax API"]}]}]}]}]}]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Note:"]}," The SMS API is end-of-sale. New integrations should use the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://developers.sinch.com/docs/conversation/"},"children":["Conversation API"]}," instead, which supports SMS and many other channels."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"getting-started","__idx":6},"children":["Getting started"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The SDK is split across npm packages. Import ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["SinchClient"]}," from ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/sinch/sinch-sdk-node/blob/main/packages/sdk-core"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["@sinch/sdk-core"]}]},", which bundles all API packages. Each API lives in its own package, and all packages share the HTTP layer from ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/sinch/sinch-sdk-node/blob/main/packages/sdk-client"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["@sinch/sdk-client"]}]},"."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"client-initialization","__idx":7},"children":["Client initialization"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["To start using the SDK, initialize the main client class. This client gives you access to all the SDK services:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"typescript","header":{"controls":{"copy":{}}},"source":"import { SinchClient } from '@sinch/sdk-core';\n\n// Warning: not all APIs support project authentication. Check the section for each API before using this snippet.\nconst sinch = new SinchClient({\n  projectId: process.env.SINCH_PROJECT_ID,\n  keyId: process.env.SINCH_KEY_ID,\n  keySecret: process.env.SINCH_KEY_SECRET,\n});\n","lang":"typescript"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Get ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["project_id"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["key_id"]}," and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["key_secret"]}," from the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://dashboard.sinch.com/settings/access-keys"},"children":["Access keys"]}," page in your Sinch dashboard (",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["key_secret"]}," is shown only once, at creation time). It's highly recommended to not hardcode these credentials: load them from environment variables for local development, and from a secret manager in production."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["This snippet is the common starting point for every API. Some APIs have a different initialization or need extra parameters (for example, a region), see the section for each API."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"conversation-api","__idx":8},"children":["Conversation API"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The Conversation API is regionalized. To use this API, the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["conversation_region"]}," parameter is required:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"typescript","header":{"controls":{"copy":{}}},"source":"import { SinchClient } from '@sinch/sdk-core';\n\nconst sinch = new SinchClient({\n  projectId: process.env.SINCH_PROJECT_ID,\n  keyId: process.env.SINCH_KEY_ID,\n  keySecret: process.env.SINCH_KEY_SECRET,\n  conversationRegion: 'us',\n});\n","lang":"typescript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"callbacks","__idx":9},"children":["Callbacks"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The Conversation API delivers asynchronous callbacks to the webhook URL you configure for your app in the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://dashboard.sinch.com/convapi/apps"},"children":["Conversation dashboard"]},". ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["validateAuthenticationHeader"]}," confirms a request comes from Sinch and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["parseEvent"]}," turns its payload into a typed callback object; ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["headers"]}," and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["rawBody"]}," are the incoming request's headers and raw body:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"typescript","header":{"controls":{"copy":{}}},"source":"import { ConversationCallbackWebhooks } from '@sinch/sdk-core';\n\nconst callbackWebhooks = new ConversationCallbackWebhooks(process.env.SINCH_CONVERSATION_APP_SECRET);\n\nconst validated = callbackWebhooks.validateAuthenticationHeader(request.headers, request.rawBody);\nif (!validated) {\n  return res.status(401).send('Invalid webhook signature');\n}\n\nconst event = callbackWebhooks.parseEvent(request.body);\n","lang":"typescript"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["SINCH_CONVERSATION_APP_SECRET"]}," is the app secret set per app in the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://dashboard.sinch.com/convapi/apps"},"children":["Conversation dashboard"]},". ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["parseEvent"]}," works without validating the request, but then its origin can't be verified, so validating is recommended in production."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["You can find a complete example in the Conversation section of ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/sinch/sinch-sdk-node/blob/main/examples/webhooks/src/controller/app.controller.ts#L41-L61"},"children":["examples/webhooks"]},"."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"sms-api","__idx":10},"children":["SMS API"]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Warning:"]}," the SMS API is end-of-sale. For new integrations, prefer the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#conversation-api"},"children":["Conversation API"]},"."]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The SMS API is regionalized: set ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["sms_region"]}," to the region where your SMS account is hosted. The accepted values are ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["us"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["eu"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["au"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["br"]}," and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ca"]},", and the region also determines which credentials you can use:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Project access keys"]}," — available only in the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["us"]}," and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["eu"]}," regions. Use the same ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["project_id"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["key_id"]}," and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["key_secret"]}," as the common client, plus ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["sms_region"]},":"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"typescript","header":{"controls":{"copy":{}}},"source":"import { SinchClient } from '@sinch/sdk-core';\n\nconst sinch = new SinchClient({\n  projectId: process.env.SINCH_PROJECT_ID,\n  keyId: process.env.SINCH_KEY_ID,\n  keySecret: process.env.SINCH_KEY_SECRET,\n  smsRegion: 'us',\n});\n","lang":"typescript"},"children":[]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["SMS authentication for new projects"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Projects created after the SMS API end-of-sale (",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["15/04/26"]},") cannot use project access keys — the SMS API requests return ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["401 Unauthorized"]},"."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["If you encounter this issue, consider the following options:"]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Use service plan credentials (",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["service_plan_id"]}," + ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["sms_api_token"]},")"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Use the Conversation API, which works with project access keys."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Contact your account manager"]}]}]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Service plan"]}," — available in all regions (",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["us"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["eu"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["au"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["br"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ca"]},"). Use a ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["service_plan_id"]}," and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["sms_api_token"]},", both available on the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://dashboard.sinch.com/sms/api/services"},"children":["Service APIs dashboard"]},":"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"typescript","header":{"controls":{"copy":{}}},"source":"import { SinchClient } from '@sinch/sdk-core';\n\nconst sinch = new SinchClient({\n  servicePlanId: process.env.SINCH_SERVICE_PLAN_ID,\n  apiToken: process.env.SINCH_API_TOKEN,\n  smsRegion: 'au',\n});\n","lang":"typescript"},"children":[]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Note:"]}," if you use both the SMS and the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#conversation-api"},"children":["Conversation API"]}," from the same client, set ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["sms_region"]}," and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["conversation_region"]}," to the same region. Mismatched regions cause delivery failures."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"callbacks-1","__idx":11},"children":["Callbacks"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The SMS API delivers asynchronous callbacks to a webhook URL set per batch with the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["callback_url"]}," parameter on the send, update and replace operations. ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["validateAuthenticationHeader"]}," confirms a request comes from Sinch and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["parseEvent"]}," turns its payload into a typed callback object; ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["headers"]}," and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["rawBody"]}," are the incoming request's headers and raw body:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"typescript","header":{"controls":{"copy":{}}},"source":"import { SmsCallbackWebhooks } from '@sinch/sdk-core';\n\nconst callbackWebhooks = new SmsCallbackWebhooks(process.env.SINCH_SMS_APP_SECRET);\n\nconst validated = callbackWebhooks.validateAuthenticationHeader(request.headers, request.rawBody);\nif (!validated) {\n  return res.status(401).send('Invalid webhook signature');\n}\n\nconst event = callbackWebhooks.parseEvent(request.body);\n","lang":"typescript"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Signature authentication for SMS callbacks must be enabled for your account by your account manager. Until it is activated, signature headers will not be present and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["parseEvent"]}," can be called directly without signature validation. See the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://developers.sinch.com/docs/sms/api-reference/sms/tag/Webhooks/#tag/Webhooks/section/Callbacks"},"children":["SMS callbacks documentation"]},"."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["You can find a complete example in ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/sinch/sinch-sdk-node/blob/main/examples/webhooks"},"children":["examples/webhooks"]},"."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"voice-api","__idx":12},"children":["Voice API"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The Voice API does not use project access keys. It authenticates with an ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["application_key"]}," and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["application_secret"]},", which you create per application in the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://dashboard.sinch.com/voice/apps"},"children":["Voice dashboard"]},". Optionally set ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["voice_region"]}," to select the regional endpoint:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"typescript","header":{"controls":{"copy":{}}},"source":"import { SinchClient } from '@sinch/sdk-core';\n\nconst sinch = new SinchClient({\n  applicationKey: process.env.SINCH_APPLICATION_KEY,\n  applicationSecret: process.env.SINCH_APPLICATION_SECRET,\n  voiceRegion: 'euc1',\n});\n","lang":"typescript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"callbacks-2","__idx":13},"children":["Callbacks"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The Voice API delivers asynchronous callbacks to the callback URL you configure for your application in the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://dashboard.sinch.com/voice/apps"},"children":["Voice dashboard"]},". ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["validateAuthenticationHeader"]}," confirms a request comes from Sinch and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["parseEvent"]}," turns its payload into a typed callback object; ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["headers"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["rawBody"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["path"]}," and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["method"]}," are the incoming request's headers, raw body, path and HTTP method:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"typescript","header":{"controls":{"copy":{}}},"source":"import { VoiceCallbackWebhooks } from '@sinch/sdk-core';\n\nconst callbackWebhooks = new VoiceCallbackWebhooks({\n  applicationKey: process.env.SINCH_APPLICATION_KEY,\n  applicationSecret: process.env.SINCH_APPLICATION_SECRET,\n});\n\nconst validated = callbackWebhooks.validateAuthenticationHeader(\n  request.headers,\n  request.rawBody,\n  request.path,\n  request.method,\n);\nif (!validated) {\n  return res.status(401).send('Invalid authorization');\n}\n\nconst event = callbackWebhooks.parseEvent(request.body);\n","lang":"typescript"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["You can find a complete example in ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/sinch/sinch-sdk-node/blob/main/examples/webhooks"},"children":["examples/webhooks"]},"."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"verification-api","__idx":14},"children":["Verification API"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The Verification API uses the same application credentials as the Voice API. Create an application in the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://dashboard.sinch.com/verification/apps"},"children":["Verification dashboard"]},":"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"typescript","header":{"controls":{"copy":{}}},"source":"import { SinchClient } from '@sinch/sdk-core';\n\nconst sinch = new SinchClient({\n  applicationKey: process.env.SINCH_APPLICATION_KEY,\n  applicationSecret: process.env.SINCH_APPLICATION_SECRET,\n});\n","lang":"typescript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"callbacks-3","__idx":15},"children":["Callbacks"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The Verification API delivers asynchronous callbacks to the callback URL you configure for your application in the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://dashboard.sinch.com/verification/apps"},"children":["Verification dashboard"]},". ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["validateAuthenticationHeader"]}," confirms a request comes from Sinch and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["parseEvent"]}," turns its payload into a typed callback object; ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["headers"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["rawBody"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["path"]}," and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["method"]}," are the incoming request's headers, raw body, path and HTTP method:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"typescript","header":{"controls":{"copy":{}}},"source":"import { VerificationCallbackWebhooks } from '@sinch/sdk-core';\n\nconst callbackWebhooks = new VerificationCallbackWebhooks({\n  applicationKey: process.env.SINCH_APPLICATION_KEY,\n  applicationSecret: process.env.SINCH_APPLICATION_SECRET,\n});\n\nconst validated = callbackWebhooks.validateAuthenticationHeader(\n  request.headers,\n  request.rawBody,\n  request.path,\n  request.method,\n);\nif (!validated) {\n  return res.status(401).send('Invalid authorization');\n}\n\nconst event = callbackWebhooks.parseEvent(request.body);\n","lang":"typescript"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["You can find a complete example in ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/sinch/sinch-sdk-node/blob/main/examples/webhooks"},"children":["examples/webhooks"]},"."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"elastic-sip-trunking-api","__idx":16},"children":["Elastic SIP Trunking API"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The Elastic SIP Trunking API needs no extra parameters, use the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#client-initialization"},"children":["common client"]}," shown above."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"numbers-api","__idx":17},"children":["Numbers API"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The Numbers API needs no extra parameters, use the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#client-initialization"},"children":["common client"]}," shown above."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"callbacks-4","__idx":18},"children":["Callbacks"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The Numbers API delivers asynchronous callbacks to the callback URL you configure through ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["numbers.callbacks"]},". ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["validateAuthenticationHeader"]}," confirms a request comes from Sinch and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["parseEvent"]}," turns its payload into a typed callback object; ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["headers"]}," and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["rawBody"]}," are the incoming request's headers and raw body:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"typescript","header":{"controls":{"copy":{}}},"source":"import { NumbersCallbackWebhooks } from '@sinch/sdk-core';\n\nconst callbackWebhooks = new NumbersCallbackWebhooks(process.env.SINCH_NUMBERS_CALLBACK_SECRET);\n\nconst validated = callbackWebhooks.validateAuthenticationHeader(request.headers, request.rawBody);\nif (!validated) {\n  return res.status(401).send('Invalid signature');\n}\n\nconst event = callbackWebhooks.parseEvent(request.body);\n","lang":"typescript"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["SINCH_NUMBERS_CALLBACK_SECRET"]}," is the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["hmacSecret"]}," returned by ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["numbers.callbacks.get()"]},". ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["parseEvent"]}," works without validating the request, but then its origin can't be verified, so validating is recommended in production."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["You can find a complete example in ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/sinch/sinch-sdk-node/blob/main/examples/webhooks"},"children":["examples/webhooks"]},"."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"number-lookup-api","__idx":19},"children":["Number Lookup API"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The Number Lookup API needs no extra parameters, use the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#client-initialization"},"children":["common client"]}," shown above."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"fax-api","__idx":20},"children":["Fax API"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The Fax API needs no extra parameters, use the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#client-initialization"},"children":["common client"]}," shown above."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"callbacks-5","__idx":21},"children":["Callbacks"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The Fax API delivers asynchronous callbacks to the incoming webhook URL you configure per service in the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://dashboard.sinch.com/fax/services"},"children":["Fax dashboard"]},". ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["parseEvent"]}," turns the payload into a typed callback object:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"typescript","header":{"controls":{"copy":{}}},"source":"import { FaxCallbackWebhooks } from '@sinch/sdk-core';\n\nconst event = FaxCallbackWebhooks.parseEvent(request.body);\n","lang":"typescript"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["No request signature validation is implemented for the Fax API. You can find a complete example in ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/sinch/sinch-sdk-node/blob/main/examples/webhooks"},"children":["examples/webhooks"]},"."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"your-first-request","__idx":22},"children":["Your first request"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Once your client is configured, you can send your first message. The example below uses the Conversation API to send a simple text message over SMS. Replace CONVERSATION_APP_ID with your app ID and RECIPIENT_PHONE_NUMBER with the recipient's phone number:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"typescript","header":{"controls":{"copy":{}}},"source":"const response = await sinch.conversation.messages.send({\n  sendMessageRequestBody: {\n    app_id: CONVERSATION_APP_ID,\n    message: {\n      text_message: {\n        text: '[Node.js SDK: Conversation Message] Sample text message',\n      },\n    },\n    recipient: {\n      identified_by: {\n        channel_identities: [\n          {\n            channel: 'SMS',\n            identity: 'RECIPIENT_PHONE_NUMBER',\n          },\n        ],\n      },\n    },\n  },\n});\n","lang":"typescript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"logging","__idx":23},"children":["Logging"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The SDK supports configurable logging through an optional ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["logger"]}," property on ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["SinchClient"]}," initialization parameters. Logging is handled by ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["@sinch/sdk-client"]},", the shared HTTP layer used by all API packages. Method contracts and log levels are defined on the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/sinch/sinch-sdk-node/blob/main/packages/sdk-client/src/logger/logger-types.ts"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Logger"]}]}," interface."]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Without a custom logger"]},": Omit ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["logger"]}," to send SDK output to ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["console"]},", or pass ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["logger: null"]}," to suppress it."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Lazy messages"]},": Each method accepts a ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/sinch/sinch-sdk-node/blob/main/packages/sdk-client/src/logger/logger-types.ts"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["LogMessage"]}]},", a ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["string"]}," or ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["() => string"]},". Pass a function to defer building the message until your logger reads it; level-aware loggers can then skip that work when the level is disabled."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Custom loggers"]},": Plug in any compatible logger, for example ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://www.npmjs.com/package/winston"},"children":["Winston"]},", and route SDK messages into your existing logging stack, format, and transports."]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["For a runnable example using Winston, see ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/sinch/sinch-sdk-node/blob/main/examples/snippets/sdk-client/logger.js"},"children":["examples/snippets/sdk-client/logger.js"]},"."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"handling-exceptions","__idx":24},"children":["Handling exceptions"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Failed API calls throw typed errors from ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["@sinch/sdk-core"]},". The SDK validates every response automatically and raises an exception when the HTTP status is not successful or when the response body is empty or invalid."]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Error class"},"children":["Error class"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"When it is thrown"},"children":["When it is thrown"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["RequestFailedError"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["The API returned a non-success HTTP status (",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["statusCode"]}," and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["data"]}," are available on the error)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["EmptyResponseError"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["The response is missing or empty"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ResponseJSONParseError"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["The response body could not be parsed as JSON"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["GenericError"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Other SDK-level errors"]}]}]}]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"typescript","header":{"controls":{"copy":{}}},"source":"try {\n  await sinchClient.sms.batches.send({\n  sendSMSRequestBody: {\n    body: 'Hello from the Sinch Node.js SDK!',\n    to: ['+12065550100'],\n    from: 'YOUR_sender_number',\n  },\n});\n} catch (error) {\n  if (error instanceof RequestFailedError) {\n    console.error(`Request failed (${error.statusCode}):`, error.data);\n  } else {\n    console.error(error);\n  }\n}\n","lang":"typescript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"third-party-dependencies","__idx":25},"children":["Third-party dependencies"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The SDK relies on the following third-party dependencies:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://www.npmjs.com/package/node-fetch"},"children":["node-fetch"]},": HTTP client used to send API requests."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://www.npmjs.com/package/form-data"},"children":["form-data"]},": Multipart form-data support for file uploads."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"examples","__idx":26},"children":["Examples"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["You can find:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["a JS example of each request in the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/sinch/sinch-sdk-node/blob/main/examples/snippets"},"children":["examples/snippets"]}," folder."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["getting started guides for specific use cases in the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/sinch/sinch-sdk-node/blob/main/examples/getting-started"},"children":["examples/getting-started"]}," folder."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["a TS example of each request in the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/sinch/sinch-sdk-node/blob/main/examples/simple-examples"},"children":["examples/simple-examples"]}," folder."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["a Nest.js application for handling Sinch webhook callbacks in the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/sinch/sinch-sdk-node/blob/main/examples/webhooks"},"children":["examples/webhooks"]}," folder."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["examples of integrated flows in the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/sinch/sinch-sdk-node/blob/main/examples/integrated-flows-examples"},"children":["examples/integrated-flows-examples"]}," folder."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"changelog","__idx":27},"children":["Changelog"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["For information about the latest changes in the SDK, please refer to the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/sinch/sinch-sdk-node/blob/main/packages/sdk-core/CHANGELOG.md"},"children":["CHANGELOG"]}," file."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"license","__idx":28},"children":["License"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["This project is licensed under the Apache License. See the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/sinch/sinch-sdk-node/blob/main/LICENSE"},"children":["LICENSE"]}," file for the license text."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"contact","__idx":29},"children":["Contact"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Developer Experience engineering team: ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"mailto:team-developer-experience@sinch.com"},"children":["team-developer-experience@sinch.com"]}]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"versions","__idx":30},"children":["Versions"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://developers.sinch.com/sdk/sinch-sdk-node/1.5.0/index.html"},"children":["1.5.0 (latest)"]}]}]}]}]},"headings":[{"value":"Sinch Node.js SDK","id":"sinch-nodejs-sdk","depth":1},{"value":"Table of contents:","id":"table-of-contents","depth":2},{"value":"Prerequisites","id":"prerequisites","depth":2},{"value":"Documentation","id":"documentation","depth":2},{"value":"Installation","id":"installation","depth":2},{"value":"Supported APIs","id":"supported-apis","depth":2},{"value":"Getting started","id":"getting-started","depth":2},{"value":"Client initialization","id":"client-initialization","depth":3},{"value":"Conversation API","id":"conversation-api","depth":3},{"value":"Callbacks","id":"callbacks","depth":4},{"value":"SMS API","id":"sms-api","depth":3},{"value":"Callbacks","id":"callbacks-1","depth":4},{"value":"Voice API","id":"voice-api","depth":3},{"value":"Callbacks","id":"callbacks-2","depth":4},{"value":"Verification API","id":"verification-api","depth":3},{"value":"Callbacks","id":"callbacks-3","depth":4},{"value":"Elastic SIP Trunking API","id":"elastic-sip-trunking-api","depth":3},{"value":"Numbers API","id":"numbers-api","depth":3},{"value":"Callbacks","id":"callbacks-4","depth":4},{"value":"Number Lookup API","id":"number-lookup-api","depth":3},{"value":"Fax API","id":"fax-api","depth":3},{"value":"Callbacks","id":"callbacks-5","depth":4},{"value":"Your first request","id":"your-first-request","depth":3},{"value":"Logging","id":"logging","depth":2},{"value":"Handling exceptions","id":"handling-exceptions","depth":2},{"value":"Third-party dependencies","id":"third-party-dependencies","depth":2},{"value":"Examples","id":"examples","depth":2},{"value":"Changelog","id":"changelog","depth":2},{"value":"License","id":"license","depth":2},{"value":"Contact","id":"contact","depth":2},{"value":"Versions","id":"versions","depth":2}],"frontmatter":{"seo":{"title":"Node.js SDK Reference Docs | Sinch","description":"See all versions of the Sinch Node.js SDK reference documentation."},"template":"../../../@theme/Templates/SideBySide.tsx"},"lastModified":"2026-07-17T14:30:25.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/docs/sdks/node/sdk-reference-docs","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}