We have recently been given our Short service code and I want to use SMS as a channel to our 110k subscribers. I have checked with legal who are ok for them to opted in to enable SMS sending but I do not know how to do this in bulk.

I have set up Keywords for Stop subscription and Help but what would be the best recommended way to opt in our existing customers into MobileConnect?

Your help is appreciated....Regards

2 Answers 2


You can use the contacts API for this. The below code works for me. However, there are few things you need to do first, create an ADD Keyword and opt in response and activate it. Send a test sms to a mobile number. Query the SMS Message Tracking DV and get the keywordid for the add keyword. I do not know any other method of finding the keyword id. (May be SF could help).

You need to have all your contacts along with their mobile number in one data extension and then iterate through all records using a for loop in SSJS

Use the below payload and API:

var OPT_IN_STATUS = 2;
var bodyPayload = {
"contactKey": contact.CONTACT_KEY,
"attributeSets": [{
"name": "MobileConnect Subscriptions",
"items": [{
"values": [
{ "name": "Keyword", "value": keywordid},
{ "name": "Mobile Number", "value": MOBILE_NUMBER },
{ "name": "Opt In Status", "value": OPT_IN_STATUS },
{ "name": "Opt Out Status", "value": OPT_OUT_STATUS },
{ "name": "Modified Date", "value": TODAY },
{ "name": "Created Date", "value": TODAY }


  • Question: Where is the SSJS code being run from?
    – Rahul G
    Jan 17, 2021 at 20:27
  • 1
    The SSJS code is being run from the script activity in Automation Studio Jan 18, 2021 at 8:16

The easiest and recommended way to Subscribe (not Resubscribe) customers in bulk is to use Mobile Import within Contact Builder. You can prepare data extension with your subscribers and use it as source for the import. ContactKey, MobileNumber and Local are required for import, so be sure to put it in your source DE.

After creation you can run this activity manual or use it in Automation Studio as scheduled process.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.