IAB TC String Encoder
Overview
In some business scenarios, the IAB TC String must be calculated/encoded server-side. To support this requirement, OneTrust provides a TCF 2.3 API.
This document explains how to call and use that API.
API Details
| Method Type | POST |
| URL | https://mobile.onetrust.io/iabtcf/v1/tcmodel/encode |
| Body | See below |
Payload 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,
6,
7,
8
],
"disclosedVendors":[
1,
2,
3,
4,
6,
7,
8
],
"purposeConsents":[
1,
2,
3,
4,
5,
6,
7,
8,
9,
10
],
"vendorLegitimateInterests":[
1,
7,
700,
755,
766,
756
],
"purposeLegitimateInterests":[
1,
2,
3,
4,
5,
6,
7,
8,
9,
10
],
"specialFeatureOptins":[
1,
2,
4
],
"publisherRestrictions":{
"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
}
}
}
}Payload Body Details
| Key | Description |
|---|---|
| location | Usually cdn.cookielaw.org |
| cmpID | Always 28 for OneTrust |
| cmpVersion | Always 1 |
| consentScreen | Always 1 |
| consentLanguage | Two-letter language code |
| gdprApplies | Always true |
| isServiceSpecific | Always true |
| publisherCountryCode | Country code of the publisher |
| vendorConsents | Array of Vendor IDs for which consent has been granted |
| disclosedVendors | Array of Vendor IDs for vendors that were displayed/disclosed to the user when consent was collected. See here for more information. |
| purposeConsents | Array of Purpose IDs for which consent has been granted |
| vendorLegitimateInterests | Array of Vendor IDs for which legitimate interest has been granted |
| purposeLegitimateInterests | Array of Purpose IDs for which legitimate interest has been granted |
| specialFeatureOptins | Array of Special Feature IDs for which consent has been granted |
| publisherRestrictions | Map of Purpose IDs > Vendor IDs > Restriction Type. See below for more information |
Publisher Restriction Types
IAB Tech Spec: TCF 2.3 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
Returned in the TCData format.
{
"cmpId":28,
"cmpVersion":1,
"gdprApplies":true,
"tcfPolicyVersion":5,
"eventStatus":"cmpuishown",
"cmpStatus":"loaded",
"tcString":"CQgipwAQgipwAAcABBENCUFtAP_AAEPAAAAAADNQLzgBAABAXmAIOABgAoAB0AuQgABAXISAAgAoKAAwAUAA6AXI.YAAAAAAAAAAA.IAEPcAAA",
"isServiceSpecific":true,
"useNonStandardTexts":false,
"purposeOneTreatment":false,
"publisherCC":"AA",
"purpose":{
"consents":"1111111111",
"legitimateInterests":"0100001111"
},
"vendor":{
"consents":"110101",
"legitimateInterests":"10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001",
"disclosedVendors":"11110111"
},
"specialFeatureOptins":"1101",
"publisher":{
"consents":"",
"legitimateInterests":"",
"customPurpose":{
"consents":"",
"legitimateInterests":""
},
"restrictions":{
"7":"_______________________________________0_________________0_________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________0",
"8":"___________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________0",
"9":"_______________________________________0____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________",
"10":"_______________________________________0_________________0_________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________0"
}
},
"publisherCountryCode":"AA",
"created":"2026-03-04T16:26:49.179Z",
"lastUpdated":"2026-03-04T16:26:49.179Z"
}Updated about 3 hours ago