1

I would like to list all data extensions via rest api but I didn't find anything about it.

I need only the name and customer key or id.

I appreciate if someone can help me.

2 Answers 2

3

So officially you will not be able to get a list of Data Extensions via REST API, but there is an undocumented endpoint that can get it for you.

Note on undocumented endpoints:
Please note that all undocumented endpoints are not officially supported or maintained by SFMC. So at any moment, the endpoint could be altered, removed, broken or throttled - making it impractical to use this for anything that needs to be reliable or integral in a process. To this extent, I would only recommend this for adhoc development uses, especially considering that these endpoints were not made with the idea of public consumption so they may not be optimized for significant volume or frequency.

Caveat on the endpoints

That being said, I also want to note that there are a few caveats that come with this endpoint:

  1. The id returned is not the normal GUID you see from the official endpoints, but is instead otherwise 'encoded' - so depending on the endpoint there is the possibility that it may not transfer correctly. (Most of the endpoints I have tried this id with have accepted it without issue though.)
  2. The information in this endpoint is very limited and is not a 1:1 match with the SOAP API
  3. This endpoint will literally return ALL the data extensions / custom objects inside the account, including dataviews and other internal objects that we do not have access to. This can lead to issues depending on what you are trying to do.
  4. There is no way to filter this endpoint other than to add an 'id' to the end of it, which will then return just the info for that specific DE. To note though, there is no increase in available info by doing it against a single DE.
  5. By adding {{deID}}/field to the end of the endpoint, you can get a list of the fields inside of the DE along with the field meta data.

Now on to the endpoint itself:

GET /legacy/v1/beta/object/
Host: {{subDomain}}.rest.marketingcloudapis.com
Authorization: Bearer {{authToken}}

Which will return an object like:

{
    "startIndex": 0,
    "itemsPerPage": 50,
    "totalResults": 13904,
    "entry": [
        {
            "id": "xxxxxxxxxxxxxxxxxxxxxxxx",
            "key": "myKey",
            "dataExtensionName": "myName",
            "isSendable": true,
            "sendableDataExtensionField": "EmailAddress",
            "sendableSubscriberField": "_SubscriberKey",
            "isTestable": false,
            "isPublic": false,
            "isPlatformObject": false
        },
        {
            "id": "xxxxxxxxxxxxxxxxxxxxxxxx",
            "key": "myKey2",
            "dataExtensionName": "myName2",
            "isSendable": true,
            "sendableDataExtensionField": "EmailAddress",
            "sendableSubscriberField": "_SubscriberKey",
            "isTestable": false,
            "isPublic": false,
            "isPlatformObject": false
        }
    ]
}

Now as you may have noticed, the parent object denotes "itemsPerPage": 50 which would normally mean that you get a max of 50 per page, but this one does not seem to recognize pagination like it should and instead returns the full amount - in this case 13,904 data extensions inside the return object.

There is not a big amount of data for each DE here, but if you are looking for a simple bulk listing of name/key/id, this is definitely a possibility and the ability to grab the field data is great opportunity too - but it is not as comprehensive as the SOAP one, but you can match to SOAP via the CustomerKey to supplement this call.

Once again though...this is NOT a comprehensive solution nor is it a viable one for more than just exploration or development. Please do not implement this into a regular process or anything in production.

1
  • Ran across the "itemsPerPage": 50" issue as well. You don't get a count object for proper API pagination, nor can you pass $pageSize and $page as other documented REST APIs. Looks like the preferred way is via SOAP (BARF). This is still neat to see. Just wish SFMC would make their REST API more comprehensive. Commented Oct 25, 2023 at 17:31
1

First of all: you will not be able to list all the data extensions in a single API call, and definitely not using REST. Using SOAP will get you there, but requires a combination of few different calls.

Initially you will need to retrieve data extension folders, using guidance found here. Here is also a thread here on SFSE, which might be helpful.

Then, for each folder, you will need to retrieve the data extensions within, using another SOAP call, where you provide the folder ID as CategoryID, like in this example:

<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Header>
    <Security xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
        <UsernameToken>
            <Username>[user name]</Username>
            <Password>[user password]</Password>
        </UsernameToken>
    </Security>
</Header>
<Body>
    <RetrieveRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
        <RetrieveRequest>
            <ObjectType>DataExtension</ObjectType>
            <Properties>CustomerKey</Properties>
            <Properties>Name</Properties>
            <Filter xsi:type="SimpleFilterPart">
                <Property>CategoryID</Property>
                <SimpleOperator>equals</SimpleOperator>
                <Value>[category id value]</Value>
            </Filter>
        </RetrieveRequest>
    </RetrieveRequestMsg>
</Body>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .