Create a Data Extension

Use a data extension to store information about your subscribers.

Keep these considerations in mind when you use SOAP API to create data extensions:

  • Limit data extension external keys to 36 characters. You can specify an external key that exceeds this limit, but doing so can negatively impact other processes.
  • Don't use Date values as primary keys. When you retrieve a column that contains the Date data type, SOAP API returns a value that’s rounded to the nearest second, followed by AM or PM. This behavior occurs even when the source timestamp contains millisecond data. As a result, if you use a Date column as a primary key, it can prevent you from retrieving unique rows.

This sample SOAP envelope represents a request to create a data extension called DataExtensionFromAPI. The data extension contains 4 fields: EmailAddress, ChannelUser, ChannelUser_EmailAddress, and Demographic_Address.

If the API accepts the request to create a data extension, the response includes the external key, name, and fields for the data extension.

This sample SOAP envelope creates a data extension with a non-nullable field by including IsPrimaryKey and IsRequired values.

This sample SOAP envelope includes an example of data extension field types.

This example shows how to create a data extension that uses row-based data retention. In a data extension that uses row-based retention, individual rows are deleted when their ages exceed the specified period.

This example shows how to create a data extension that uses object-based data retention. In a data extension that uses object-based retention, all of the content in the data extension is deleted after the specified period. Optionally, you can delete the data extension itself (as opposed to deleting all of the data in it) at the end of the retention period by setting the value of DeleteAtEndOfRetentionPeriod to true.

Compared to the row-based retention code example, this example omits the RowBasedRetention property and adds the ResetRetentionPeriodOnImport and DeleteAtEndOfRetentionPeriod properties.

When you create a data extension field that contains a date value, pass the time in 24-hour format.