Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
Consent Write
All records with the email address listed are updated. If the Create Individual parameter is selected and no Individual record exists, the API creates an Individual record. If warranted, the API also creates a Contact Point Type Consent and Contact Point Email record.
If you aren’t passing anything in the request body, pass in an empty object {}.
Syntax
URI: /services/data/vXX.X/consent/action/action?ids=listOfIds
Formats: JSON
HTTP methods: PATCH
Authentication: Authorization: Bearer token
Request parameters
| Parameter | Description |
|---|---|
| blobParam | Optional. Use to pass information to Data Cloud, such as portability write location. Use only for mode=cdp. This parameter must be passed in as part of the PATCH request body. |
| captureDate | Optional. The date and time when consent is captured. The default is the date and time that the API call is made. |
| captureContactPointType | Optional. Describes how consent is captured (web, phone, email). Supported values are email, phone, or web (default). |
| captureSource | Optional. The source through which consent is captured. The default capture source is Consent API. Max length 255 characters. |
| consentName | Optional. Use to set the name for any new consent records. Default is: Individual Name-Datetime (<Name> 2019-03-31T15:47:57). Max length is 255 characters. |
| createIndividual | Optional. Boolean. If set to true and the API call includes an email address that matches multiple records without an Individual object, then an Individual object is created. Any consent records with an email address that match the email in the API call are linked to the new Individual object. If multiple records are found, then any records not linked to an Individual object is linked to the Individual object found in the other records. If more than one Individual object is found on the matching records, then the call is rejected. |
| doubleOptIn | Optional. The date and time that the double opt-in is completed, formatted as described in Valid Date and DateTime Formats. |
| effectiveFrom | Optional. The date from which consent is effective, formatted as described in Valid Date and DateTime Formats. The default is the date that the API call is made. |
| effectiveTo | Optional. The date through which consent is effective, formatted as described in Valid Date and DateTime Formats. |
| ids | Required. The email address used to sync consent. The ID can be the record ID or the email address listed on the record. You can pass up to 1,000 IDs in the request body. When mode=cdp, the ID value is a string equal to the Individual ID attribute. |
| individualName | Optional. The name of the person in an Individual record. If a name isn’t provided for a new Individual record, then the local part of the passed-in email address is used. Max length is 80 characters. |
| mode | Optional. Default is normal. The allowed modes are: normal or cdp. With mode=cdp, the request is passed to the Data Cloud platform to get or write consent. The mode=cdp parameter only supports the action, blobParam, and ids parameters. |
| purposeName | Optional. The data use purpose for which consent is provided. Must use an existing data use purpose that you previously created. If more than one purpose with the same name exists, only one purpose is selected. |
| status | Required. Status of the consent (OptIn, OptOut, Seen, NotSeen.) If action exists on an Individual object (for example, tracking or processing), the only valid values are OptIn and OptOut. |
Action
Allowed values are:
- fax
- geotrack
- mailing
- phone
- portability
- process
- profile
- shouldForget
- social
- solicit
- storePiiElsewhere
- track
- web
Security
To call the Consent Write API, you must have either the ModifyAllData or the ConsentApiUpdate user permission. This API writes org-wide consent data, such as links between records and the value of consent flags, and not just records to which the user ordinarily has access. The ConsentApiUpdate user permission grants full write permission to the user during the Consent Write API call.
Example
Example Request
1curl -X PATCH https://MyDomainName.my.salesforce.com/services/data/v67.0/consent/action/<action>?ids=<email-OR-recordID>&status=<optout/optin/seen/notseen>&createIndividual=<true/false> -H "Content-Type: application/json" -d "@exampleRequestBody.json"Example Request Body
1{ "ids": [ "001ZM000002ZhpHYAS", "001ZM000002ZhpFYAS" ] }Example Response Body
1{
2 "<email-OR-recordID>" : {
3 "result" : "Success",
4 "edited" : [{
5 "objectType" : "<Contact, Lead, User, etc.>",
6 "field" : "<HasOptedOutofFax, DoNotCall,etc>",
7 "valueOfField" : "<true/false>",
8 "id" : "<recordID>"
9 }],
10 }
11}