Create groups tutorial continued
Connect your data
Connect your own database. Because data comes in all shapes and sizes, we'll leave this step to you!
In our sample, we'll add data directly to the request body for testing.
Tip:
As you prepare your contacts data, keep in mind the
members
body parameter is your user's phone number (msisdn
) and it must be in E.164 format (country code, area code, and no dashes in the phone number).Add the code to your file
Copy and paste the "Create a group" code into yourindex.mjs
file.Fill in your parameters
- Assign your values to the following parameters:
Parameter | Your value |
---|---|
servicePlanId | 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 | Here is where you will list the phone numbers (MSISDNs) you want in the group as strings in an array. The country code must preceed the number. The intial list is limited to 10,000 numbers. |
name | The name of the group you're creating. It must be between 1-20 characters. |
- Save the file.
Run the code
- Run the following command in your terminal/command prompt to create a group:
node index.mjs
- Copy the
id
of the group, You'll need it later.
Successful Response
A successful response will look like this:
{
id: '01XXJ3HFXXT3CA0X1NGZCXXXXX',
name: 'March Signups',
created_at: '2022-04-13T18:38:59.719Z',
modified_at: '2022-04-13T18:38:59.719Z',
child_groups: []
}
Repeat!
Now following the same process, make another call to the API to create an additional group.
In the next steps, we'll turn these groups into child groups of a parent group.
Go back