Salesforce CDP Profile API Library

The Salesforce CDP Profile API calls are used to lookup and search customer profile information. These API calls can be included in your external web/mobile apps to look up customer profile information.

Using Salesforce CDP Profile API calls, you can build the complete Salesforce CDP pages by retrieving the Profile info along with computed engagement insights.

These calls only support the data model objects in the profile category, such as Individual, Contact Point Email, Unified Individual, and Contact Point Address. They also support retrieving the computed attributes related to the Individual field. For example, the computed value of the total sales quantity in the last 6 months for a customer profile.

These calls do NOT support the engagement category data model objects like Sales Order.

The Salesforce CDP Profile API calls follow the REST standard specification.

Key Properties

  • You must explicitly specify the fields you want to retrieve, or only the data from the first 10 alphabetically sorted fields/attributes of the entity will be included in your response. This restriction of 10 fields does not apply when you explicitly mention the field names.
  • You can retrieve a maximum of 50 fields.
  • Only the AND logical operator and equality comparator operator are supported.
  • There are no limits on the number of filters you can have in your query.
  • The default return limit is 100 rows. A max limit of 4999 is allowed.
  • For date and time fields, use the format:
    1Date/DateTime BirthDate__c=1990-07-12 00:00:00

Connected App Setup

Perform the following steps to set up a connected app, before using the calls in this section. Use Salesforce’s OAuth 2.0 JSON Web Token (JWT) bearer flow to acquire a token, as described in the steps below.

  1. Create a connected app.
  2. Enable OAuth settings on the connected app.
  3. Give a name/label.
  4. Locate your private/public key pair.
  5. If you don't have these, use the following steps:
    1. You need a .key and a .crt file (private and public key)
    2. Go to any folder and run the following commands:
      1openssl genrsa 2048 > host.key
      2                  chmod 400 host.key
      3                  openssl req -new -x509 -nodes -sha256 -days 365 -key host.key -out host.crt
      This command will create a host.key and a host.crt file in that folder.
  6. Specify any redirect_uri.
  7. Select the scopes required
    1. You must select refresh_token, and at least one other scope (Select api, for example).
  8. Save your changes so far. Copy your client ID and client secret so you can add it later.
  9. Go to the Manage page for the connected app and edit the following policies:
    1. Change Restrict IP to Relax IP restrictions.
    2. If you don't have any custom scopes, create them now.
    3. Choose Manage custom scopes and add cdpprofile and cdpquery to the custom scopes.
  10. Authorize the users for whom you are creating JWT bearer tokens.
    1. This is a one-time step for each user. If you don't perform this step, you will receive a user hasn’t approved consumer error.
    2. Construct this URL
      1https://<ORG URL>/services/oauth2/authorize?response_type=code&client_id=<CLIENT ID>&scope=api refresh_token cdpprofile cdpquery&redirect_uri=https://oauth.pstmn.io/v1/callback
      1. Change redirect_url value if you are using
        1https://oauthdebugger.com
      2. Notice the scope parameter in the constructed URL. It’s important that you select all the required custom CDP scopes in this request. All further JWT bearer flow requests will only use these scopes.
  11. This prompts a consent dialog that asks you to give permission for each of the scopes you requested. Choose Allow for each of the scopes.
Your connected app is all setup and ready to go!

Acquire an Access Token

