Skip to content

Instantly share code, notes, and snippets.

Last active December 22, 2021 08:10
What would you like to do?
<script runat="server">
try {
//API authentication
var authEndpoint = ""; //provide authentication endpoint
var payload = {
clientId: "", //provide Client Id
clientSecret: "" //provide Client Secret
var url = authEndpoint + "/v1/requestToken";
var contentType = "application/json";
var accessTokenRequest = HTTP.Post(url, contentType, Stringify(payload));
if(accessTokenRequest.StatusCode == 200) {
var tokenResponse = Platform.Function.ParseJSON(accessTokenRequest.Response[0]);
var accessToken = tokenResponse.accessToken;
//make a call using the messageContact route
var headerNames = ["Authorization"];
var headerValues = ["Bearer " + accessToken];
var smsEndpoint = ""; //provide rest endpoint
var smsPayload = {
"mobileNumbers": [
"" //pass phone number
"Subscribe": true,
"Resubscribe": true,
"keyword": "" //provide KEYWORD
var smsUrl = smsEndpoint + "/sms/v1/messageContact/xxxxxxxxx/send"; //provide message API key
var sendSMS = HTTP.Post(smsUrl, contentType, Stringify(smsPayload), headerNames, headerValues);
} catch (error) {
Copy link

this code is broken in every way, the HTTP.Post doesn't work at all

Copy link

@rain89146 I just checked and the code works just fine, I even set up a CloudPage with the above code (unfortunately it only works with Polish phone numbers) -
I suggest you take your code to and have someone help you fix it there instead of making vicious comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment