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.
Thanks for your sharing! I’d tried to perform exactly what you shared, however, i am getting “Insufficient privileges to complete this action.” error. May i know which privilege i should grant for this API?
Search thru internet and doesn’t seems like there is any documentation for this. Maybe i’ve missed out.
Thanks for your help!
You will want to make sure that you have the correct scoping in your auth call and in your package (https://developer.salesforce.com/docs/atlas.en-us.mc-app-development.meta/mc-app-development/access-token-s2s.htm). I believe it would likely need to include at least Data Extensions Read/Write and possibly Automations read/write/execute. See here for a good doc on available permissions (https://developer.salesforce.com/docs/atlas.en-us.mc-app-development.meta/mc-app-development/data-access-permissions.htm)
Great article, thanks for publishing. I’ve had to add the following permissions in order to make the api calls
Journeys: Read, Write, Execute
List and Subscribers: Read, Write
Data Extensions: Read, Write
Thanks for this. This looks like something I was looking for.