# Create an order data extension

Creates an order data extension.
To avoid creating key-value pairs that already exist in the data extension for an order, first retrieve all the data extensions for an order 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.
- The key-value pairs you include in the object become the extension data. For example, if you include `"firstTimeOrder": true` in the object, **First Time Order** with the value of `true` 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](https://www.rfc-editor.org/rfc/rfc7159) specification.
- In camel case.

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

```
{ 
"firstTimeOrder": true, 
"storeLocation": "London", 
"totalUnits": 8, 
"totalDiscount": "20%"
}
```
This creates four key-value pairs for the order.

Endpoint: POST /v2.1/orders/{orderRef}/extensions/{dataExtensionName}
Version: v2.1
Security: BasicAuth

## Description:

  - `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.The key-value pairs you include in the object become the extension data. For example, if you include "firstTimeOrder": true in the object, First Time Order with the value of true becomes extension data.Supported data types for the values:string, for example "level2"boolean, for example trueinteger, for example 9floating-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.

  - `Example request body` ()
    Here's an example request body: { 
"firstTimeOrder": true, 
"storeLocation": "London", 
"totalUnits": 8, 
"totalDiscount": "20%"
}
{ 
"firstTimeOrder": true, 
"storeLocation": "London", 
"totalUnits": 8, 
"totalDiscount": "20%"
} This creates four key-value pairs for the order.

## Security:

  - `BasicAuth` (unknown)
    http basic

## Path parameters:

  - `orderRef` (string, required)

  - `dataExtensionName` (string, required)

## Request fields (application/json):

  - `{exampleKey1}` (string | boolean | integer | number)
    A key-value pair of your choice.
Supported data types for the values: string, boolean, integer, floating-point number.
Example: `"firstTimeOrder": true`
    Example: {exampleValue1}

  - `{exampleKey2}` (string | boolean | integer | number)
    A key-value pair of your choice.
Supported data types for the values: string, boolean, integer, floating-point number.
Example:`"storeLocation": "London"`
    Example: {exampleValue2}

## Response 200:

  - `200` (unknown)
    Resource successfully created

## Response 200 fields (application/json):

  - `name` (string)
    The name of the data extension.
    Example: ext

  - `href` (string)
    The URL of the order extension.
    Example: https://api-engage-eu.sitecorecloud.io/v2.1/orders/f7aabbca-1c1b-4fc2-be72-3e16294a4f03/extensions/ext

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

  - `key` (string)
    The value `"default"`.
    Example: default

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

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

  - `{exampleKey1}` (string | boolean | integer | number)
    A key-value pair of your choice.
Supported data types for the values: string, boolean, integer, floating-point number.
Example: `"firstTimeOrder": true`
    Example: {exampleValue1}

  - `{exampleKey2}` (string | boolean | integer | number)
    A key-value pair of your choice.
Supported data types for the values: string, boolean, integer, floating-point number.
Example:`"storeLocation": "London"`
    Example: {exampleValue2}

  - `order` (object)
    The request's first list of orders URL.

  - `order.href` (string)
    Example: https://api-engage-eu.sitecorecloud.io/v2.1/orders?guestRef=2d7de9df-45a2-45ea-872c-30e45139007d&offset=1&limit=10

## Response 400:

  - `400` (unknown)
    Bad request

## Response 400 fields (application/json):

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

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

  - `message` (string)
    description message
    Example: firstName: may not be null.

  - `developerMessage` (string)
    Error description for developers.
    Example: firstName: may not be null.

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

## Response 401:

  - `401` (unknown)
    Unauthorized request

## Response 401 fields (application/json):

  - `status` (string)
    The HTTP request status.
    Example: UNAUTHORIZED

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

  - `message` (string)
    Error description.
    Example: Authentication credentials are required to access the resource. All requests must be authenticated.

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

