Create Preference Form Access Tokens with REST API

Create an access token for Preference Manager forms by using REST API.

Required Editions

After you generate the access token, append the access token string ?pctoken=[token string] to the website URL of your published site. Then send this URL to your users to give them access to the preference form without logging in.

Available in: Developer, Enterprise, Performance, and Unlimited Editions. Requires the Salesforce Privacy Center license.
User Permissions Needed
To use the Preference Manager Builder: ManagePreferenceManager

Syntax

URI services/data/vXX.X/consent/prefcenter/token
Formats JSON
HTTP Methods POST
Authentication Bearer Token
Request Parameters recordId
Request Body

The request body contains a JSON object with the record ID of the associated object.

{
  [recordId]            // String, Required
}
Response Body

The response body returns a JSON object containing the token for the user associated with the provided recordId.

{
  "success":                     // Boolean
  "tokenMapping": {              // Object
  "token": "xxxxxxxxxxxxxxxx"    // String
                  },
  "tokenErrors": {},             // Object 
  "error": ""                    // String 
}
  • success returns a true or false statement to indicate if the request was successful.
  • tokenErrors indicates if there was an error revoking the token. If you included multiple tokens, the response indicates any errors for each individual token.
  • error indicates if there was a system error while processing the request.

Example Response Body

This example shows a successful response for a request with the record ID 0034L00000CZqeqQAD.


{
  "success" : true,
  "tokenMapping" : 
    {
    "token": "QTRMMDAwMDAwNTRQSGc0ZlhSczZnSXNTNEpNUVBldWN6
              cFl0bDRNcERURWRMWGJPZ1hhamxQTnUxa2oxN0dXVVFM
              alhwNFY1NXVxaDlrcXEwcFhuQy94WGNBYmMyMkZaWjJR
              L1VTOWw0UVhiZ2s4dFZaMUM0M053M01wWllUUTQzODZ1
              VjFLekxod2xQZ2NNQzRIYzNuM2RtRW9kVTRTN1lEdz09"
    },
  "tokenErrors": {},
  "error": ""
}