Name an SMS batch with Node.js continued
Name your batch
Assigning a name to a batch can be done in the/batches
endpoint. The main parameter we're looking at is client_reference
for naming batches.If you're looking to set your own ID for a batch, you're in the right place.
Add the code to your file
Copy and paste the "Name your batch" code into yournameBatch.mjs
file.Fill in your parameters
- Assign your values to the following parameters:
Parameter | Your value |
---|---|
SERVICE_PLAN_ID | The service plan ID found on your Sinch Customer Dashboard. SMS > APIs > REST configuration |
API_TOKEN | The API token found on your Sinch Customer dashboard. SMS > APIs > REST configuration > Click Show to reveal your API token. |
SINCH_NUMBER | A free test number or any Sinch virtual number you've rented. Find the number on your Sinch Customer Dashboard by clicking the service plan ID link and scrolling to the bottom of the page. |
TO_NUMBER | Your receipient number(s). The phone number(s) to which you want to send the test SMS message. Even if you only send to one number, it is inside an array. |
client_reference | Here is where you'll set your own batch ID or name. It can be anything you want, so long as it's a string. Any identifier you'd like to provide will work. It will show in the delivery report/callback of this batch. The limitation is 2048 characters. |
- Save the file.
Run the code
- Run the following command in your terminal/command prompt to create a group:
node nameBatch.mjs
Successful Response
A successful response will look like this:
{
"id": "XXXXX6621VXXXXX19Z8PMXXXXX",
"to": [
15551231234,
15551256344
],
"from": 15551231234,
"canceled": false,
"body": "Testing. Testing. Is this thing on?",
"type": "mt_text",
"created_at": "2022-08-24T14:15:22Z",
"modified_at": "2022-08-24T14:15:22Z",
"delivery_report": "full",
"send_at": "2022-08-24T14:15:22Z",
"expire_at": "2022-08-26T14:15:22Z",
"callback_url": "http://my.url.com",
"client_reference": "YOUR_ID_or_name_shows_here",
}
client_reference
parameter. Kneadless to say, this batch is baked. Great job!Go BackNext steps
- Learn how to search a list of delivery reports for your named batch
- Find other useful code samples in our API reference.
- Check out another tutorial.