Overview

The Profile service provides a REST interface to store and consume data associated with the customer profiles.

The service stores customer profiles as documents. Each profile document consists of JSON subdocuments related to specific profile aspects. The profile documents are consumed in the same form in which they are stored.

Unlike the Secure Graph service, the Profile service allows you to retrieve all customer profile data with a single request.


API Reference

/{tenant}/profiles

/{tenant}/profiles

head

Returns number of profiles for the specified tenant. Requires scope hybris.profile_view.

/{tenant}/profiles/{profileId}

put

Creates or replaces the entire profile document. Requires scope hybris.profile_manage.

patch

Creates or updates part of the profile document. Requires scope hybris.profile_manage.

get

Get a given profile document. Requires scope hybris.profile_view.

delete

Deletes a given profile document. Requires scope hybris.profile_manage.

/{tenant}/profiles/{profileId}/{propertyPath}

put

Overrides a profile property or creates a profile document if it does not exist. Requires scope hybris.profile_manage.

get

Get a given property value from a profile document. Requires scope hybris.profile_view.

delete

Deletes a given property from a profile document. Requires scope hybris.profile_manage.


Profile Explorer

The Profile Explorer is a debugging tool that displays the profile data stored in the document. Use this tool to browse the data stored in the profile, and to verify that the system stores the data within the expected document.

For more details about the Profile Explorer, and instructions how to use it, see the Profile Explorer documentation.


Profile document

Profile metadata

Every profile document contains a section named metadata. The metadata section includes two properties:

  • consentReference: The consent reference used for handling consents for the particular profile
  • lastUpdatedAt: This value displays the date and time of the last profile update in the ISO 8601 format

The system also updates the metadata.lastUpdatedAt field with every change introduced to the profile document.


Consent definition

Before the Profile service can store and consume profile information, you must first define consents for the collection of data related to, for example, the customer's storefront activity. Consent definition requires these actions:

  1. Create a relevant profile schema in the Enricher Authorization service.
    For more information about how to create or modify a schema, see the Schema management section in the Enricher Authorization service documentation.
  2. When the customer grants consent to the created schema, the service starts to collect relevant data.
    For more information about how to grant and revoke consents, see the Tutorial section in the Consent service documentation.


Consent handling

The Profile service stores and consumes customer profile data organized in the form of JSON documents. In accordance with the applicable data protection regulations, customers have the right to access their data and manage their privacy settings at any time. The Profile service receives information about a user's consents from the Consent service and, within a single document, displays only the data for which the user grants consent.

The Profile service respects consents, which you can manage in the Consent service.

The Profile service allows you to write data to a user's profile document and read such data. Depending on the user's privacy settings, the resulting JSON document contains only the relevant subdocuments, which reflect the user's consents. The service verifies consents only on the first and second document nesting levels. Writing to further sub-levels of the document depends upon the first-level and second-level privacy settings.

First-level consents

To start writing any data, initially, there must exist a consent for a property on the first nesting level of the document. Failing to define a consent of the first level prevents writing to further sub-levels of the document. Also, revoking consent on the first level prevents adding information on lower levels. Define a consent for a first-level property to write to this property and to further subdocuments.

Further-level consents

Subdocuments nested on the second and lower levels of the profile document do not require defined consents at all. However, if you decide to define such consents in order to manage privacy settings in greater granularity, the service respects them up to the second level only. If you define a consent on both the first and the second levels, the user must grant both consents to allow writing to the second level and further sub-levels of the document. If the user revokes consent on a selected level, writing to a property nested on this level and to its further sub-levels is not possible.

Example

  1. You intend to save the following document in the user's profile:
    {
    "a1Level":{
      "a2Level":{
         "a3Level":"value",
         "b3Level":"value"
      },
      "b2Level":"value",
      "c2Level":{
         "a3Level":"value"
       }
    },
    "b1Level":"value",
    "c1Level":"value"
    }
    
  2. You configure the system with the following consents. The symbol represents a granted consent, the symbol represents a revoked consent, while the - symbol means no defined consent. When you write the document from the example to the Profile service, the system allows and forbids the following parts of the document:

    PropertyConsents on levelsCommentRead/Write
    1st2nd3rd
    a1Level---allow
    a1Level.a2Level--allow
    a1Level.a2Level.a3Level-service respects the user's consents up to the second level only, consent granted on the second levelallow
    a1Level.a2Level.b3Levelservice respects the user's consents up to the second level only, consent granted on the second levelallow
    a1Level.b2Level--consent granted on the first levelallow
    a1Level.c2Level-consent granted on the first level but revoked on the second levelforbid
    a1Level.c2Level.a3Level-consent granted on the first level but revoked on the second levelforbid
    b1Level---forbid
    c1Level---consent not defined on the first levelforbid
  3. The resulting profile document looks like this:

{
  "a1Level":{
     "a2Level":{
        "a3Level":"value"
     },
     "b2Level":"value"
   }
}
The service displays a profile document that respects all of the user's consents. When you try to store some properties, the response may also include a hybris-missing-consents header. The hybris-missing-consents header displays schemas to which the service fails to write, either due to a revoked consent or a schema not defined in the metamodel. The response does not include this header if the service saves all data properly.

The hybris-missing-consents header for the preceding sample request looks as follows:

hybris-missing-consents: https://api.beta.yaas.io/metamodel/v1/profiles/a1Level/c2Level,https://api.beta.yaas.io/metamodel/v1/profiles/b1Level,https://api.beta.yaas.io/metamodel/v1/profiles/c1Level

Data deletion

Revoking a consent entails the deletion of particular data. The following sections describe what happens when you delete a consent reference or revoke a consent.

When you opt out in the Consent service, deleting the consent reference, the service also deletes the entire profile associated with that consent reference.

When you remove your consent for a particular schema, for example, profiles/insights/affinities, the service deletes the entire subdocument with the path insights.affinities and writing to the subdocument is no longer possible.

When you revoke your consent to collect specific data, and later regrant consent, you can write to the subdocument again. However, the previously-deleted document does not reappear.


Profile service events

The Profile service sends notifications about the created, updated, or deleted of profile documents.

Profile document creation event

When you enrich a profile, and there is no profile document for the selected profileId yet, the Profile service stores the event in the Context service with these values:

  • operation: The type of operation, in this case CREATE
  • schema: The schema defining the created profile document, https://api.beta.yaas.io/metamodel/v1/profiles
  • message:
    {
    "profileId": "yourProfileId"
    }
    

The message contains the identifier for the created profile document.

Profile document update event

When you add new properties to a profile document or update existing properties, the Profile service prepares a list of events to send to the Context service. When you update a profile but there is no profile document for the selected profileId yet, the system also sends an event about the creation of a document. The profile document update event contains the following values:

  • operation: The type of operation, in this case UPDATE
  • schema: Because the service only allows the definition of event schemas up to the second level of the profile document, this value provides the most specific schema for changed or added property paths.
  • message:
    {
    "profileId": "yourProfileId",
    "updatedProperties": ["path.to.property1", "path.to.property2"]
    }
    

Properties

  • profileId: The identifier for the updated profile document
  • updatedProperties: This value lists the changed or added property paths that belong to the notification schema. If you change multiple properties under one schema, the system groups them in the payload, and sends a single notification for the found schema group.

Example

This example presents how the Profile service creates notifications.

When you make a PUT or PATCH request on the /mycomicsshop/profiles/123-456 endpoint, with the following data:

{  
   "insights":{  
      "affinities":{  
         "products":{  
            "hulk":{  
               "score":5.0
            }
         },
         "categories":{  
            "marvel":{  
               "score":5.7
            }
         }
      }
   },
   "identities":{  
      "devices":{  
         "device12345":{  
            "deviceType":"gameboy"
         }
      }
   }
}

And the following schemas defined in SAP Hybris Profile:

  • profiles/insights
  • profiles/identities/devices

Your request triggers the following notifications:

  • Notification 1:
    • operation: UPDATE
    • schema: profiles/insights
    • message:
      {
      "profileId": "123-456",
      "updatedProperties": ["insights.affinities.products.hulk.score", "insights.affinities.categories.marvel.score"]
      }
      

  • Notification 2:
    • operation: UPDATE
    • schema: profiles/identities/devices
    • message:
      {
      "profileId": "123-456",
      "updatedProperties": ["identities.devices.device12345.deviceType"]
      }
      
Both the PUT and the PATCH methods update the profile document, and cause the service to send a notification, yet the results of each call are different. For more information, refer to the Create or replace a profile document section.
Be aware that your enricher receives notifications not only for the property path you are interested in, but for all properties that belong to the enricher-triggering schema. Therefore, your enricher must verify whether the updatedProperties attribute contains the property path your enricher listens to. This is particularly important to avoid infinite event loops. You could create this unwanted infinite loop, for example, if you write an enricher that updates the property under the insights.affinities.product.hulk.score property based on the insights.affinities.product.hulk.recentScore property, both of which belong to the same enricher-triggering schema. If you fail to verify the property path in the updatedProperties attribute, your enricher reacts to its own changes, in this case, the modification of the property under the insights.affinities.product.hulk.score path.

Profile document deletion event

Upon deletion of a profile document, the Profile service stores the event in the Context service with these values:

  • operation: The type of operation, in this case DELETE
  • schema: The schema defining the deleted profile document, https://api.beta.yaas.io/metamodel/v1/profiles
  • message:
    {
    "profileId": "yourProfileId"
    }
    

The message contains the identifier for the deleted profile document.


Operations on profile documents

The Profile service provides an endpoint that allows you to perform operations on the profile documents.

Create or replace a profile document

The service allows you to create a profile document. A profile document includes all data associated with a given customer's profile.

If you run the command in the example, the service creates a profile document that replaces the existing document. An update replaces all data with the information included in the new document. To update the selected data only, run the command provided in this example.

To create a new profile document, run the following command:

cURL command example

curl -X PUT -H "Authorization: Bearer access_token" -H "hybris-consent-reference: consent-reference" -H "Content-Type: application/json" -d '{
  "insights": {
    "affinities": {
      "products": {
        "productName": {"some property": "some property value"}
      }
    }
  },
  "identities": {
      "devices": {
        "deviceId": {"some property": "some property value"}
      }
  }
}' 'https://api.beta.yaas.io/hybris/profile/v1/{tenant}/profiles/{profileId}' -i

Parameters

  • Headers
    • Authorization: Provide a valid Bearer access token with the scope hybris.profile_manage
    • hybris-consent-reference: Your consent reference
  • URI parameters
    • {tenant}: Your tenant name
    • {profileId}: The identifier of a given profile

Example of a PUT request with real data

curl -X PUT -H "Authorization: Bearer 001-65115c05-f2a2-4413-8d60-45349d103208" -H "hybris-consent-reference: 965dcef9-da77-40bf-9e9b-65fd735df113" -H "Content-Type: application/json" -d '{
  "insights": {
    "affinities": {
      "products": {
        "product123": {"score": 1234}
      }
    }
  },
  "identities": {
    "devices": {
      "device1": {"deviceType": "notebook"}
    }
  }
}' 'https://api.beta.yaas.io/hybris/profile/v1/mytenant/profiles/965dcef9-da77-40bf-9e9b-65fd735df113' -i

Response

If the service successfully creates or replaces an entire profile document, it sends a response with a status code of 204. However, if the system does not store some of the data you intend to save, despite the successful status code, it means that there are no consents granted to the collection of that data, or that the schemas for this data are not defined in the metamodel. In this case, the response includes a hybris-missing-consents header with a comma-delimited list of schemas to which writing is forbidden. A response with a status code of 403 indicates that the consent reference does not exist.

Create or update part of a profile document

The service allows you to create or update part of a document, as opposed to the entire document. To update the selected data only, or create part of a document, use the following command.

cURL command example

curl -X PATCH -H "Authorization: Bearer access_token" -H "hybris-consent-reference: consent-reference" -H "Content-Type: application/json" -d '{
  "some property": "some property value"
}' 'https://api.beta.yaas.io/hybris/profile/v1/{tenant}/profiles/{profileId}' -i

Parameters

  • Headers
    • Authorization: Provide a valid Bearer access token with the scope hybris.profile_manage
    • hybris-consent-reference: Your consent reference
  • URI parameters
    • {tenant}: Your tenant name
    • {profileId}: The identifier of a given profile

Example of a PATCH request with real data

