Create a Data Extension Using AMPscript and the SOAP Web Service API

Use AMPscript contained in a landing page to interact with the web service API to create a data extension. For example, you can create unique sendable data extensions that receive information from another data system or integration and conduct sends based on the information imported into those data extensions. The AMPscript pulls the information from the other data source and imports it into the sendable data extensions. You can then include the sendable data extensions inside a triggered send definition to send emails including personalized information.

Use this sample AMPscript as a model to create your own script.

The sample code below creates a sendable data extension using a subscriber key.

If you work in an Enterprise 2.0 account and want to use data retention with your data extensions, add the ClientID property to the data extension object with the appropriate ClientID value. Add the AMPscript below to the sample code above to make sure the correct user permissions are used with the data retention policy. You can hover your mouse over the user in the Setup section of the Salesforce Marketing Cloud application to get the UserID number to include in this code:

You must also set the data retention policy via AMPscript, as demonstrated in this code: