# Send an SMS Message with Node.js SDK

Note:
Before you can get started, you need the following already set up:

- 
- [NPM](https://www.npmjs.com/) and a familiarity with how to install packages.
- [Node.js](https://nodejs.org/en/) and a familiarity with how to create a new app.


Learn how to quickly send SMS messages in a Node.js application with the Sinch Node.js SDK.

Steps:
1. [Set up](#set-up-your-nodejs-application) your Node.js application
2. [Send](#send-your-first-sms-message) your first SMS message


## Set up your Node.js application

To quickly get started setting up a simple client application using the Node SDK:

1. If you haven't already, clone the [sinch-sdk-node-quickstart](https://github.com/sinch/sinch-sdk-node-quickstart) repository.
2. Navigate to the `templates/client` folder.
3. Open a command prompt or terminal and run the following command to install the necessary dependencies:

```shell
npm install
```
4. Open the `.env` [file](https://github.com/sinch/sinch-sdk-node-quickstart/blob/main/templates/client/.env). Using the [access key credentials](https://dashboard.sinch.com/settings/access-keys) from your Sinch Build Dashboard, populate the following fields with your values:
| Field | Description |
|  --- | --- |
| SINCH_PROJECT_ID | The unique ID of your Project. |
| SINCH_KEY_ID | The unique ID of your access key. |
| SINCH_KEY_SECRET | The secret that goes with your access key.  **Note:** For security reasons, this secret is only visible right after access key creation. |
If you're sending SMS messages, ensure you set your region in the `SMS_REGION` field.
5. Save the file.


### Modify your application

1. Navigate to the `/templates/client/src/sms/` folder and open the `snippet.js` file. Replace the existing content within that file with the `snippet.js` code provided on this page. That code is also found [at this location in the repo](https://github.com/sinch/sinch-sdk-node-snippets/blob/main/snippets/sms/batches/send/snippet.js) if you want to just replace the file.

```javascript snippet.js
// eslint-disable-next-line no-unused-vars
import { Sms, SmsService } from '@sinch/sdk-core';

/** @param {SmsService} smsService */
export const execute = async (smsService) => {

  const from = 'YOUR_sinch_phone_number';
  const recipient = 'YOUR_recipient_phone_number';
  const body = 'This is a test SMS message using the Sinch Node.js SDK.';

  /** @type {Sms.SendSMSRequestData} */
  const requestData= {
    sendSMSRequestBody: {
      type: 'mt_text',
      from,
      to: [recipient],
      body,
    },
  };

  const response = await smsService.batches.send(requestData);

  console.log(`Response:\n${JSON.stringify(response, null, 2)}`);
};
```
2. The code provided in **snippet.js** includes default parameters. If you want, you can replace the following values for these parameters with your own values:
| Parameter | Your value |
|  --- | --- |
| `YOUR_sinch_phone_number` | Any number you've assigned to your Sinch account. Find the number on your Sinch [dashboard](https://dashboard.sinch.com/sms/api/rest) by clicking the service plan ID link and scrolling to the bottom of the page. |
| `YOUR_recipient_phone_number` | The phone number to which you want to send the test SMS message. |
Ensure you save your file.


## Send your first SMS message

Now you can execute the code and send your test SMS message.

Run the following command:

```shell
node src/app.js
```

You should receive a text to the phone number you entered and you'll see a response in your terminal or command prompt. You did it!

## Next steps

The code you used in the `snippet.js` file sends a POST request to the Sinch API `/batches` endpoint to send the SMS message. Click [here to learn more about the batches endpoint](/docs/sms/api-reference/sms/batches).

- [Learn how to receive and reply to an incoming SMS](/docs/sms/getting-started/node-sdk/handle-incoming).


## Additional resources

- Explore the [API specification](/docs/sms/api-reference/) to test more endpoints.