curl -X PATCH -H "Authorization: Bearer 001-65115c05-f2a2-4413-8d60-45349d103208" -H "hybris-consent-reference: 965dcef9-da77-40bf-9e9b-65fd735df113" -H "Content-Type: application/json" -d '{
  "insights": {
    "affinities": {
      "products": {
        "product123": {"score": 125}
      }
    }
  },
  "identities": {
    "devices": {
      "device2": {"deviceType": "smartphone"}
    }
  }
},' 'https://api.beta.yaas.io/hybris/profile/v1/mytenant/profiles/965dcef9-da77-40bf-9e9b-65fd735df113' -i

When you send that request, the previously-created sample profile document included in the Create a profile document section updates as shown:

{
  "insights": {
    "affinities": {
      "products": {
        "product123": {"score": 125}
      }
    }
  },
  "identities": {
    "devices": {
      "device1": {"deviceType": "notebook"},
      "device2": {"deviceType": "smartphone"}
    }
  }
}

Response

If the service successfully creates or updates a part of a profile document, it sends a response with a status code of 204. However, if the system does not store some of the data you intend to save, despite the successful status code, it means that there are no consents granted to the collection of that data, or that the schemas for this data are not defined in the metamodel. In this case, the response includes a hybris-missing-consents header with a list of comma-delimited schemas to which writing is forbidden. A response with a status code of 403 indicates that the consent reference does not exist.

Get a profile document

To get a given profile document, run the command in this example.

cURL command example

curl -X GET -H "Authorization: Bearer access_token" 'https://api.beta.yaas.io/hybris/profile/v1/{tenant}/profiles/{profileId}'

Parameters

  • Headers
    • Authorization: Provide a valid Bearer access token with the scope hybris.profile_view
  • URI parameters
    • {tenant}: Your tenant name
    • {profileId}: The identifier of a given profile

Example of a GET request with real data

curl -X GET -H "Authorization: Bearer 001-65115c05-f2a2-4413-8d60-45349d103208" 'https://api.beta.yaas.io/hybris/profile/v1/mytenant/profiles/965dcef9-da77-40bf-9e9b-65fd735df113'

Responses

A response with the status code of 200 indicates that a service successfully retrieved the specified profile document.
If your call returns a response with a status code of 404, the service could not find the requested profile document.

Get a selected field

To get a selected field, or fields, from a given profile document, run the command in this example.

cURL command example

curl -X GET -H "Authorization: Bearer access_token" 'https://api.beta.yaas.io/hybris/profile/v1/{tenant}/profiles/{profileId}?fields={property1},{property2}'

Parameters

  • Headers
    • Authorization: Provide a valid Bearer access token with the scope hybris.profile_view
  • URI parameters
    • {tenant}: Your tenant name
    • {profileId}: The identifier of a given profile
  • Query parameters
    • properties: When you provide a properties query parameter, the service returns only the fields that include the specified property? You can filter your results by multiple properties. Use ',' as a separator.

Example of a GET request with real data

curl -X GET -H "Authorization: Bearer 001-65115c05-f2a2-4413-8d60-45349d103208" 'https://api.beta.yaas.io/hybris/profile/v1/mytenant/profiles/965dcef9-da77-40bf-9e9b-65fd735df113?fields=insights.affinities.products,identities.devices'

Responses

A response with the status code of 200 indicates that the service returned the requested fields.

Delete a profile document

You can delete the previously-created profile document by running the command provided in this example.

cURL command example

curl -X DELETE -H "Authorization: Bearer access_token" 'https://api.beta.yaas.io/hybris/profile/v1/{tenant}/profiles/{profileId}'

Parameters

  • Headers
    • Authorization: Provide a valid Bearer access token with the scope hybris.profile_manage
  • URI parameters
    • {tenant}: Your tenant name
    • {profileId}: The identifier of a given profile

Example of a DELETE request with real data

curl -X DELETE -H "Authorization: Bearer 001-65115c05-f2a2-4413-8d60-45349d103208" 'https://api.beta.yaas.io/hybris/profile/v1/mytenant/profiles/965dcef9-da77-40bf-9e9b-65fd735df113'

Response

The response with a status code of 204 indicates that the service deleted a given profile document. The response with a status code of 404 indicates that the service could not find the requested profile document.

Get the number of profiles owned by a tenant

