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 your nameBatch.mjs file.

Fill in your parameters

  1. Assign your values to the following parameters:
ParameterYour value
SERVICE_PLAN_IDThe service plan ID found on your Sinch Customer Dashboard. SMS > APIs > REST configuration
API_TOKENThe API token found on your Sinch Customer dashboard. SMS > APIs > REST configuration > Click Show to reveal your API token.
SINCH_NUMBERA 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_NUMBERYour 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_referenceHere 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.
  1. Save the file.

Run the code

  1. Run the following command in your terminal/command prompt to create a group:
    Copy
    Copied
    node nameBatch.mjs

Successful Response

A successful response will look like this:

Copy
Copied
{
  "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",
}
You've named your batch using the client_reference parameter. Kneadless to say, this batch is baked. Great job!Go Back

Next steps

We'd love to hear from you!
Rate this content:
Still have a question?
 
Ask the community.