# Create a data extension

Creates a data extension for a guest. You can create up to six data extensions.

To avoid creating key-value pairs in a data extension that already exist within a guest profile, first retrieve a guest's collection of data extensions to check that the keys you intend to create are unique.

### Creating the request body
In the request body, you must provide one object. This object represents the data extension. Note the following about the object:
- Can contain primitive values only. You cannot nest objects. If you need to group key-value pairs, use prefixes for the key names.
- Can contain a maximum of 100 key-value pairs.
- Must contain the name key. This is the name of the data extension.
  - If you send extension data from one source, set the value for name to ext.
  - If you send extension data from multiple sources, you can create up to six data extensions by setting the value for name to one of the following: ext, ext1, ext2, ext3, ext4, ext5.
- The other key-value pairs you include in the object become the extension data. For example, if you include "loyaltyTier": "level2" in the object, Loyalty Tier with the value of level2 becomes extension data.
- Supported data types for the values:
  - string, for example "level2"
  - boolean, for example true
  - integer, for example 9
  - floating-point number, for example 99.9
 #### Naming keys
The keys you enter in the request body must be:
- Alphanumeric A-Z,a-z,0-9] as per the [JSON RFC 7159 specification.
 - In camel case.
- Unique across all data extensions within a guest profile. For example, if ext contains the vipMember key, you must not use that key in any other data extensions for the same guest.

### Example request body
Here's an example request body:


{
"name": "ext",
"vipMember": true,
"loyaltyTier": "level2",
"rewardBalance": 5012.25,
"loyaltyNumber": 3452
}

This creates four key-value pairs in the ext data extension for the guest.
### Finding the data in Sitecore CDP
  You can find the created data in Sitecore CDP by clicking Guests > the guest profile you created the data for > Properties > Additional information:
 - The ext data displays in Data extension group.
 - The ext1 data displays in Data extension group 1.
 - The ext2 data displays in Data extension group 2.
 - The ext3 data displays in Data extension group 3.
 - The ext4 data displays in Data extension group 4.
 - The ext5 data displays in Data extension group 5.

 ### Multiple sources
 You can send extension data from multiple sources. For example, your organization might want to send extension data both from a loyalty system to capture loyalty data, and from a Customer Relationship Management (CRM) system to capture email preferences, alternative mailing addresses, and so on.

 To send data from multiple sources, we recommend that you use a different data extension name for each source system. For example, use the ext data extension for the loyalty system data, and use the ext1 data extension for the CRM data.

Endpoint: POST /v2.1/guests/{guestRef}/extensions
Version: v2.1
Security: BasicAuth

## Path parameters:

  - `guestRef` (string, required)
    The guest reference. This is a unique identifier of the guest record. If you don't know the guest reference, first retrieve guests.
    Example: "f7aabbca-1c1b-4fc2-be72-3e16294a4f03"

## Request fields (application/json):

  - `name` (string, required)
    The name of the data extension.
    Enum: "ext", "ext1", "ext2", "ext3", "ext4", "ext5"

  - `{exampleKey1}` (string,boolean,integer,number)
    A key-value pair of your choice.
 Example: "vipMember": true
    Example: "{exampleValue1}"

  - `{exampleKey2}` (string,boolean,integer,number)
    A key-value pair of your choice.
 Example: "loyaltyTier": "level2"
    Example: "{exampleValue2}"

## Response 201 fields (application/json):

  - `createdAt` (string)
    The date and time when the resource was created in Sitecore CDP.
    Example: "2024-01-01T16:17:16.000Z"

  - `guest` (object)

  - `guest.href` (string)
    The URL of the guest.
    Example: "https://api-engage-eu.sitecorecloud.io/v2.1/guests/f7aabbca-1c1b-4fc2-be72-3e16294a4f03"

  - `href` (string)
    The URL of the guest extension.
    Example: "https://api-engage-eu.sitecorecloud.io/v2.1/guests/f7aabbca-1c1b-4fc2-be72-3e16294a4f03/ext1"

  - `key` (string)
    You must set this to default.
    Example: "default"

  - `modifiedAt` (string)
    The date and time when the resource was last updated in Sitecore CDP.
    Example: "2024-01-01T16:17:16.000Z"

  - `name` (string)
    The name of the data extension. You can only use a name once in a collection.
    Example: "ext"

  - `ref` (string)
    Guest extension reference.
    Example: "6a5cb3c2-1a4a-56d8-8a01-1ede232b9db2"

  - `{exampleKey1}` (string,boolean,integer,number)
    A key-value pair in the data extension.
 Example: "vipMember": true
    Example: "{exampleValue1}"

  - `{exampleKey2}` (string,boolean,integer,number)
    A key-value pair in the data extension.
 Example: "loyaltyTier": "level2"
    Example: "{exampleValue2}"

## Response 400 fields (application/json):

  - `code` (integer)
    The HTTP response status code.
    Example: 400

  - `developerMessage` (string)
    Error description for developers.
    Example: "Attribute name is invalid (value must be one of ext,ext1,ext2,ext3,ext4,ext5)."

  - `message` (string)
    Error description.
    Example: "name: value must be one of ext,ext1,ext2,ext3,ext4,ext5"

  - `moreInfoUrl` (string)
    URL to get more information about the error.
    Example: "https://support.sitecore.com"

  - `status` (integer)
    The HTTP request status.
    Example: 400

## Response 409 fields (application/json):

  - `code` (integer)
    The HTTP response status code.
    Example: 409

  - `developerMessage` (string)
    Error description for developers.
    Example: 409

  - `message` (string)
    Error description.
    Example: "Data extension ext1 already exists."

  - `moreInfoUrl` (string)
    URL to get more information about the error.
    Example: "https://support.sitecore.com"

  - `status` (integer)
    The HTTP request status.
    Example: 409


