Rename a group with Node.js continued
Have a group already?
If you have an existing group in mind, skip ahead to the next section.
Name a group
This part shows how to create a group and name it simultaneously. First things first, any string less than or equal to 20 characters is allowable.
To name a group of contacts, you can either do it during intial group creation or you can update the group to include a name. We have included both code samples.
The parameter we're working with for group naming is aptly calledname
.Create a file
This part covers how to name a group at the time the group is created.
- Create a new file called
nameGroup.mdx
.
- Paste the code in from the "Name a group" file.
- Assign your values to the following parameters:
Parameter | Your value |
---|---|
YOUR_service_plan_id | The service plan ID found on your Sinch Customer Dashboard. SMS > APIs > REST configuration |
YOUR_API_token | The API token found on your Sinch Customer dashboard. SMS > APIs > REST configuration > Click Show to reveal your API token. |
members | In this example, descriptions are listed. You'll want to replace these with phone numbers (MSISDNs) including the country code. With or without the leading + . |
name | The name you'd like to give your group of contacts. Example: name: "Spelunking Group" |
- Run the code
node nameGroup.mjs
Response
Be sure to copy the groupid
if you plan on updating the name of the group in the next step.{
"id": "XXXXX6621XXXXX119Z8PMXXXXX",
"name": "Spelunking Group",
"size": 2,
"created_at": "2022-08-24T14:15:22Z",
"modified_at": "2022-08-24T14:15:22Z",
}