Consent Management Platform API

Consent Management Platforms (CMPs) provide a user interface to establish transparency to users and obtain consent or register objections from end users while also capturing their preferences in Signals. These Signals are packaged in a standardized, easily-communicated payload called a TC String. The CMP API provides a standardized means for parties such as the hosting publisher or an advertising vendor to access these preferences managed by the CMP.

Using the API, scripts may obtain the TC String payload as well as the information it contains, which is ready to use without having to understand how to “unpack” the payload format. This makes it easy to make immediate data processing decisions based on the returned information.

CMPs may provide proprietary interfaces for specialized features or capabilities. The design and operation of a proprietary interface are documented in the IAB Europe Transparency and Consent Framework Policies.

CookieHub & CMP API

CookieHub exposes the standard __tcfapi function according to IAB’s specifications, which can be used by vendors to get the user’s consent state.


The CMP API Stub should be loaded synchronously before any other script that relies on __tcfapi. The stub will provide a basic implementation of __tcfapi temporarily until the actual implementation has been loaded. 

The CookieHub CMP Stub is located here:

Sample code to interact with __tcfapi


The ping command invokes the callback immediately without any asynchronous logic and returns a PingReturn object to determine whether or not the main CMP script has loaded and whether GDPR applies.

__tcfapi('ping', 2, (pingReturn) => {
  // do something with pingReturn


The getTCData command returns the complete unencoded TC String, including the current consent state of the information about the CMP.

__tcfapi('getTCData', 2, (tcData, success) => {
  if(success) {
    // do something with tcData
  } else {
    // do something else
}, [1,2,3]);

Further information about the exposed commands and all available commands can be found in the Consent Management Platform API specification

Still need help? Contact Us Contact Us