# Guest API

Use the Guest REST API to create, retrieve, update, and delete guest data in Sitecore CDP.

This REST API lets you interact with:
   - The guest object. The guest object is the core entity of Sitecore CDP. It stores the personal data of a customer, and all relevant transactional and behavioral data is linked in a guest profile.
   - The guest data extension object. A guest data extension is an object that lets you specify any key-value pairs you want. Guest data extensions are optional and enable your organization to capture more robust information about your guests.

After capturing guest information, Sitecore CDP users can:
   - View the captured data in the [guest profile](https://doc.sitecore.com/cdp/en/users/sitecore-cdp/view-a-guest-profile-in-sitecore-cdp.html).
   - Use the captured data to [build segments of guests](https://doc.sitecore.com/cdp/en/users/sitecore-cdp/introduction-to-batch-segmentation.html).
   - [Export audience data](https://doc.sitecore.com/cdp/en/users/sitecore-cdp/audience-export.html) to activate audiences outside Sitecore CDP.

Note the following:
   - To use this REST API, you must [authenticate](https://doc.sitecore.com/cdp/en/developers/api/authentication-and-authorization.html) your API requests.
   - All API requests are made in your production environment.
   - This reference documentation describes Sitecore CDP functionality for data model 2.1.

 For more information, see the [official Sitecore CDP developer documentation](https://doc.sitecore.com/cdp/en/developers/api/index-en.html).
## Authentication 
The Guest REST API uses basic authentication.  
Basic authentication involves sending a user name and a password with every request.  
To find your user name and password, in Sitecore CDP, on the navigation pane, click **Settings** > **API access**:  
 - The user name is the **Client key**.  
- The password is the **API token**.  
You must include the user name and password in every request you make. For example:  
```  
curl -X GET '{baseURL}/v2/guests' \  
-u '{YOUR_USERNAME}:{YOUR_PASSWORD}' \  
-H 'Accept: application/json'  


Version: v2.1
License: Apache 2.0

Metadata:
  - product: CDP

## Servers

Production server AP
```
https://api-engage-ap.sitecorecloud.io
```

Production server EU
```
https://api-engage-eu.sitecorecloud.io
```

Production server JP
```
https://api-engage-jpe.sitecorecloud.io
```

Production server US
```
https://api-engage-us.sitecorecloud.io
```

## Security

### BasicAuth

Type: http
Scheme: basic

### BearerToken

Type: http
Scheme: bearer
Bearer Format: JWT

## Download OpenAPI description

 - [Guest API](https://api-docs.sitecore.com/_bundle/cdp/guest-rest-api/index.yaml)

## Guest

 - [POST /v2.1/guests](https://api-docs.sitecore.com/cdp/guest-rest-api/guest/createguest.md): Creates a guest. The REST API does not check whether a guest already exists in Sitecore CDP when you create a guest. To avoid creating duplicates, first retrieve guests by their email address or other
 - [GET /v2.1/guests](https://api-docs.sitecore.com/cdp/guest-rest-api/guest/retrieveguests.md): Retrieves a maximum of 100 of the most recent guests. We recommend that you retrieve guests by their email address or other identifying information using query parameters before you create a guest. Th
 - [GET /v2.1/guests/{guestRef}](https://api-docs.sitecore.com/cdp/guest-rest-api/guest/retrieveguest.md): Retrieves the full guest record of a guest, including any guest data extensions.
 - [PUT /v2.1/guests/{guestRef}](https://api-docs.sitecore.com/cdp/guest-rest-api/guest/putguest.md): Fully updates a guest, 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 guest
 - [PATCH /v2.1/guests/{guestRef}](https://api-docs.sitecore.com/cdp/guest-rest-api/guest/updateguests.md): Partially updates a guest, replacing only those fields in the resource that you provide in the request. For example, you can use this request to update the guest's array of phone numbers when they e
 - [DELETE /v2.1/guests/{guestRef}](https://api-docs.sitecore.com/cdp/guest-rest-api/guest/deleteguest.md): Deletes a guest record and all entities associated with the guest including orders, sessions, and events. **This is an irreversible operation. After you delete a guest record, you cannot retrieve the
## Guest data extension

 - [POST /v2.1/guests/{guestRef}/extensions](https://api-docs.sitecore.com/cdp/guest-rest-api/guest-data-extension/createguestdataextension.md): 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'
 - [GET /v2.1/guests/{guestRef}/extensions](https://api-docs.sitecore.com/cdp/guest-rest-api/guest-data-extension/retrieveguestdataextensions.md): Retrieves the URLs for each of the guest's data extensions. We recommend that you retrieve the URLs using the `expand=true` query parameter to check that the keys you intend to create when you Create
 - [GET /v2.1/guests/{guestRef}/extensions/{dataExtensionName}](https://api-docs.sitecore.com/cdp/guest-rest-api/guest-data-extension/retrieveguestdataextension.md): Retrieves a data extension for a guest.
 - [PUT /v2.1/guests/{guestRef}/extensions/{dataExtensionName}](https://api-docs.sitecore.com/cdp/guest-rest-api/guest-data-extension/putguestdataextension.md): Fully updates a data extension for a guest, 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 Part
 - [PATCH /v2.1/guests/{guestRef}/extensions/{dataExtensionName}](https://api-docs.sitecore.com/cdp/guest-rest-api/guest-data-extension/updateguestdataextension.md): Partially updates a data extension for a guest, replacing only those key-value pairs in the resource that you provide in the request. If multiple source systems use the same data extension, use this
 - [DELETE /v2.1/guests/{guestRef}/extensions/{dataExtensionName}](https://api-docs.sitecore.com/cdp/guest-rest-api/guest-data-extension/deleteguestdataextension.md): Deletes the data extension for a guest, 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
 - [DELETE /v2.1/guests/{guestRef}/extensions/{dataExtensionName}/fields](https://api-docs.sitecore.com/cdp/guest-rest-api/guest-data-extension/deleteguestdataextensionfields.md): Deletes the key-value pairs you provide in the `name` query parameter from a data extension for a guest. For example, if your data extension contains the `vipMember` and `loyaltyMember` keys, you can
