Function Name
Gettoken(client_id,client_secret,account_id,OAuth2URL)
Function Parameters
Name Type Required Description
client_id String Required In order to interact with Marketing cloud APIs
client_secret String with authentication, we can achieve using -
Client ID and Client Secret
account_id Integer Required Account ID is MID of Business Unit
OAuth2URL String Required To generate the bearer token
Example request
function Gettoken(client_id,client_secret,account_id,OAuth2URL) {
var payload = '{"grant_type":"client_credentials",';
payload += '"client_id":"'+client_id+'",';
payload += '"client_secret":"'+client_secret+'",';
payload += '"account_id":"'+account_id+'"}';
var contentType = 'application/json';
var accessTokenResult = HTTP.Post(OAuth2URL, contentType, payload);
var tokenObj = Platform.Function.ParseJSON(accessTokenResult["Response"][0]);
var accessToken = tokenObj.access_token;
var auth = ["Bearer " + accessToken];
return auth;
Write(accessToken);
}
Example Response
GET
https://www.YOUR_SUBDOMAIN.rest.marketingcloudapis.com/platform/v1/endpoints
Accept: application/json
Authorization: Bearer YOUR_ACCESS_TOKEN
Function Name
searchByAddress(EmailID,EmailCount,SearchbyAddressUrl,client_id,client_secret,acc
ount_id,OAuth2URL)
API Name
POST /contacts/v1/addresses/email/search
Resource Description:
Retrieves the Contact key for one or more email channel addresses.
End points and Methods
POST /addresses/email/search
Function Parameters
Name Type Required Description
EmailID String Required Email address to be validated
EmailCount Integer Required Number of contact keys associated
with an email channel address.
SearchbyAddressUrl String Required A RESTful API is an architectural style
Required for an API that uses HTTP's requests to
client_id String Required access and use data.
client_secret String Required In order to interact with Marketing
cloud APIs with authentication, we can
account_id Integer achieve using - Client ID and Client
OAuth2URL String Secret
Account ID is MID of BU
To generate the bearer token
Example request
function
searchByAddress(EmailID,EmailCount,SearchbyAddressUrl,client_id,client_secret,acc
ount_id,OAuth2URL)
{
var token=Gettoken(client_id,client_secret,account_id,OAuth2URL);
token=token[0]
var payload =
'{"ChannelAddressList":["'+EmailID+'"],"MaximumCount":"'+EmailCount+'"}';
var req = new Script.Util.HttpRequest(SearchbyAddressUrl);
req.emptyContentHandling = 0;
req.retries = 2;
req.continueOnError = true;
req.contentType = "application/json";
req.setHeader("Authorization", token);
req.method = "POST";
req.postData = payload;
var response = req.send();
Write(Stringify(response.content));
}
Example Response
{
"channelAddressResponseEntities": [
{
"contactKeyDetails": [
{
"contactKey": "[email protected]",
"createDate": "2014-11-15T11:51:00"
}
],
"channelAddress": "[email protected]"
}
],
"requestServiceMessageID": "unique-UUID-provided-by-SFMC",
"resultMessages": [],
"serviceMessageID": "unique-UUID-provided-by-SFMC" }
Function Name
deleteStatusbyID(DeleteStatusUrl,client_id,client_secret,account_id, OAuth2URL)
API Name
GET /contacts/v1/contacts/actions/delete/status?operationID=
Resource Description:
Retrieves status of contact deletion operation by operation ID.
Endpoints and Methods:
GET /contacts/actions/delete/status?operationID=3551271'
Function Parameters
Name Type Description
DeleteStatusUrl String Required A RESTful API is an architectural style for an API
that uses HTTP's requests to access and use
client_id String Required data.
String Required In order to interact with Marketing cloud APIs
client_secret Integer Required with authentication, we can achieve using -
String Required Client ID and Client Secret
account_id Account ID is MID of Business Unit
OAuth2URL To generate the bearer token
Usage:
Use the OperationID value returned by a contact delete call in the query string
parameter. Since the contact delete call has 2 phases, there is a response example
for each of the 2 phases.
Example request
function deleteStatusbyID(DeleteStatusUrl,client_id,client_secret,account_id,
OAuth2URL)
{
var token=Gettoken(client_id,client_secret,account_id,OAuth2URL);
token=token[0]
var req = new Script.Util.HttpRequest(DeleteStatusUrl);
req.emptyContentHandling = 0;
req.retries = 2;
req.continueOnError = true;
req.contentType = "application/json";
req.setHeader("Authorization", token);
req.method = "GET";
var response = req.send();
Write(Stringify(response.content));
}
Example Response
{
"operation": {
"listTypeID": 5,
"listIdentifier": "037c2811-ce62-4381-b3d2-1936e51fbf4d",
"listKey": "037c2811-ce62-4381-b3d2-1936e51fbf4d",
"expectedListCount": 1,
"deleteType": "ContactAndAttributes",
"deleteListOnCompleted": false,
"operationID": 2,
"eID": 12345,
"mID": 12345,
"employeeID": 30980,
"operationRequestID": "21d0d10d-a15a-413c-bc3e-8b43b185e551",
"status": "Completed",
"scheduledTime": "2016-06-14T16:01:58.107",
"retryCount": 0,
"createdDate": "2016-06-14T16:02:00",
"createdBy": 30980,
"modifiedDate": "2016-06-14T16:02:00",
"modifiedBy": 30980
},
"requestServiceMessageID": "93631be1-107f-4239-a8b7-cdae245d7403",
"resultMessages": [],
"serviceMessageID": "00e6add8-d79a-4bd6-9568-2f2a272538f0"
}
Note:
In the delete phase, the backgroundOperationStatusID under the backgroundOperationsSummary
node provides that status. If you're implementing this API, should use the
backgroundOperationStatusID to determine whether or not the deletion has been fully processed.
The notable values of backgroundOperationStatusID are:
• Completed
• Aborted (this is usually done at customer's request - this means contacts were restored back
to active after suppression phase was completed)
• Invalid
All other status values should be interpreted as “Processing”.
Function Name
restrictStatusByID(RestrictStatusUrl,client_id,client_secret,account_id,OAuth2URL)
API Name
GET /contacts/v1/contacts/actions/restrict/status?operationID=
Resource Description:
Retrieve the status of the contact restrict operation by operation ID.
Endpoints and Methods: GET /contacts/actions/restrict/status?operationID=3551271'
Function Parameters
Name Type Description
RestrictStatusUrl String Required A RESTful API is an architectural style for an
API that uses HTTP's requests to access and
client_id String Required use data.
String Required In order to interact with Marketing cloud APIs
client_secret Integer Required with authentication, we can achieve using -
String Required Client ID and Client Secret
account_id Account ID is MID of Business Unit
OAuth2URL To generate the bearer token
Example request
function
restrictStatusByID(RestrictStatusUrl,client_id,client_secret,account_id,OAuth2URL)
{
var token=Gettoken(client_id,client_secret,account_id,OAuth2URL);
token=token[0]
var req = new Script.Util.HttpRequest(RestrictStatusUrl);
req.emptyContentHandling = 0;
req.retries = 2;
req.continueOnError = true;
req.contentType = "application/json";
req.setHeader("Authorization", token);
req.method = "GET";
var response = req.send();
Write(Stringify(response.content));
}
Example Response
{
"backgroundOperationsSummary": [],
"numberofRestorableDays": -1,
"operation": {
"listTypeID": 5,
"listIdentifier": "aa11b2cc-d6ea-4f46-bbfc-a4b7afa3f449",
"listKey": "bb11c2dd-d6ea-4f46-bbfc-a4b7afa3f449",
"listName": "Prestaged List",
"expectedListCount": 1,
"actualListCount": 1,
"deleteType": "ContactAndAttributes",
"deleteListOnCompleted": false,
"errorsOccurredInBatchProcess": false,
"isRestrictedForProcessing": true,
"operationID": 2105,
"eID": 55555555,
"mID": 55555555,
"employeeID": 12345678,
"operationRequestID": "1a22b33c-daf1-4ff9-b381-18658d74c547",
"status": "Completed",
"scheduledTime": "2018-01-30T12:40:09.06",
"startTime": "2018-01-30T18:40:11.293",
"endTime": "2018-01-30T18:40:11.963",
"retryCount": 0,
"createdDate": "2018-01-30T18:40:00",
"createdBy": 12345678,
"modifiedDate": "2018-01-30T18:40:00",
"modifiedBy": 10898158
},
"requestServiceMessageID": "a12345b6-5490-4ecf-bed1-cb2112eddd7b",
"responseDateTime": "2018-01-30T12:42:05.819137-06:00",
"resultMessages": [],
"serviceMessageID": "ab11cd2e-1f74-489e-98fb-ff6d2c33a5e4"
}
Function Name
deleteByID(ContactID,DeletebyIDUrl,client_id,client_secret,account_id,OAuth2URL)
API Name
POST /contacts/v1/contacts/actions/delete?type=ids
Resource Description:
Deletes contacts in batches using REST API on the basis of Contact ID's.
Use the operationID value returned to check the status of the delete.
Endpoints and Method: POST /contacts/actions/delete?type=ids'
Function Parameters
Name Type Description
ContactID String Required Unique ID for the contact. You must provide
either a value for contactKey or contactID.
DeletedbyIDUrl String Required A RESTful API is an architectural style for an API
that uses HTTP's requests to access and use
client_id String Required data.
String Required In order to interact with Marketing cloud APIs
client_secret Integer Required with authentication, we can achieve using -
String Required Client ID and Client Secret
account_id Account ID is MID of Business Unit
OAuth2URL To generate the bearer token
Usage:
This request deletes contacts specified by the contact ID values passed in the values array.
This asynchronous process places the deletion call in a queue for processing. The queue processes
only one deletion call at a time, and each process can take several hours to complete.
When deleting from a sendable data extension, the call limits each process to one million rows.
Example request
function
deleteByID(ContactID,DeletebyIDUrl,client_id,client_secret,account_id,OAuth2URL)
{
var token=Gettoken(client_id,client_secret,account_id,OAuth2URL);
token=token[0]
var payload = '{"values": ["'+ContactID+'"],"DeleteOperationType":
"ContactAndAttributes"}';
var req = new Script.Util.HttpRequest(DeletebyIDUrl);
req.emptyContentHandling = 0;
req.retries = 2;
req.continueOnError = true;
req.contentType = "application/json";
req.setHeader("Authorization", token);
req.method = "POST";
req.postData = payload;
var response = req.send();
Write(Stringify(response.content));
}
Example Response
{
"operationInitiated": true,
"operationID": 2,
"requestServiceMessageID": "21d0d10d-a15a-413c-bc3e-8b43b185e551",
"resultMessages": [],
"serviceMessageID": "acb87f67-ec49-42af-a0bb-987ac6451560"
}
Function Name
contactsEstablish(CKey,CKey2,ContactsEstablishUrl,client_id,client_secret,account_id,
OAuth2URL)
API Name
POST/contacts/v1/establish
Resource Description:
Creates or returns a contact using the contact key and contact type provided in the
payload.
Endpoints and Method:
POST /contacts/v1/establish
Function Parameters
Name Type Required Description
ContactKey String Primary address for the contact. You must
provide either a value for contactKey or
contactID.
ContactKey2 String Required Primary address for the contact. You must
provide either a value for contactKey or
contactID.
ContactsEstablishUrl String Required A RESTful API is an architectural style for
an API that uses HTTP's requests to
client_id String Required access and use data.
String Required In order to interact with Marketing cloud
client_secret Integer Required APIs with authentication, we can achieve
String Required using - Client ID and Client Secret
account_id Account ID is MID of Business Unit
OAuth2URL To generate the bearer token
Required Marketing Cloud Permissions:
Contact Builder, Administer Contact Data Model
Contact Builder, Access
Example request
function
contactsEstablish(CKey,CKey2,ContactsEstablishUrl,client_id,client_secret,account_id,
OAuth2URL)
{
var token=Gettoken(client_id,client_secret,account_id,OAuth2URL);
token=token[0]
var payload = '{"ContactKeys": ["'+CKey+'", "'+CKey2+'"]}';
var req = new Script.Util.HttpRequest(ContactsEstablishUrl);
req.emptyContentHandling = 0;
req.retries = 2;
req.continueOnError = true;
req.contentType = "application/json";
req.setHeader("Authorization", token);
req.method = "POST";
req.postData = payload;
var response = req.send();
Write(Stringify(response.content));
}
Example Response
HTTP/1.1 200 Success
[
{
"items": [
{
"value": {
"requestedContactKey": "key1",
"isNewContact": false,
"contactReference": {
"contactID": 295863490,
"contactType": "Default",
"contactKey": "key1",
"contactStatus": "Active"
}
},
"requestItemIndex": 0,
"resultMessages": []
},
{
"value": {
"requestedContactKey": "key2",
"isNewContact": false,
"contactReference": {
"contactID": 304574890,
"contactType": "Default",
"contactKey": "key2",
"contactStatus": "Active"
}
},
"requestItemIndex": 1,
"resultMessages": []
}
],
"requestServiceMessageID": "53e4cbf8-b9b4-43d4-ba17-eedbfb0ffd90",
"responseDateTime": "2018-02-26T15:06:45.4009365-06:00",
"resultMessages": [],
"serviceMessageID": "70082431-9a48-4e3e-8dc5-f318ec5c3665"
}
]
Function Name
deleteByKeys(CKey,DeletebyKeyUrl,client_id,client_secret,account_id,OAuth2URL)
API Name
POST /contacts/v1/contacts/actions/delete?type=keys
Resource Description:
Deletes contacts based on specified contact key values. This operation runs
asynchronously.
Use the OperationID value returned to check the status of the delete.
Endpoints and Method:
POST /contacts/actions/delete?type=keys
Function Parameters
Name Type Description
ContactKey String Required Primary address for the contact. You
must provide either a value for
contactKey or contactID.
DeletebyKeyUrl String Required A RESTful API is an architectural style
for an API that uses HTTP's requests to
access and use data.
client_id String Required In order to interact with Marketing
Required cloud APIs with authentication, we can
client_secret String achieve using - Client ID and Client
Secret
account_id Integer Required Account ID is MID of Business Unit
String Required To generate the bearer token
OAuth2URL
Usage:
This request deletes contacts specified by the contact key values passed in the values array.
This asynchronous process places the deletion call in a queue for processing. The queue processes
only one deletion call at a time, and each process can take several hours to complete.
This resource deletes contact information from the account, including the Email, MobileConnect,
MobilePush, and GroupConnect apps, as well as lists, audiences, journeys, and Einstein analytics.
This deletion occurs at the enterprise level.
Example request
function
deleteByKeys(CKey,DeletebyKeyUrl,client_id,client_secret,account_id,OAuth2URL)
{
var token=Gettoken(client_id,client_secret,account_id,OAuth2URL);
token=token[0]
var payload = '{"values": ["'+CKey+'"],"DeleteOperationType": "ContactAndAttributes"}';
var req = new Script.Util.HttpRequest(DeletebyKeyUrl);
req.emptyContentHandling = 0;
req.retries = 2;
req.continueOnError = true;
req.contentType = "application/json";
req.setHeader("Authorization", token);
req.method = "POST";
req.postData = payload;
var response = req.send();
Write(Stringify(response.content));
}
Example Response
{
"operationInitiated": true,
"operationID": 2,
"requestServiceMessageID": "21d0d10d-a15a-413c-bc3e-8b43b185e551",
"resultMessages": [],
"serviceMessageID": "acb87f67-ec49-42af-a0bb-987ac6451560"
}
Function Name
sMSKeyword(SC,CC,KeywordName,SMSKeywordUrl,client_id,client_secret,account_id,
OAuth2URL)
API Name
POST /sms/v1/keyword
Resource Description:
Creates a keyword on an account.
Endpoints and Method:
POST /sms/v1/keyword
Function Parameters
Name Type Description
ShortCode String Required The short code that the keyword will be created
on
CountryCode String Required The two letter country code specifying the
country that short code belongs to
KeywordName String Required The keyword that will be created
SMSKeywordUrl String Required A RESTful API is an architectural style for an API
that uses HTTP's requests to access and use
data.
client_id String Required In order to interact with Marketing cloud APIs
Required with authentication, we can achieve using -
client_secret String Client ID and Client Secret
account_id Integer Required Account ID is MID of Business Unit
String Required To generate the bearer token
OAuth2URL
Example request
function
sMSKeyword(SC,CC,KeywordName,SMSKeywordUrl,client_id,client_secret,account_id,
OAuth2URL)
{
var token=Gettoken(client_id,client_secret,account_id,OAuth2URL);
token=token[0]
var payload = '{"ShortCode": "'+SC+'","CountryCode": "'+CC+'","Keyword":
"'+KeywordName+'"}';
var req = new Script.Util.HttpRequest(SMSKeywordUrl);
req.emptyContentHandling = 0;
req.retries = 2;
req.continueOnError = true;
req.contentType = "application/json";
req.setHeader("Authorization", token);
req.method = "POST";
req.postData = payload;
var response = req.send();
Write(Stringify(response.content));
}
Example Response
HTTP/1.1 202 Accepted
{
"KeywordId": "alm5LXNSSktGMGluRznRb1Rb1R5MDZFQTo4Njow"
}
Function Name
getContactSchema(ContactSchemaUrl,client_id,client_secret,account_id,OAuth2URL)
API Name
GET /contacts/v1/schema
Resource Description:
Retrieves the collection of all contact data schemas contained in the current account.
Endpoints and Method:
GET /contacts/v1/schema
Function Parameters
Name Type Description
ContactSchemaUrl Required A RESTful API is an architectural style for an
API that uses HTTP's requests to access and
use data.
client_id String Required In order to interact with Marketing cloud APIs
client_secret String Required with authentication, we can achieve using -
Client ID and Client Secret
account_id Integer Required Account ID is MID of Business Unit
OAuth2URL String Required To generate the bearer token
Example request
function
getContactSchema(ContactSchemaUrl,client_id,client_secret,account_id,OAuth2URL)
{
var token=Gettoken(client_id,client_secret,account_id,OAuth2URL);
token=token[0]
var req = new Script.Util.HttpRequest(ContactSchemaUrl);
req.emptyContentHandling = 0;
req.retries = 2;
req.continueOnError = true;
req.contentType = "application/json";
req.setHeader("Authorization", token);
req.method = "GET";
var response = req.send();
Write(Stringify(response.content));
}
Example Response
200 (OK)
Content-Type: application/json
{
"links": {
"self": { "href": "/v1/schema" }
},
"page": 0,
"pageSize": 0,
"count": 0,
"items": [
{
"id": "71c1f974-9812-e411-9ef0-08edb9ddebf0",
"enterpriseID": 10650001,
"availableBusinessUnits": [ 10650001 ],
"version": 16,
"schemaType": "Contacts",
"links": {
"self": { "href": "/v1/schemas/71c1f974-9812-e411-9ef0-08edb9ddebf0" },
"attributeGroups": { "href": "/v1/schemas/71c1f974-9812-e411-9ef0-
08edb9ddebf0/attributeGroups" },
"attributeSetDefinitions": { "href": "/v1/schemas/71c1f974-9812-e411-9ef0-
08edb9ddebf0/attributeSetDefinitions" }
}
}
],
"requestServiceMessageID": "ec7c40b0-22f7-11e4-bf2e-ffbc219b0f06",
"resultMessages": [],
"serviceMessageID": "1fa77ba6-0fb1-4ae1-914a-ef0166318f03"
}
Function Name
attributeSetDefinition(AtrributeSetUrl,client_id,client_secret,account_id,OAuth2URL)
API Name
GET /contacts/v1/attributeSetDefinitions/{id}
Endpoints and Method:
GET /contacts/v1/attributeSetDefinitions
Function Parameters
Name Type Description
AtrributeSetUrl String Required A RESTful API is an architectural style for an API
that uses HTTP's requests to access and use
data.
client_id String Required In order to interact with Marketing cloud APIs
client_secret String Required with authentication, we can achieve using - Client
ID and Client Secret
account_id Integer Required Account ID is MID of Business Unit
OAuth2URL String Required To generate the bearer token
Example request
function
attributeSetDefinition(AtrributeSetUrl,client_id,client_secret,account_id,OAuth2URL)
{
var token=Gettoken(client_id,client_secret,account_id,OAuth2URL);
token=token[0]
var req = new Script.Util.HttpRequest(AtrributeSetUrl);
req.emptyContentHandling = 0;
req.retries = 2;
req.continueOnError = true;
req.contentType = "application/json";
req.setHeader("Authorization", token);
req.method = "GET";
var response = req.send();
Write(Stringify(response.content));
}
Example Response
200 (OK)
{
"page": 1,
"pageSize": 50,
"count": 1,
"items": [
{
"id": "043e290e-01ad-e611-80d5-1402ec6b95bc",
"key": "MobileSubscriptions",
"name": {
"value": "MobileConnect Subscriptions"
},
"fullyQualifiedName": "MobileConnect Subscriptions",
"storageLogicalType": "DataExtension",
"isRoot": false,
"isSendable": false,
"categoryID": 639167,
"isShared": false,
"dataRetentionProperties": {
"setDefinitionID": "043e290e-01ad-e611-80d5-1402ec6b95bc",
"isRowBasedRetention": false,
"isResetRetentionPeriodOnImport": false,
"isDeleteAtEndOfRetentionPeriod": false
},
"isEvent": false,
"relationships": [],
"attributes": [
{
"id": "063e290e-01ad-e611-80d5-1402ec6b95bc",
"key": "CreatedDate",
"name": {
"value": "Created Date"
},
"storageName": "_CreatedDate",
"dataType": "Date",
"isPrimaryKey": false,
"isNullable": false,
"isReadOnly": true,
"defaultValue": "GETDATE()",
"displayOrder": 2,
"ranges": [],
"description": "",
"dataSourceID": 3,
"restrictedValues": [],
"obfuscationProperties": {
"valueDefinitionID": "063e290e-01ad-e611-80d5-1402ec6b95bc",
"storageTypeID": 1,
"maskTypeID": 0,
"storageType": "Plain",
"maskType": "None"
},
"fullyQualifiedName": "MobileConnect Subscriptions.Created Date",
"parentId": "043e290e-01ad-e611-80d5-1402ec6b95bc",
"isSystemDefined": true,
"isIdentityValue": false,
"isHidden": false,
"isUpdateable": false,
"parentType": "Set",
"dataSourceName": {},
"links": {},
"objectState": "Created"
},
{
"id": "15052214-01ad-e611-80d5-1402ec6b95bc",
"key": "SubscriptionDefinitionID",
"name": {
"value": "Keyword"
},
"storageName": "_SubscriptionDefinitionID",
"dataType": "Text",
"isPrimaryKey": true,
"isNullable": false,
"isReadOnly": false,
"displayOrder": 3,
"ranges": [],
"description": "",
"length": 200,
"dataSourceID": 3,
"restrictedValues": [],
"restrictionLookupListID": 7,
"obfuscationProperties": {
"valueDefinitionID": "15052214-01ad-e611-80d5-1402ec6b95bc",
"storageTypeID": 1,
"maskTypeID": 0,
"storageType": "Plain",
"maskType": "None"
},
"fullyQualifiedName": "MobileConnect Subscriptions.Keyword",
"parentId": "043e290e-01ad-e611-80d5-1402ec6b95bc",
"isSystemDefined": true,
"isIdentityValue": false,
"isHidden": false,
"isUpdateable": false,
"parentType": "Set",
"dataSourceName": {},
"links": {},
"objectState": "Created"
},
{
"id": "073e290e-01ad-e611-80d5-1402ec6b95bc",
"key": "MobileNumber",
"name": {
"value": "Mobile Number"
},
"storageName": "_MobileNumber",
"dataType": "Phone",
"isPrimaryKey": true,
"isNullable": false,
"isReadOnly": true,
"displayOrder": 4,
"ranges": [],
"description": "",
"length": 15,
"dataSourceID": 3,
"restrictedValues": [],
"obfuscationProperties": {
"valueDefinitionID": "073e290e-01ad-e611-80d5-1402ec6b95bc",
"storageTypeID": 1,
"maskTypeID": 0,
"storageType": "Plain",
"maskType": "None"
},
"fullyQualifiedName": "MobileConnect Subscriptions.Mobile Number",
"parentId": "043e290e-01ad-e611-80d5-1402ec6b95bc",
"isSystemDefined": true,
"isIdentityValue": false,
"isHidden": false,
"isUpdateable": false,
"parentType": "Set",
"dataSourceName": {},
"links": {},
"objectState": "Created"
},
{
"id": "0c052214-01ad-e611-80d5-1402ec6b95bc",
"key": "ModifiedDate",
"name": {
"value": "Modified Date"
},
"storageName": "_ModifiedDate",
"dataType": "Date",
"isPrimaryKey": false,
"isNullable": false,
"isReadOnly": true,
"defaultValue": "GETDATE()",
"displayOrder": 7,
"ranges": [],
"description": "",
"dataSourceID": 3,
"restrictedValues": [],
"obfuscationProperties": {
"valueDefinitionID": "0c052214-01ad-e611-80d5-1402ec6b95bc",
"storageTypeID": 1,
"maskTypeID": 0,
"storageType": "Plain",
"maskType": "None"
},
"fullyQualifiedName": "MobileConnect Subscriptions.Modified Date",
"parentId": "043e290e-01ad-e611-80d5-1402ec6b95bc",
"isSystemDefined": true,
"isIdentityValue": false,
"isHidden": false,
"isUpdateable": false,
"parentType": "Set",
"dataSourceName": {},
"links": {},
"objectState": "Created"
},
{
"id": "0d052214-01ad-e611-80d5-1402ec6b95bc",
"key": "OptInDate",
"name": {
"value": "Opt In Date"
},
"storageName": "_OptInDate",
"dataType": "Date",
"isPrimaryKey": false,
"isNullable": true,
"isReadOnly": true,
"displayOrder": 8,
"ranges": [],
"description": "",
"dataSourceID": 3,
"restrictedValues": [],
"obfuscationProperties": {
"valueDefinitionID": "0d052214-01ad-e611-80d5-1402ec6b95bc",
"storageTypeID": 1,
"maskTypeID": 0,
"storageType": "Plain",
"maskType": "None"
},
"fullyQualifiedName": "MobileConnect Subscriptions.Opt In Date",
"parentId": "043e290e-01ad-e611-80d5-1402ec6b95bc",
"isSystemDefined": true,
"isIdentityValue": false,
"isHidden": false,
"isUpdateable": false,
"parentType": "Set",
"dataSourceName": {},
"links": {},
"objectState": "Created"
},
{
"id": "0e052214-01ad-e611-80d5-1402ec6b95bc",
"key": "OptInMethodID",
"name": {
"value": "Opt In Method"
},
"storageName": "_OptInMethodID",
"dataType": "Byte",
"isPrimaryKey": false,
"isNullable": true,
"isReadOnly": true,
"displayOrder": 9,
"ranges": [],
"description": "",
"dataSourceID": 3,
"restrictedValues": [],
"restrictionLookupListID": 2,
"obfuscationProperties": {
"valueDefinitionID": "0e052214-01ad-e611-80d5-1402ec6b95bc",
"storageTypeID": 1,
"maskTypeID": 0,
"storageType": "Plain",
"maskType": "None"
},
"fullyQualifiedName": "MobileConnect Subscriptions.Opt In Method",
"parentId": "043e290e-01ad-e611-80d5-1402ec6b95bc",
"isSystemDefined": true,
"isIdentityValue": false,
"isHidden": false,
"isUpdateable": false,
"parentType": "Set",
"dataSourceName": {},
"links": {},
"objectState": "Created"
},
{
"id": "0f052214-01ad-e611-80d5-1402ec6b95bc",
"key": "OptInStatusID",
"name": {
"value": "Opt In Status"
},
"storageName": "_OptInStatusID",
"dataType": "Byte",
"isPrimaryKey": false,
"isNullable": false,
"isReadOnly": false,
"displayOrder": 10,
"ranges": [],
"description": "",
"dataSourceID": 3,
"restrictedValues": [],
"restrictionLookupListID": 1,
"obfuscationProperties": {
"valueDefinitionID": "0f052214-01ad-e611-80d5-1402ec6b95bc",
"storageTypeID": 1,
"maskTypeID": 0,
"storageType": "Plain",
"maskType": "None"
},
"fullyQualifiedName": "MobileConnect Subscriptions.Opt In Status",
"parentId": "043e290e-01ad-e611-80d5-1402ec6b95bc",
"isSystemDefined": true,
"isIdentityValue": false,
"isHidden": false,
"isUpdateable": false,
"parentType": "Set",
"dataSourceName": {},
"links": {},
"objectState": "Created"
},
{
"id": "10052214-01ad-e611-80d5-1402ec6b95bc",
"key": "OptOutDate",
"name": {
"value": "Opt Out Date"
},
"storageName": "_OptOutDate",
"dataType": "Date",
"isPrimaryKey": false,
"isNullable": true,
"isReadOnly": true,
"displayOrder": 11,
"ranges": [],
"description": "",
"dataSourceID": 3,
"restrictedValues": [],
"obfuscationProperties": {
"valueDefinitionID": "10052214-01ad-e611-80d5-1402ec6b95bc",
"storageTypeID": 1,
"maskTypeID": 0,
"storageType": "Plain",
"maskType": "None"
},
"fullyQualifiedName": "MobileConnect Subscriptions.Opt Out Date",
"parentId": "043e290e-01ad-e611-80d5-1402ec6b95bc",
"isSystemDefined": true,
"isIdentityValue": false,
"isHidden": false,
"isUpdateable": false,
"parentType": "Set",
"dataSourceName": {},
"links": {},
"objectState": "Created"
},
{
"id": "11052214-01ad-e611-80d5-1402ec6b95bc",
"key": "OptOutMethodID",
"name": {
"value": "Opt Out Method"
},
"storageName": "_OptOutMethodID",
"dataType": "Byte",
"isPrimaryKey": false,
"isNullable": true,
"isReadOnly": true,
"displayOrder": 12,
"ranges": [],
"description": "",
"dataSourceID": 3,
"restrictedValues": [],
"restrictionLookupListID": 4,
"obfuscationProperties": {
"valueDefinitionID": "11052214-01ad-e611-80d5-1402ec6b95bc",
"storageTypeID": 1,
"maskTypeID": 0,
"storageType": "Plain",
"maskType": "None"
},
"fullyQualifiedName": "MobileConnect Subscriptions.Opt Out Method",
"parentId": "043e290e-01ad-e611-80d5-1402ec6b95bc",
"isSystemDefined": true,
"isIdentityValue": false,
"isHidden": false,
"isUpdateable": false,
"parentType": "Set",
"dataSourceName": {},
"links": {},
"objectState": "Created"
},
{
"id": "12052214-01ad-e611-80d5-1402ec6b95bc",
"key": "OptOutStatusID",
"name": {
"value": "Opt Out Status"
},
"storageName": "_OptOutStatusID",
"dataType": "Byte",
"isPrimaryKey": false,
"isNullable": true,
"isReadOnly": false,
"displayOrder": 13,
"ranges": [],
"description": "",
"dataSourceID": 3,
"restrictedValues": [],
"restrictionLookupListID": 3,
"obfuscationProperties": {
"valueDefinitionID": "12052214-01ad-e611-80d5-1402ec6b95bc",
"storageTypeID": 1,
"maskTypeID": 0,
"storageType": "Plain",
"maskType": "None"
},
"fullyQualifiedName": "MobileConnect Subscriptions.Opt Out Status",
"parentId": "043e290e-01ad-e611-80d5-1402ec6b95bc",
"isSystemDefined": true,
"isIdentityValue": false,
"isHidden": false,
"isUpdateable": false,
"parentType": "Set",
"dataSourceName": {},
"links": {},
"objectState": "Created"
},
{
"id": "13052214-01ad-e611-80d5-1402ec6b95bc",
"key": "Source",
"name": {
"value": "Source"
},
"storageName": "_Source",
"dataType": "Byte",
"isPrimaryKey": false,
"isNullable": true,
"isReadOnly": true,
"displayOrder": 14,
"ranges": [],
"description": "",
"dataSourceID": 3,
"restrictedValues": [],
"restrictionLookupListID": 5,
"obfuscationProperties": {
"valueDefinitionID": "13052214-01ad-e611-80d5-1402ec6b95bc",
"storageTypeID": 1,
"maskTypeID": 0,
"storageType": "Plain",
"maskType": "None"
},
"fullyQualifiedName": "MobileConnect Subscriptions.Source",
"parentId": "043e290e-01ad-e611-80d5-1402ec6b95bc",
"isSystemDefined": true,
"isIdentityValue": false,
"isHidden": false,
"isUpdateable": false,
"parentType": "Set",
"dataSourceName": {},
"links": {},
"objectState": "Created"
},
{
"id": "14052214-01ad-e611-80d5-1402ec6b95bc",
"key": "SourceObjectID",
"name": {
"value": "Source Object ID"
},
"storageName": "_SourceObjectId",
"dataType": "Text",
"isPrimaryKey": false,
"isNullable": true,
"isReadOnly": true,
"displayOrder": 15,
"ranges": [],
"description": "",
"length": 200,
"dataSourceID": 3,
"restrictedValues": [],
"obfuscationProperties": {
"valueDefinitionID": "14052214-01ad-e611-80d5-1402ec6b95bc",
"storageTypeID": 1,
"maskTypeID": 0,
"storageType": "Plain",
"maskType": "None"
},
"fullyQualifiedName": "MobileConnect Subscriptions.Source Object ID",
"parentId": "043e290e-01ad-e611-80d5-1402ec6b95bc",
"isSystemDefined": true,
"isIdentityValue": false,
"isHidden": false,
"isUpdateable": false,
"parentType": "Set",
"dataSourceName": {},
"links": {},
"objectState": "Created"
}
],
"canAddValues": false,
"isSystemDefined": true,
"canRemove": false,
"canModify": false,
"isReadOnly": false,
"applicationID": "e25893f9-08f3-480f-8def-7f8ab0583611",
"applicationKey": "com.exacttarget.mobileconnect",
"links": {},
"objectState": "Created"
}
],
"links": {
"self": {
"href": "/v1/attributeSetDefinitions"
},
"schema": {
"href": "/v1/schema"
}
},
"requestServiceMessageID": "c9ffe21c-3cb7-4a05-a061-77844c090ecb",
"resultMessages": [],
"serviceMessageID": "2099a391-68fe-4fee-a2f5-0a8942d62830"
}
Function Name
getContactSchema(ContactSchemaUrl,client_id,client_secret,account_id,OAuth2URL)
API Name
GET /contacts/v1/schema
Description:
Retrieves the collection of all contact data schemas contained in the current account.
Endpoints and Method:
GET /contacts/v1/schema
Function Parameters
Name Type Description
ContactSchemaUrl String Required A RESTful API is an architectural style for an
API that uses HTTP's requests to access and
use data.
client_id String Required In order to interact with Marketing cloud APIs
client_secret String Required with authentication, we can achieve using -
Client ID and Client Secret
account_id Integer Required Account ID is MID of Business Unit
OAuth2URL String Required To generate the bearer token
Example request
function
getContactSchema(ContactSchemaUrl,client_id,client_secret,account_id,OAuth2URL)
{
var token=Gettoken(client_id,client_secret,account_id,OAuth2URL);
token=token[0]
var req = new Script.Util.HttpRequest(ContactSchemaUrl);
req.emptyContentHandling = 0;
req.retries = 2;
req.continueOnError = true;
req.contentType = "application/json";
req.setHeader("Authorization", token);
req.method = "GET";
var response = req.send();
Write(Stringify(response.content));
}
Example Response
200 (OK)
Content-Type: application/json
{
"links": {
"self": { "href": "/v1/schema" }
},
"page": 0,
"pageSize": 0,
"count": 0,
"items": [
{
"id": "71c1f974-9812-e411-9ef0-08edb9ddebf0",
"enterpriseID": 10650001,
"availableBusinessUnits": [ 10650001 ],
"version": 16,
"schemaType": "Contacts",
"links": {
"self": { "href": "/v1/schemas/71c1f974-9812-e411-9ef0-08edb9ddebf0" },
"attributeGroups": { "href": "/v1/schemas/71c1f974-9812-e411-9ef0-
08edb9ddebf0/attributeGroups" },
"attributeSetDefinitions": { "href": "/v1/schemas/71c1f974-9812-e411-9ef0-
08edb9ddebf0/attributeSetDefinitions" }
}
}
],
"requestServiceMessageID": "ec7c40b0-22f7-11e4-bf2e-ffbc219b0f06",
"resultMessages": [],
"serviceMessageID": "1fa77ba6-0fb1-4ae1-914a-ef0166318f03"
}
Function Name
journeyContactExit(CKey,CKey2,v1,v2,DEFINITIONKEY,ContactExitUrl,client_id,client_se
cret,account_id,OAuth2URL)
API Name
POST /interaction/v1/interactions/contactexit/status
Description:
Returns the status of a request to remove a contact from a journey or from one or
more versions of a journey.
Endpoints and Method:
POST /interaction/v1/interactions/contactexit/status
Function Parameters
Name Type Description
ContactKey String Required Primary address for the contact. You must
provide either a value for contactKey or
contactID.
ContactKey2 String Required Primary address for the contact. You must
provide either a value for contactKey or
contactID.
V1 Integer Required Version 1 of the journey
V2 Integer Required Version 2 of the journey
DEFINITIONKEY String Required Customer Key that uniquely identifies the
ContactExitUrl String journey. This key is the same for all versions of
the journey.
client_id String Required A RESTful API is an architectural style for an API
Client_secret String that uses HTTP's requests to access and use
account_id Integer data.
OAuth2Url String Required In order to interact with Marketing cloud APIs
Required with authentication, we can achieve using -
Client ID and Client Secret
Required Account ID is MID of Business Unit
Required To generate the bearer token
Example request
function
journeyContactExit(CKey,CKey2,v1,v2,DEFINITIONKEY,ContactExitUrl,client_id,client_se
cret,account_id,OAuth2URL)
{
var token=Gettoken(client_id,client_secret,account_id,OAuth2URL);
token=token[0]
var payload = '[{"ContactKey": "'+CKey+'","DefinitionKey":
"'+DEFINITIONKEY+'"},{"ContactKey": "'+CKey2+'","DefinitionKey":
"DEFINITIONKEY1","Versions" :['+v1+','+v2+']}]';
var req = new Script.Util.HttpRequest(ContactExitUrl);
req.emptyContentHandling = 0;
req.retries = 2;
req.continueOnError = true;
req.contentType = "application/json";
req.setHeader("Authorization", token);
req.method = "POST";
req.postData = payload;
var response = req.send();
Write(Stringify(response.content));
}
Example Response
Successful Completion of Exit by Contact
HTTP/1.1 200
[
{
"contactKey": "2",
"definitionKey": "DEFINITIONKEY",
"status": [
{
"version": 3,
"message": "Exit process Completed.",
"definitionInstanceId": "a47f5b0b-c673-4662-b043-bbd269f79c11"
}
]
}
]
Function Name
getAuditEvents(AuditEventUrl,client_id,client_secret,account_id,OAuth2URL)
API Name
GET /data/v1/audit/securityEvents
Description:
Retrieves logged Audit Trail security events for the authenticated user’s account and
its children. Logins are audited at the enterprise level.
Endpoints and Methods:
GET /data/v1/audit/auditEvents
Function Parameters
Name Type Description
AuditEventUrl String Required A RESTful API is an architectural style for
an API that uses HTTP's requests to
access and use data.
Client_id String Required In order to interact with Marketing cloud
Client_secret String Required APIs with authentication, we can achieve
using - Client ID and Client Secret
Account_id Integer Required Account ID is MID of Business Unit
OAuth2URL String Required To generate the bearer token
Example request
function getAuditEvents(AuditEventUrl,client_id,client_secret,account_id,OAuth2URL)
{
var token=Gettoken(client_id,client_secret,account_id,OAuth2URL);
token=token[0]
var req = new Script.Util.HttpRequest(AuditEventUrl);
req.emptyContentHandling = 0;
req.retries = 2;
req.continueOnError = true;
req.contentType = "application/json";
req.setHeader("Authorization", token);
req.method = "GET";
var response = req.send();
Write(Stringify(response.content));
}
Example Response
HTTP/1.1 200 OK
[
{
"page": 1,
"pageSize": 50,
"count": 15,
"items": [
{
"id": 00000000,
"createdDate": "2019-01-01T12:00:00.00",
"memberId": 00000000,
"enterpriseId": 00000000,
"employee": {
"employeeName": "Test User",
"userName": "monitoring"
},
"ipAddress": "255.255.255.255",
"sessionId":
"fa7cbbf2899f5b8a4257ab5a834389a7f3471478f5d0ead6e468f4c0128f538e",
"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML,
like Gecko) Chrome/60.0.3112.78 Safari/537.36",
"eventType": {