Uncategorized

Filtered Data Extension automatically refresh via REST API

So, in the past, the only way you could refresh a filtered Data Extension was utilizing the Filter Activity (in Automation Studio) or via the UI, performing a manual refresh.

Now admittedly this is not too bad of a hurdle, but it does not help if you already built out the filter inside the UI or otherwise outside of a Filter Activity.

Surprisingly, there is a public facing, undocumented endpoint that will let you refresh your filtered Data Extensions with the Object ID.

First you need to collect the ObjectID of your Filtered DE via a REST endpoint:





GET /data/v1/customobjectdata/key/{{yourFilteredDEKey}}/rowset?$pageSize=1
Host: {{yourSubDomain}}.rest.marketingcloudapis.com
Authorization: Bearer {{oauthToken}}

This will return a JSON containing the needed ObjectID:





{
    "links": {
        "self": "/v1/customobjectdata/token/{{yourFilteredDEKey}}/rowset?$page=1",
        "next": "/v1/customobjectdata/token/{{yourFilteredDEKey}}/rowset?$page=2"
    },
    "requestToken": "XXXXXXX",
    "tokenExpireDateUtc": "XXXXXXXX",
    "customObjectId": "{{myCustomObjectID}}",
    "customObjectKey": "{{myCustomObjectKey}}",
    "pageSize": 1,
    "page": 1,
    "count": X,
    "items": [
        {
            "keys": {
                "myKey": "00544"
            },
            "values": {
                "Field1": "40.815400000",
                "Field2": "-73.045600000",
                "Field3": "0.220696498"
            }
        }
    ]
}

As REST does not have a specific Endpoint to get DE properties info, I had to go about this as if we wanted to gather a Rowset, but set a pagesize of 1 to keep the call succinct and reduce the draw and needless info.

The part we want to look at is the “customObjectId” property. This contains the ID we need for our next call.

To be fair there IS a SOAP call that can be used to gather this info if you prefer, but I used the above to keep everything running using REST.

Next step is the refresh call:





POST /email/v1/filteredCustomObjects/{{myObjectID}}/refresh
Host: {{yourSubDomain}}.rest.marketingcloudapis.com
Authorization: Bearer {{oauthToken}}

Which should return a JSON like below:





{
    "id": "XXXXXXXX",
    "filterActivityInstance": {
        "id": "XXXXXXXX",
        "asyncID": 8675309
    }
}

This shows that the call was a success and that the filtered DE has now been refreshed. The time it takes for the refresh to finish is dependent on the complexity and size of the DE.

Leave a Reply

Your email address will not be published. Required fields are marked *