> ## Documentation Index
> Fetch the complete documentation index at: https://developer.onetrust.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 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**

```json
{
   "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](https://my.onetrust.com/s/article/UUID-ed5e7e89-f9df-732d-d2ac-99263139abf4) 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](https://github.com/InteractiveAdvertisingBureau/GDPR-Transparency-and-Consent-Framework/blob/master/TCFv2/IAB%20Tech%20Lab%20-%20Consent%20string%20and%20vendor%20list%20formats%20v2.md#the-core-string)

* 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](https://github.com/InteractiveAdvertisingBureau/GDPR-Transparency-and-Consent-Framework/blob/master/TCFv2/IAB%20Tech%20Lab%20-%20CMP%20API%20v2.md#tcdata) format.

```json
{
   "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"
}
```