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

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

KeyDescription
locationUsually cdn.cookielaw.org
cmpIDAlways 28 for OneTrust
cmpVersionAlways 1
consentScreenAlways 1
consentLanguageTwo-letter language code
gdprAppliesAlways true
isServiceSpecificAlways true
publisherCountryCodeCountry code of the publisher
vendorConsentsArray of Vendor IDs for which consent has been granted
disclosedVendorsArray of Vendor IDs for vendors that were displayed/disclosed to the user when consent was collected. See here for more information.
purposeConsentsArray of Purpose IDs for which consent has been granted
vendorLegitimateInterestsArray of Vendor IDs for which legitimate interest has been granted
purposeLegitimateInterestsArray of Purpose IDs for which legitimate interest has been granted
specialFeatureOptinsArray of Special Feature IDs for which consent has been granted
publisherRestrictionsMap 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"
}