To get the number of profiles owned by a given tenant, run the command in this example.

cURL command example

curl -X HEAD -H "Authorization: Bearer access_token" -I 'https://api.beta.yaas.io/hybris/profile/v1/{tenant}/profiles'

Parameters

  • Headers
    • Authorization: Provide a valid Bearer access token with the scope hybris.profile_view
  • URI parameters
    • {tenant}: Your tenant name

Example of a HEAD request with real data

curl -X HEAD -H "Authorization: Bearer 001-65115c05-f2a2-4413-8d60-45349d103208" -I 'https://api.beta.yaas.io/hybris/profile/v1/mytenant/profiles'

Response

A response with the status code of 204 indicates that a service successfully retrieved the number of profiles owned by a specified tenant.
The system returns this number as the hybris-count header.


Operations on profile properties

The Profile service provides an endpoint that allows you to perform operations on the profile document properties.

Create or replace a property

By running the command in the example, you can create a new property or replace the existing property.

cURL command example

curl -X PUT -H "Authorization: Bearer access_token" -H "hybris-consent-reference: consent-reference" -H "Content-Type: application/json" -d '"some property value"'
'https://api.beta.yaas.io/hybris/profile/v1/{tenant}/profiles/{profileId}/{propertyPath}'

Parameters

  • Headers
    • Authorization: Provide a valid Bearer access token with the scope hybris.profile_manage
    • hybris-consent-reference: Your consent reference
  • URI parameters
    • {tenant}: Your tenant name
    • {profileId}: The identifier of a given profile
    • {propertyPath}: The profile property path. Use '.' as a nesting mark.

Example of a PUT request with real data

curl -X PUT -H "Authorization: Bearer 001-65115c05-f2a2-4413-8d60-45349d103208" -H "hybris-consent-reference: 965dcef9-da77-40bf-9e9b-65fd735df113" -H "Content-Type: application/json" -d '20'
'https://api.beta.yaas.io/hybris/profile/v1/mytenant/profiles/965dcef9-da77-40bf-9e9b-65fd735df113/insights.affinities.products.product123.score'

Response

A response with a status code of 204 indicates that the service successfully created or replaced a given property. However, if the system does not store some of the data you intend to save, despite the successful status code, it means that there are no consents granted to the collection of that data, or that the schemas for this data are not defined in the metamodel. In this case, the response includes a hybris-missing-consents header with a comma-delimited list of schemas to which writing is forbidden. A response with a status code of 403 indicates that the consent reference does not exist.

Get a property

You can retrieve a given property value from a profile document by running the following command.

cURL command example

curl -X GET -H "Authorization: Bearer access_token" 'https://api.beta.yaas.io/hybris/profile/v1/{tenant}/profiles/{profileId}/{propertyPath}'

Parameters

  • Headers
    • Authorization: Provide a valid Bearer access token with the scope hybris.profile_view
  • URI parameters
    • {tenant}: Your tenant name
    • {profileId}: The identifier of a given profile
    • {propertyPath}: The profile property path. Use '.' as a nesting mark.

Responses

A response with the status code of 200 indicates that the service returned the requested property value. The consent reference value associated with a given profile is returned in the hybris-consent-reference header. If you receive a response with the status code of 404, the service could not find the requested property.

Delete a property

If you run the following command, the service deletes a given profile property.

cURL command example

curl -X DELETE -H "Authorization: Bearer access_token" 'https://api.beta.yaas.io/hybris/profile/v1/{tenant}/profiles/{profileId}/{propertyPath}'

Parameters

  • Headers
    • Authorization: Provide a valid Bearer access token with the scope hybris.profile_manage
  • URI parameters
    • {tenant}: Your tenant name
    • {profileId}: The identifier of a given profile
    • {propertyPath}: The profile property path. Use '.' as a nesting mark.

Responses

The response with a status code of 204 indicates that the service deleted a given profile property. The response with a status code of 404 indicates that the service could not find the requested property.


  • Send feedback

    If you find any information that is unclear or incorrect, please let us know so that we can improve the Dev Portal content.

  • Get Help

    Use our private help channel. Receive updates over email and contact our specialists directly.

  • hybris Experts

    If you need more information about this topic, visit hybris Experts to post your own question and interact with our community and experts.