TCF 2.2 API
Overview
Some business cases require a IAB's encoded TC String and TC Data to be calculated server-side. For this use case, OneTrust provides a TCF 2.2 API.
In this document, you'll learn how to call this API.
Details
Method Type | POST |
URL | https://mobile.onetrust.io/iabtcf/v1/tcmodel/encode |
Params | n/a |
Headers | n/a |
Body | see below |
// sample body
{
"location": "cdn.cookielaw.org",
"gvlUrl": "https://cdn.cookielaw.org/vendorlist/iab2V2Data.json",
"tcModel": {
"cmpId": 28,
"cmpVersion": 1,
"consentScreen": 1,
"consentLanguage": "en",
"gdprApplies": true,
"isServiceSpecific": true,
"publisherCountryCode": "AA",
"vendorConsents": [1,2,3,4],
"purposeConsents": [1,2,3],
"vendorLegitimateInterests": [1,2,7,700],
"purposeLegitimateInterests": [1,2,3],
"specialFeatureOptins": [1,2,4],
"publisherRestrictions": {
"1": {
"40": 0,
"58": 0
},
"2": {
"40": 0,
"577": 2
},
"3": {
"40": 0,
"740": 0
},
"4": {
"40": 0,
"740": 0
},
"5": {
"577": 0,
"740": 0
},
"6": {
"577": 2
},
"7": {
"40": 0,
"58": 0,
"577": 0,
"740": 0
},
"8": {
"577": 0,
"740": 0
},
"9": {
"40": 0
},
"10": {
"40": 0,
"58": 0,
"740": 0
}
}
}
}
JSON Body Explained
Key | Description |
---|---|
location | Usually cdn.cookielaw.org |
cmpID | always 28 for OneTrust |
cmpVersion | always 1 |
consentScreen | always 1 |
consentLanguage | pass in the appropriate language code |
gdprApplies | always true |
isServiceSpecific | always true |
publisherCountryCode | pass in the appropriate country code of the publisher |
vendorConsents | pass in an array of vendorIds (numbers) that user has granted consent for |
purposeConsents | pass in an array of IAB purposeIds (numbers) that user has granted consent for |
vendorLegitimateInterests | pass in an array of vendorIds (numbers) that user has objected legit interest for |
purposeLegitimateInterests | pass in an array of purposeIds (numbers) that user has objected legit interest for |
specialFeatureOptins | pass in an array of specialFeatureIds (numbers) that user has granted consent for |
publisherRestrictions | pass in a map of purposeIds > vendorId > restriction Type |
Publisher Restriction Types
Source: TCF 2.2 TC String Documentation
-
0 - Purpose Flatly Not Allowed by Publisher (regardless of Vendor declarations)
-
1 - Require Consent (if Vendor has declared the Purpose IDs legal basis as Legitimate Interest and flexible)
-
2 - Require Legitimate Interest (if Vendor has declared the Purpose IDs legal basis as Consent and flexible)
-
3 - UNDEFINED (not used)
Sample Response:
Source: TCF 2.2 CMP API Documentation
The response is returned in the TCF 2.2 TCData format:
{
"cmpId": 28,
"cmpVersion": 1,
"gdprApplies": true,
"tcfPolicyVersion": 4,
"eventStatus": "cmpuishown",
"cmpStatus": "loaded",
"tcString": "CPzyhEAPzyhEAAcABBENAWENAOAAAGAAAAAAACNAAAAQCABAAoAB0EAAgAoDAAgAUALkEAAgAUALkHAAwAUAA6AXIQAAgLkJAAQAUFAAYAKAAdALkAAA.IgoNV_H__bX9v8Tr16ft0eYlX99j77uQxBhfJs-4FyDvW_JwVn2EyNA06tqYKmRIEuzZBIQFsHJnURVihSogVrzHsYkGMhTMIJ-BkgHMRa2dYCFxvmYtjEQIZ5_p_d3f52R_9_dn-3czjT9lnnzVtP2dlcKidS59tH_l_bRKb-7Ied-72_4v09tfrkW_eTVu_9evv79-u_s_v__9_9wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQ",
"isServiceSpecific": false,
"useNonStandardStacks": false,
"purposeOneTreatment": false,
"publisherCC": "AA",
"purpose": {
"consents": "111",
"legitimateInterests": "011"
},
"vendor": {
"consents": "1101",
"legitimateInterests": ""
},
"specialFeatureOptins": "1101",
"publisher": {
"consents": "",
"legitimateInterests": "",
"customPurpose": {
"consents": "",
"legitimateInterests": ""
},
"restrictions": {
"1": "_______________________________________0_________________0__________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________",
"2": "_______________________________________0____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________",
"3": "_______________________________________0___________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________0",
"4": "_______________________________________0___________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________0",
"7": "_______________________________________0_________________0_________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________0",
"8": "___________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________0",
"9": "_______________________________________0____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________",
"10": "_______________________________________0_________________0_________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________0"
}
},
"publisherCountryCode": "AA",
"created": "2023-10-17T17:48:35.326Z",
"lastUpdated": "2023-10-17T17:48:35.326Z"
}
Updated 12 months ago