0

I'm trying to retrieve all contacts from my account in Marketing Cloud via API but I can't see the operation.

I found this for REST API: https://developer.salesforce.com/docs/atlas.en-us.mc-apis.meta/mc-apis/schemasCollection.htm

And this for SOAP: https://developer.salesforce.com/docs/atlas.en-us.noversion.mc-apis.meta/mc-apis/list.htm --> I suppose I could call All Subscribers list but what about the contacts?

Is there any solution for REST API?

Thanks!

1

I mean, yes you could, but it would take forever and require a TON of looping through multiple calls. You would use the documented REST endpoint (no direct link) of:

/contacts/v1/addresses/search/{{attributeName}}

This endpoint shows a requirement of a body containing a filterConditionOperator and filterConditionValue - but you can make the call without these and it will return all contacts. The issue is that the default page size is 50, so using that, it would take an extremely long time with a crazy amount of calls to get all your contacts.

You can adjust the returned pageSize via the following params attached to the endpoint though: ?$page=1&$pageSize=2500 but with the large amount of data passed back per subscriber, this can make your API call reach closer and closer to timing out.

Plus, even still, with a cap of (I think) 10,000 - that is still small potatoes compared to the average of a couple million contacts that most people have. Meaning if you could safely hit the maximum of 10k per call, you would still need 100 calls just to collect 1 million records. Lets say each call is around 30 seconds just to get the data, then lets add another 30 seconds for processing and concatenation of the returned arrays - we are looking at nearly 2 hours for a million records - and that doesn't account for increased processing as the array grows in size each time records are added to it.

This process could take days to fully run and during that time, you run into risks of contacts being updated or deleted or added that you will miss. It also has a risk of erroring in a call and potentially tossing the whole process up to that point or even missing sections of it completely and leaving gaps that you may not even know about.

Instead of using the actual REST service, what I would do to get ALL contacts is first create a mobile list that has the following filter condition:

Contact Key is not null

(Here is a good resource talking about this type of a solution for gathering contacts via Mobile Lists)

This should grab every single contact in your account into a single mobile list. If this is a 'one time' need, you can just export this here onto the FTP and then move the file wherever you need for your system to grab it.

If it is a multiple use thing, you could then create a SQL query to move this data from a mobile list into a Data Extension as you can use the List name similar to a Data Extension inside of SQL Queries.

SELECT ContactKey
FROM [myMobileListName]

Then you can do a data extract on this DE and use a File Transfer to push to the SFMC FTP or any other FTP location you need to send this to. You can then use your system to grab the file.

| improve this answer | |
  • Hi Gortonington, thanks for this master explanation. Would be feasible to make an API call to retrieve the data from that DE with all the contacts or would I risk the timeouts again? Thanks! – Mrquestion Jun 5 at 8:59
  • @Mrquestion - you would run into pretty much the same issues around requiring hundreds of API calls - causing a very long and process heavy event. It IS possible to do, but there is significant risk. It is less risk than doing it directly via the endpoint I listed as there would not be new contacts or edits happening at the same time, but the large issues would still remain due to volume. – Gortonington Jun 5 at 13:12

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.