The following example shows you how to request an access token:
1POST https://login.salesforce.com/services/oauth2/token
2          
3          Content-Type: x-www-form-urlencoded
4          
5          grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer
6          &assertion=eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpc3MiOiIzTVZHOUFPcDRrYnJpWk9JZmg0eWZPQVlQUjFpYzJqb1JDQkhwZFZtaXBXU05sbXNwT2Vib1VtcWdMdHJIcDlRVFRQMGpWc3g0SHlzUW4xLk1SazFyIiwic3ViIjoic3VkaGVlckBvcmdtYWluMi5jb20iLCJhdWQiOiJodHRwOi8vc3VrdW1hci1sdG0uaW50ZXJuYWwuc2FsZXNmb3JjZS5jb20iLCJleHAiOjE2MDQ2Mzc4MTkyNTd9.WkEcmaGj_jhJpyFqXwEUtw-bkeXYuxkqc2c3lkwbGjg3GDo7sStITht_O_dSNanS0xk2q9ARA6Uom-uaiyNw_GGGK5L3jBQjK-ytrGumuJAsujjfSmLdYStxPVnjU2zyuPSWMQJmeDegxDgmeht3UQyluj0q4lX3rayx0Ol-vZfTuzr4YlxmdOKTNrPJCQ8h26uMSPFrQmmqcssrSg1DRgm3kMh15VKM3yZyNAg43EPw1BfncPWIxOmsGt2JxUUclBER3enTLM2cJKr9fDx16Ssesj2UKqXGbwN68gCF5rZxD6yGN5B0VeZIZVJrY5cTtExqBp3Lj8UOcqUj6esyCQ
Response Format:
1{
2          "access_token": "00Dxx0000006JFr!AQEAQL7SvQ1t..2yYtyM0jfXtMNriivdMpTYE3mThqATnm5YqPIX.xnzUC45zd0HEIU3tc9GdHLqWOFVprsgszWdYMPRUnOy",
3          "scope": "cdpquery api cdpprofile",
4          "instance_url": "http://orgmain2.localhost.internal.salesforce.com:6109",
5          "id": "http://sukumar-ltm.internal.salesforce.com:6109/id/00Dxx0000006JFrEAM/005xx000001X9hBAAS",
6          "token_type": "Bearer"
7          }
Follow this link to create the assertion JWT: Create Assertion JWT

Exchange Your Access Token for a Salesforce CDP Token (CDP Token)

The following example shows you how to request a Salesforce CDP Token:
1POST <Instance URL>/services/a360/token
2          
3          Content-Type : x-www-form-urlencoded
4          
5          grant_type=urn:salesforce:grant-type:external:cdp
6          &subject_token=<CORE ACCESS TOKEN>
7          &subject_token_type=urn:ietf:params:oauth:token-type:access_token
Response Format:
1{
2          "access_token": "eyJraWQiOiJDT1JFLjAwRHh4MDAwMDAwNkpGci4xNjAzMjM5NzI2NjI5IiwidHlwIjoiSldUIiwiYWxnIjoiUlMyNTYifQ.eyJzdWIiOiJodHRwOi8vc3VrdW1hci1sdG0uaW50ZXJuYWwuc2FsZXNmb3JjZS5jb206NjEwOS9pZC8wMER4eDAwMDAwMDZKRnJFQU0vMDA1eHgwMDAwMDFYOWhCQUFTIiwiYXVkIjoiYTM2MCIsInNjcCI6ImNkcHByb2ZpbGUgY2RwcXVlcnkiLCJuYmYiOjE2MDQ1NTE3NzYsInNmb2lkIjoiMDBEeHgwMDAwMDA2SkZyIiwiaXNzIjoiaHR0cDovL3N1a3VtYXItbHRtLmludGVybmFsLnNhbGVzZm9yY2UuY29tOjYxMDkvIiwic2Z1aWQiOiIwMDV4eDAwMDAwMVg5aEIiLCJleHAiOjE2MDQ1NTkwMjgsImlhdCI6MTYwNDU1MTgzNiwianRpIjoiYjk1ODA1ZDUtM2MzYS00MDNkLWJiNjgtNjBkNTJlNmM4OTBjIiwic2ZhcHBpZCI6IjNNVkc5QU9wNGticmlaT0lmaDR5Zk9BWVBSMWljMmpvUkNCSHBkVm1pcFdTTmxtc3BPZWJvVW1xZ0x0ckhwOVFUVFAwalZzeDRIeXNRbjEuTVJrMXIifQ.GAWqiPpVJoDig-adGtD4d5cO7L7JaIn2mOYH9GyDD7oO7Ayrsnv_k05QRPp-B1gSd4U8lqE_cuC0MTE9L6lzJA",
3          "instance_url": "https://a360.cdp.cdp001.dev1-uswest2.aws.sfdc.cl",
4          "token_type": "Bearer",
5          "issued_token_type": "urn:ietf:params:oauth:token-type:jwt",
6          "expires_in": 7191
7          }
Use the access_token from the response as the instance_url, which is the Salesforce CDP URL.

Refer to each of the call pages for more information about how to interact with these profile API calls.

Troubleshooting

If you receive the User hasn't approved this consumer yet error message, double-check the following configuration parameters:
  • Make sure you have Users may self-authorize in the connected app configuration.
  • Make sure you select refresh_token scope and AT LEAST one other scope apart from this (not counting custom scopes).
  • In the self-authorization URL, set the scope parameter value as api refresh_token cdpquery cdpprofile.
  • The first time you make a call to the self-authorization URL, you must respond to a consent page asking for permission for each of the scopes you requested in the URL.