# Order item data extension

An order item data extension is an object that lets you specify any key-value pairs you want. Order data extensions are optional and enable your organization to capture more robust information about your order items.

 To get started with this API, create a data extension for the order items you previously created.

## Create an order item data extension

 - [POST /v2.1/orderItems/{orderItemRef}/extensions/{dataExtensionName}](https://api-docs.sitecore.com/cdp/order-rest-api/order-item-data-extension/createorderitemdataextension.md): Creates an order item data extension. 

 To avoid creating key-value pairs that already exist in the data extension for an order item, first retrieve all the data extensions for an order item 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 "withWarranty": true in the object, With Warranty 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 specification. 
 - In camel case. 

 ### Example request body 
 Here's an example request body: 
 
{
 "withWarranty": true,
 "color": "obsidian", 
 "capacityInGb": 128 
}
 
 This creates three key-value pairs for the order item.

## Retrieve an order item data extension

 - [GET /v2.1/orderItems/{orderItemRef}/extensions/{dataExtensionName}](https://api-docs.sitecore.com/cdp/order-rest-api/order-item-data-extension/retrieveorderitemdataextension.md): Retrieves a data extension for an order item.

## Update an order item data extension

 - [PUT /v2.1/orderItems/{orderItemRef}/extensions/{dataExtensionName}](https://api-docs.sitecore.com/cdp/order-rest-api/order-item-data-extension/putorderitemdataextension.md): Fully updates a data extension for an order item, replacing the entire resource including all the key-value pairs with the data you send in the request.

To update certain key-value pairs only, use the Partially update a data extension endpoint instead.

## Partially update an order item data extension

 - [PATCH /v2.1/orderItems/{orderItemRef}/extensions/{dataExtensionName}](https://api-docs.sitecore.com/cdp/order-rest-api/order-item-data-extension/updateorderitemdataextension_1.md): Partially updates a data extension for an order, replacing only those key-value pairs in the resource that you provide in the request.

## Delete an order item data extension

 - [DELETE /v2.1/orderItems/{orderItemRef}/extensions/{dataExtensionName}](https://api-docs.sitecore.com/cdp/order-rest-api/order-item-data-extension/deleteorderitemdataextension.md): Deletes the data extension for an order item, including all the key-value pairs in the data extension.

To delete certain key-value pairs only, use the Delete key-value pairs from a data extension endpoint instead.

## Delete key-value pairs from an order item data extension

 - [DELETE /v2.1/orderItems/{orderItemRef}/extensions/{dataExtensionName}/fields](https://api-docs.sitecore.com/cdp/order-rest-api/order-item-data-extension/updateorderitemdataextension.md): Deletes the key-value pairs you provide in the name query parameter from a data extension for an order item.

For example, if your data extension contains the firstTimeOrder and storeLocation keys, you can delete both keys and their values by making the following request:



 {baseURL}/v2.1/orders/{orderRef}/extensions/{dataExtensionName}/fields?name=firstTimeOrder|storeLocation

If you don't provide the query parameter, this operation will empty the data extension: the data extension itself will not be deleted, but all the key-value pairs in it will.

## Retrieve the URL for an order item's data extension

 - [GET /v2.1/orderItems/{orderItemRef}/extensions](https://api-docs.sitecore.com/cdp/order-rest-api/order-item-data-extension/retrieveorderitemdataextensions.md): Retrieves the URL for the order item's data extension. This lets you check if the data extension exists.

