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
    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
  • That was very helpful. To add to the response, I found the keywordId to be also present in the table _SMSSubscriptionLog on the field SubscriptionDefinitionID. It seems that there is only one value per organization. More information around that field is provided here mateuszdabrowski.pl/docs/config/sfmc-mobile-connect-data-views/…. Also I don't know what the CONTACT_KEY is about, but it appears that it can be totally random. The real relevant key is the MOBILE_NUMBER. Oct 31, 2023 at 18:02

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .