Skip to main content

Use the create guest function in Sitecore CDP REST API

Abstract

Provides a cURL command to create a guest in Sitecore CDP REST API (Data model 2.1).

You can use the Guest REST API to perform a create guest function to create a Guest record.

Warning

The Guest REST API does not validate whether a guest exists when you use the create guest function. To prevent the creation of duplicate guests, use the locate guests function to return guests using their email address or other identifying information.

To create a guest in Sitecore CDP, use the following:

POST: https://apiEndpoint/v2/guests

Create a guest using Personally Identifiable Information (PII):

$curl  --request POST 'https://{apiEndpoint}/v2/guests' \
--header 'Content-Type: application/json' 
--data-raw '
 {
    "guestType": "customer",
    "title": "Mr",
    "firstName": "Jack",
    "lastName": "Smith",
    "gender": "male",
    "dateOfBirth": "1976-10-28T00:00:00.000Z",
    "emails": [
        "jack.smith@boxever.com"
    ],
    "phoneNumbers": [
        "0851234567"
    ],
    "nationality": "Irish",
    "passportNumber": "PZ4A9565",
    "passportExpiry": "2019-01-01T00:00Z",
    "street": [
        "Apartment 15",
        "West Drive Avenue"
    ],
    "city": "Dublin",
    "country": "IE",
    "postCode": "D2",
    "state": "Dublin",
    "subscriptions": [
        {
            "name": "default",
            "channel": "EMAIL",
            "pointOfSale": "default",
            "status": "SUBSCRIBED",
            "effectiveDate": "2012-08-23T16:17:16.000Z"
        }
    ]
}'

Create a guest using identifiers:

$curl  --request POST 'https://{apiEndpoint}/v2/guests' \
 --header 'Content-Type: application/json' 
--data-raw '
 {
   "guestType":"customer",
   "subscriptions":[
      {
         "name":"default",
         "channel":"EMAIL",
         "pointOfSale":"default",
         "status":"SUBSCRIBED",
         "effectiveDate":"2012-08-23T16:17:16.000Z"
      }
   ],
   "identifiers":[
      {
         "provider":"ProfileSystem",
         "id":"B7524AE6-CF1C-440F-B1A2-0C9D42F5CB41",
         "expiryDate":"2016-08-23T16:17:16.000Z"
      }
   ]
}'

The following is a 201 Created response with Personally Identifiable Information (PII):

{
   "href":"https://{apiEndpoint}/v2/guests/9d94ee11-7043-4b71-980c-a777d00a7b46",
   "ref":"9d94ee11-7043-4b71-980c-a777d00a7b46",
   "createdAt":"2010-03-07T16:15:11.000Z",
   "modifiedAt":"2012-08-23T16:17:16.000Z",
   "firstSeen":"2010-03-07T16:15:11.000Z",
   "lastSeen":"2012-08-23T16:17:16.000Z",
   "guestType":"customer",
   "title": "Mr",
    "firstName": "Jack",
    "lastName": "Smith",
    "gender": "male",
    "dateOfBirth": "1976-10-28T00:00:00.000Z",
    "emails": [
        "jack.smith@boxever.com"
    ],
    "phoneNumbers": [
        "0851234567"
    ],
    "nationality": "Irish",
    "passportNumber": "PZ4A9565",
    "passportExpiry": "2019-01-01T00:00:00.000Z",
    "street": [
        "Apartment 15",
        "West Drive Avenue"
    ],
    "city": "Dublin",
    "country": "IE",
    "postCode": "D2",
    "state": "Dublin",
    "subscriptions": [
        {
            "name": "default",
            "channel": "EMAIL",
            "pointOfSale": "default",
            "status": "SUBSCRIBED",
            "effectiveDate": "2012-08-23T16:17:16.000Z"
        }
    ]
}

The following is a 201 Created response with identifiers:

{   
"href":"https://{apiEndpoint}/v2/guests/9d94ee11-7043-4b71-980c-a777d00a7b46",
   "ref":"9d94ee11-7043-4b71-980c-a777d00a7b46",
   "createdAt":"2010-03-07T16:15:11.000Z",
   "modifiedAt":"2012-08-23T16:17:16.000Z",
   "firstSeen":"2010-03-07T16:15:11.000Z",
   "lastSeen":"2012-08-23T16:17:16.000Z",
   "guestType":"customer",
   "subscriptions":[
      {
         "name":"default",
         "channel":"EMAIL",
         "pointOfSale":"default",
         "status":"SUBSCRIBED",
         "effectiveDate":"2012-08-23T16:17:16.000Z"
      }
   ],
   "identifiers":[
      {
         "provider":"ProfileSystem",
         "id":"B7524AE6-CF1C-440F-B1A2-0C9D42F5CB41",
         "expiryDate":"2016-08-23T16:17:16.000Z"
      }
   ]
}