0

I tries to create SSJS activity using REST API. Body of request looks like this:

{    
    "name": "ActivityName",
    "key": "ActivityKey",
    "description": "",
    "script": "Blablabla",
    "categoryId": 123456
}

But, categoryId field is required, and I don't know how I can get it using API (any API). So, the question is: how to get categoryId of SSJS activities? Ideally is to retrieve root categoryId, but honestly, I hope to get at least any categoryId through API

0

You can get a list of your SSJS Activities folder via the category type of ssjsactivity on the folder structure endpoint:

GET /email/v1/categories?catType=ssjsactivity
Host: {{subDomain}}.rest.marketingcloudapis.com
Authorization: Bearer {{auth_token}}
Content-Type: application/json

This will return an array of the folders and IDs of your SSJS Activities. Like below:

{
    "count": 1,
    "page": 1,
    "pageSize": 50,
    "links": {
        "self": {
            "href": "/v1/categories/?catType=ssjsactivity&$page=1&$pageSize=50"
        }
    },
    "items": [
        {
            "categoryId": 123456,
            "parentCatId": 0,
            "modifiedBy": XXXXXXX,
            "objectId": "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx",
            "createDate": "2029-12-09T12:33:28.133",
            "modifiedDate": "2029-12-09T12:33:28.133",
            "catType": "SSJSActivity",
            "name": "Scripts",
            "categoryDesc": "",
            "iconType": "SSJSActivity"
        }
    ]
}
2
  • thanks a lot, that forks just fine. can you help me one more time? do you know what is catType for query activities? cause I also need this done for query activities as well – Viktor Husiev Mar 2 at 8:54
  • 1
    Found it, it's queryactivity – Viktor Husiev Mar 2 at 9:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.