Create a Triggered Send Definition verified

Learn how to create a Triggered Send Definition in Salesforce Marketing Cloud (SFMC) with SSJS (server-side JavaScript). Code snippets include WSProxy and Core methods.

Core

var config = {
   Name: "MyTSD",
   CustomerKey: GUID(),
   FromName: "John",
   FromAddress: "example@mail.com",
   EmailID: 12345,
   SendClassificationID: 67890
};

var result = TriggeredSend.Add(config);
<script runat="server">

    Platform.Load("core", "1");

    try {

        var config = {
            Name: "MyTSD",
            CustomerKey: GUID(),
            FromName: "John",
            FromAddress: "example@mail.com",
            EmailID: 12345,
            SendClassificationID: 67890
        };

        var result = TriggeredSend.Add(config);

        Write(Stringify(result));

    } catch (error) {

        Write(Stringify(error));

    }

</script>
{
  "Send": "function",
  "Start": "function",
  "Pause": "function",
  "Publish": "function",
  "Update": "function",
  "Tracking": {
    "Retrieve": "function",
    "Clicks": {
      "Retrieve": "function"
    },
    "TotalByInterval": {
      "Retrieve": "function"
    }
  },
  "LastRequestID": null,
  "LastMessage": null
}

DANGER

FromName and FromAddress properties will modify the Sender Profile options related to the SendClassificationID. Proceed at your own risk!

WSProxy

var config = {
    Name: "MyTSD",
    CustomerKey: GUID(),
    SendClassification: {
        CustomerKey: "Default Transactional"
    },
    Email: {
        ID: 123188
    },
    List: {
        CustomerKey: "All Subscribers - 123"
    },
    SendSourceDataExtension: {
        CustomerKey: "S0M3-GU1D-K3Y-G03SR1G4T-H3R3"
    },
    SenderProfile: {
        CustomerKey: "default"
    }
};

var result = api.createItem("TriggeredSendDefinition", config);
<script runat="server">

    Platform.Load("core", "1");

    var api = new Script.Util.WSProxy();

    try {

        var config = {
            Name: "MyTSD",
            CustomerKey: GUID(),
            SendClassification: {
                CustomerKey: "Default Transactional"
            },
            Email: {
                ID: 123188
            },
            List: {
                CustomerKey: "All Subscribers - 123"
            },
            SendSourceDataExtension: {
                CustomerKey: "S0M3-GU1D-K3Y-G03SR1G4T-H3R3"
            },
            SenderProfile: {
                CustomerKey: "default"
            }
        };

        var result = api.createItem("TriggeredSendDefinition", config);

        Write(Stringify(result));

    } catch (error) {

        Write(Stringify(error));

    }

