For a long, long time – the only way to do this was to first build the Automation in SOAP API, via the Automation Object, and then build out the file trigger in the ‘FileTrigger’ Object and attach it to the original Automation.
It was a very confusing and very buggy endeavor. To this day, I still have trouble getting it to work correctly.
Luckily, I have found a REST API endpoint that allows you to do both actions at the same time – create the File Trigger and the Automation at the same time.
You use the endpoint automation/v1/automations
to create (POST) your new automation.
See below example for endpoint info:
POST /automation/v1/automations Host: {{yourSubDomain}}.rest.marketingcloudapis.com Authorization: Bearer XXXXXXX Content-Type: application/json
and then the payload:
{ "name": "testRestAuto", "description": "testRestAuto", "key": "testRestAuto", "steps": [ { "annotation": "", "stepNumber": 0, "activities": [ { "id": "yourActivityID", "name": "yourActivityName", "objectTypeId": 43, "displayOrder": 0, "activityObjectId": "{{yourActivityObjectID}}" } ], "id": "f4518041-5702-4712-a690-abc17e6a30f1" }, { "annotation": "", "stepNumber": 1, "activities": [ { "name": "1 Hours", "objectTypeId": 467, "displayOrder": 0, "activityObjectId": "00000000-0000-0000-0000-000000000000", "serializedObject": "{\"duration\":1,\"durationUnits\":\"Hours\"}" } ] } ], "startSource": { "typeId": 2, /* sets it to Triggered Auto */ "fileDrop": { "filenamePatternTypeId": 0, /* 0 is no name, 1 Contains, 2 begins with, 3 ends with */ "filenamePattern": "file", /* only used with 1-3 to set string for filename - remove for 0 */ "folderLocation": "triggered_automations", "statusId": 0, "queueFiles": true } }, "categoryId": 58142 /* Folder ID */ }
The important part to pay attention to is the ‘startSource’ section:
"startSource": { "typeId": 2, /* sets it to Triggered Auto */ "fileDrop": { "filenamePatternTypeId": 1, /* 0 is no name, 1 Contains, 2 begins with, 3 ends with */ "filenamePattern": "file", /* only used with 1-3 to set string for filename - remove for 0 */ "folderLocation": "triggered_automations", "statusId": 0, "queueFiles": true } }
This is where you will set up the triggered Send information.
Please note the "filenamePatternTypeId"
property. The value here will determine if there is a filename pattern (Contains, Begins with, Ends with) inside your Trigger.
0 – no name pattern
1 – Contains
2 – Begins with
3 – Ends with
All other values inside this property will cause an error.
Next, please note the "filenamePattern"
property. This will only need to be added if you use 1-3 for "filenamePatternTypeId"
. For 0, you can remove this property altogether.
Here you will place the string you want to use for the pattern, for instance I made it so that it will search for any file that contains the word “band” inside of it.
"folderLocation"
is the folder/directory inside the FTP you want this aimed at. Please note that if your directory is a subdirectory and requires a \
, you will need to escape it. So, for instance: root\yoursubdirectory
would become: "root\\yoursubdirectory"
value.
"queueFiles"
will allow your Automation to queue if it is not yet complete with one file, when a second one appears. True to allow queueing, False to prevent queueing.
After you created it, you can then use PATCH or GET (utilizing the ObjectID at the end of the endpoint) to update or retrieve your automation.
Excellent! Gotta love discovering undocumented API features.
Hello, Is it possible to to add the already created activities in the new Automation.. I am trying to replicate an automation and remove certain activities or create a new automation and define activities as the existing ones (which are already created). Can you help me with the code for the same?
I’m trying to do the same thing but haven’t gotten it figured out yet.
You can use the Object Id of your activities
@gortonington, may you add the activity types inthe post, I know its an old one, but its still useful:
42 User-initiated Email
43 Import Definition
45 Group Definition
53 File Transfer Activity
73 Data Extract Activity
84 Report Activity
300 Query Activity
303 Filter Activity
423 Server Side Javascript Activity
425 ELT Activity
427 Build Audience Activity
467 Program Wait
724 Mobile Automation List Refresh Instance
725 MobileConnect Message Instance
726 Mobile File Import Instance
733 InteractionStudio
736 MobilePush Message Object Instance
749 Interaction Studio Event
756 Interaction Studio Date Event
771 Salesforce Send Activiy
783 GroupConnect
1010 Thunderhead Transfer Activity
1101 Interaction Studio Decision Activity
1701 PredictiveIntelligenceRecommendationActivity
Recently I was playing with triggered automations from azure blob storage and the api call used for the activation was a PATCH to https://mc.sXXXX.marketingcloudapps.com/AutomationStudioFuel3/fuelapi/automation/v1/automations/trigger/automationLegacyId With a JSON body: {“isActive”:false/true} (The automationLegacyId can be retrieved from the url or via API, its also retrieved in the response body when you create the automation ). So I changed the host to my own tenant and it worked!
The endpoint now looks like:
PATCH
https://tenant.rest.marketingcloudapis.com/automation/v1/automations/trigger/automationLegacyId
body:{“isActive”:false/true}
Now I can fully automate some processes without having to manually activate the automations. Hope you can too.
@gortonington you can update the post in case you want to add this information regarding activation.