</script>
{
  "Status": "OK",
  "RequestID": "S0M3-GU1D-K3Y-G03SR1G4T-H3R3",
  "Results": [
    {
      "NewID": 0,
      "NewObjectID": "S0M3-GU1D-K3Y-G03SR1G4T-H3R3",
      "PartnerKey": null,
      "Object": {
        "CustomerKey": "S0M3-GU1D-K3Y-G03SR1G4T-H3R3",
        "Client": null,
        "Email": {
          "ID": 123188,
          "Name": null,
          "Folder": null,
          "CategoryID": 0,
          "HTMLBody": null,
          "TextBody": null,
          "ContentAreas": null,
          "Subject": null,
          "IsActive": false,
          "IsHTMLPaste": false,
          "ClonedFromID": 0,
          "Status": null,
          "EmailType": null,
          "CharacterSet": null,
          "HasDynamicSubjectLine": false,
          "ContentCheckStatus": null,
          "Template": null,
          "CustomObjectID": null,
          "SampleAudienceOnly": false,
          "SyncTextWithHTML": false,
          "PreHeader": null,
          "IsApproved": false,
          "__AdditionalEmailAttribute1": null,
          "__AdditionalEmailAttribute2": null,
          "__AdditionalEmailAttribute3": null,
          "__AdditionalEmailAttribute4": null,
          "__AdditionalEmailAttribute5": null,
          "Client": null,
          "PartnerKey": null,
          "PartnerProperties": null,
          "CreatedDate": "0001-01-01T00:00:00.000",
          "ModifiedDate": null,
          "ObjectID": null,
          "CustomerKey": null,
          "Owner": null,
          "CorrelationID": null,
          "ObjectState": null,
          "IsPlatformObject": false
        },
        "List": {
          "ListClassification": "ExactTargetList",
          "Type": "Public",
          "ListName": null,
          "Description": null,
          "Category": 0,
          "Subscribers": null,
          "AutomatedEmail": null,
          "OptInProfile": null,
          "SendClassification": null,
          "Client": null,
          "PartnerKey": null,
          "PartnerProperties": null,
          "CreatedDate": "0001-01-01T00:00:00.000",
          "ModifiedDate": null,
          "ID": 0,
          "ObjectID": null,
          "CustomerKey": "All Subscribers - 123",
          "Owner": null,
          "CorrelationID": null,
          "ObjectState": null,
          "IsPlatformObject": false
        },
        "HeaderContentArea": null,
        "FooterContentArea": null,
        "SendClassification": {
          "ObjectID": null,
          "CustomerKey": "Default Transactional",
          "SendClassificationType": "Operational",
          "Name": null,
          "Description": null,
          "SenderProfile": null,
          "DeliveryProfile": null,
          "HonorPublicationListOptOutsForTransactionalSends": false,
          "SendPriority": "Burst",
          "ArchiveEmail": false,
          "ValidateCustomSubstitutionStrings": false,
          "Client": null,
          "PartnerKey": null,
          "PartnerProperties": null,
          "CreatedDate": "0001-01-01T00:00:00.000",
          "ModifiedDate": null,
          "ID": 0,
          "Owner": null,
          "CorrelationID": null,
          "ObjectState": null,
          "IsPlatformObject": false
        },
        "SenderProfile": {
          "Name": null,
          "Description": null,
          "FromName": null,
          "FromAddress": null,
          "UseDefaultRMMRules": false,
          "AutoForwardToEmailAddress": null,
          "AutoForwardToName": null,
          "DirectForward": false,
          "AutoForwardTriggeredSend": null,
          "AutoReply": false,
          "AutoReplyTriggeredSend": null,
          "SenderHeaderEmailAddress": null,
          "SenderHeaderName": null,
          "DataRetentionPeriodLength": 0,
          "DataRetentionPeriodUnitOfMeasure": "Secondly",
          "ReplyManagementRuleSet": null,
          "RMMCustomRoutingEmailAddress": null,
          "RMMCustomTriggeredSend": null,
          "RMMCustomAutoReplyTriggeredSend": null,
          "RMMRuleCollection": null,
          "ReplyToAddress": null,
          "ReplyToDisplayName": null,
          "FallbackFromAddress": null,
          "Client": null,
          "PartnerKey": null,
          "PartnerProperties": null,
          "CreatedDate": "0001-01-01T00:00:00.000",
          "ModifiedDate": null,
          "ID": 0,
          "ObjectID": null,
          "CustomerKey": "default",
          "Owner": null,
          "CorrelationID": null,
          "ObjectState": null,
          "IsPlatformObject": false
        },
        "DeliveryProfile": null,
        "PrivateDomain": null,
        "PrivateIP": null,
        "ObjectID": "S0M3-GU1D-K3Y-G03SR1G4T-H3R3",
        "CreatedDate": "0001-01-01T00:00:00.000",
        "ModifiedDate": null,
        "Name": "MyTSD",
        "Description": null,
        "AutoAddSubscribers": false,
        "AutoUpdateSubscribers": false,
        "BatchInterval": 0,
        "FromName": null,
        "FromAddress": null,
        "BccEmail": null,
        "EmailSubject": "Some random subject",
        "DynamicEmailSubject": null,
        "IsMultipart": false,
        "IsWrapped": false,
        "AllowedSlots": 0,
        "NewSlotTrigger": 0,
        "SendLimit": 0,
        "SendWindowOpen": "0001-01-01T00:00:00.000",
        "SendWindowClose": "0001-01-01T00:00:00.000",
        "SuppressTracking": false,
        "Keyword": null,
        "IsPlatformObject": false,
        "TriggeredSendType": "Continuous",
        "TriggeredSendStatus": "New",
        "PartnerKey": null,
        "SendWindowDelete": false,
        "RefreshContent": false,
        "ExclusionFilter": null,
        "Priority": null,
        "SendSourceCustomerKey": null,
        "ExclusionListCollection": null,
        "CCEmail": null,
        "SendSourceDataExtension": {
          "CustomerKey": "S0M3-GU1D-K3Y-G03SR1G4T-H3R3",
          "Name": null,
          "Description": null,
          "IsSendable": false,
          "IsTestable": false,
          "SendableDataExtensionField": null,
          "SendableSubscriberField": null,
          "Template": null,
          "DataRetentionPeriodLength": 0,
          "DataRetentionPeriodUnitOfMeasure": 0,
          "RowBasedRetention": false,
          "ResetRetentionPeriodOnImport": false,
          "DeleteAtEndOfRetentionPeriod": false,
          "RetainUntil": null,
          "Fields": null,
          "DataRetentionPeriod": "Days",
          "CategoryID": 0,
          "Status": null,
          "Client": null,
          "PartnerKey": null,
          "PartnerProperties": null,
          "CreatedDate": "0001-01-01T00:00:00.000",
          "ModifiedDate": null,
          "ID": 0,
          "ObjectID": null,
          "Owner": null,
          "CorrelationID": null,
          "ObjectState": null,
          "IsPlatformObject": false
        },
        "IsAlwaysOn": false,
        "DisableOnEmailBuildError": false,
        "KeepExistingEmailSubject": false,
        "PreHeader": null,
        "ReplyToAddress": null,
        "ReplyToDisplayName": null,
        "DataSchemas": null,
        "TriggeredSendClass": "Standard",
        "TriggeredSendSubClass": "Standard",
        "TriggeredSendVersionID": 0,
        "RequestExpirationSeconds": 0,
        "OptionFlags": 0,
        "OptionFlagsUpdateMask": 0,
        "OptionVersion": 0,
        "CategoryID": 0,
        "SourceAddressType": "DefaultPrivateIPAddress",
        "DomainType": "DefaultDomain",
        "HeaderSalutationSource": "Default",
        "FooterSalutationSource": "Default",
        "IsSendLogging": false,
        "InteractionObjectID": null,
        "PartnerProperties": null,
        "ID": 0,
        "Owner": null,
        "CorrelationID": null,
        "ObjectState": null
      },
      "CreateResults": null,
      "ParentPropertyName": null,
      "StatusCode": "OK",
      "StatusMessage": "TriggeredSendDefinition created",
      "OrdinalID": 0,
      "ErrorCode": 0,
      "RequestID": null,
      "ConversationID": null,
      "OverallStatusCode": null,
      "RequestType": "Synchronous",
      "ResultType": null,
      "ResultDetailXML": null
    }
  ]
}

WARNING

SendClassification referenced in the request need to be linked to the referenced SenderProfile.

DANGER

If you decide to pass the FromName and FromAddress properties, they will modify the Sender Profile options related to the SendClassification.

Reference

Ressources and references related to the current methods.

Official documentation
SOAP object

Last Updated: