# Consent Management Platform API ## Version History
| Date | Version | Comments |
| June 2023 | 1.1 |
Removal of return values in favor of callback functions. Removal of getGPPData command |
| Sept 28, 2022 | 1.0 |
Published final public version |
| API | Prefix |
| IAB TCF1 (EU) | tcfeuv1 (no longer used) |
| IAB TCF v2 (EU) | tcfeuv2 |
| IAB TCF v1 (Canada) | tcfcav1 |
| IAB CCPA/USP v1 | uspv1 (deprecated) |
| California Privacy | usca |
__gpp(command, callback, parameter, [version])
Requirements for the interface:
- The __gpp function must always be a function and cannot be any other type, even if only temporarily on initialization – the API must be able to handle calls at all times.
- The command must always be a string.
- The callback must always be a function.
- Parameter can be of mixed type depending on used command
- The __gpp function does not have a return value
- If a CMP cannot immediately respond to a query, the CMP must queue all calls to the function and execute them later. The CMP must execute the commands in the same order in which the function was called.
- A CMP must support all generic commands. All generic commands must always be available when a __gpp function is present on the page. This means that “[stub code](#stubcode)” that supports all generic commands must be in place before/during CMP load.
### What required API commands must a CMP support?
All CMPs must support all generic commands. Generic commands are commands that can be used independent of [section specifications](https://github.com/InteractiveAdvertisingBureau/Global-Privacy-Platform/blob/main/Sections/Section%20Information.md). All generic commands must always be executed immediately without any asynchronous logic and call the supplied callback function immediately. The generic commands are: [‘ping’](#ping), [‘addEventListener’](#addeventlistener), [‘removeEventListener’](#removeeventlistener), [‘hasSection’](#hassection), [‘getSection’](#getsection), and [‘getField’](#getfield).
### What is a CMP ID?
Regional section policy writers may require CMPs to register to operate within the policies for that section. In these cases, CMP IDs must be used if the CMP has an ID. For CMPs that are not registered, a value of 1 must be used by string creators who do not have a CMP ID and are not using a commercially available CMP.
**Examples:**
Publisher A looking to create a GPP string that will contain the section for the MSPA US National approach must use 1 as value for CMP ID since the MSPA does not have CMP registration requirements.
Publisher B looking to create a GPP string that will contain sections for the MSPA US National approach or the TCF EU must register themselves or work with a registered CMP and use the assigned CMP ID in accordance with the TCF Policies.
________
#### `ping`
The `ping` command can be used to determine the state of the CMP. The callback shall be called with a PingReturn object as the value of the `data` parameter. A value of `false` will be passed as the argument to the `success` parameter if the CMP fails to process this command.
| argument | type | value |
command |
string | "ping" |
callback |
function | function (data: PingReturn, success: boolean) |
parameter |
not used |
| Status Code | Applicable for | Description |
'stub' |
cmpStatus | CMP not yet loaded - stub still in place |
'loaded' |
cmpStatus | CMP is finished loading |
'error' |
cmpStatus | CMP is in an error state. A CMP shall not repsond to any other API requests if this cmpStatus is present. A CMP may set this status if, for any reason, it is unable to perform the operation. |
'visible' |
cmpDisplayStatus | User interface is currently displayed |
'hidden' |
cmpDisplayStatus | User interface is not yet or no longer displayed |
'disabled' |
cmpDisplayStatus | User interface will not show (no Sections apply or data is current and does not need renewal) |
Null / not set |
cmpDisplayStatus | Is NULL when there is no display layer. Display layer refers to a modal that the user may interact with to express their choices. When no such modal is present, the value is NULL, e.g. when there is only a Do Not Sell or Share Personal Data link on the page that when clicked does not launch a modal. In this example, vendors should rely solely on signalStatus and the cmpDisplayStatus will be NULL / not set. |
'not ready' |
signalStatus | The CMP is not ready to respond to any calling scripts with the corresponding GPP string and applicable section ids. |
'ready' |
signalStatus | The CMP is ready to respond to any calling scripts with the corresponding GPP string and applicable section ids. The ‘ready’ status should only be sent when the GPP string contains the section that is currently applicable with the user’s current choices reflected. E.g. the ‘ready’ status should be signaled when applicableSection == -1 or applicableSection != 1 and the GPP string contains the section corresponding to applicableSection reflecting the user’s current choices. |
| argument | type | value |
command |
string | "addEventListener" |
callback |
function | function (data: EventListener, success: boolean) |
parameter |
not used |
| Event Name | Type of data property | Description |
listenerRegistered |
boolean | Only used within the return object to addEventListener command. The data property signals whether the event listener was registered successfully. If data equals true, a listenerId must be sent, otherwise the listenerId must be 0 (zero). |
listenerRemoved |
boolean | Only used within the return object to removeEventListener command. The data property signals whether the event listener was successfully removed. |
cmpStatus |
string | Event is called whenever the status of the CMP changes (e.g. the CMP has finished loading). The data property will contain the new status (e.g. loaded) |
cmpDisplayStatus |
string | Event is called whenever the display status of the CMP changes (e.g. the CMP shows the consent layer). The data property will contain the new display status (e.g. visible). Note that this is only applicable when a consent layer is displayed. |
signalStatus |
string | Event is called whenever the signalStatus changes. The data property will contain the new signalStatus value.
|
error |
string | Event can be called by the CMP in case of an error. The data property will contain a human readable error message. |
sectionChange |
string | Event is called whenever the status or content of a section changes (e.g. consent is obtained). The data property will indicate the name (API prefix) of the changed section. |
[API.prefix] or [API-prefix].[Eventname] |
mixed | Event is called by the CMP depending on the specific API needs (e.g. IAB TCF EU may specify different events than MSPA US National Section). If the API defines different event types, these can be used by combining API-prefix and eventname, If the API does not specify different event types (e.g. in IAB TCF v2.0), the API-prefix is used as name. The data property will contain mixed data depending on API. |
| Event Order | Event Name | Data | Description |
| 1 | initial data of PingReturn is {gppVersion:1.1, cmpStatus: loading, cmpDisplayStatus: hidden, signalStatus: not ready, ...} | ||
| 2 | listenerRegistered |
CMP has registered the event listener. Event is immediately fired after registering. | |
| 3 | cmpStatus |
loaded |
CMP is now loaded. Event is fired with name = cmpStatus and data = loaded. |
| 4 | cmpDisplayStatus |
visible |
CMP now displays the consent layer. Event is fired with name=cmpDisplayStatus and data = visible. |
| 5 | User makes their choices and clicks on accept or reject or save. | ||
| 6 | cmpDisplayStatus |
hidden |
CMP closed the consent layer and processes user input. Event is fired with name=cmpDisplayStatus and data = hidden. |
| 7 | sectionChange |
tcfcav1 |
CMP changes the section based on user input. Event is fired with name = sectionChange and data = tcfcav1. Note: if multiple sections are present, multiple sectionChange events may occur one after another. |
| 8 | signalStatus |
ready |
CMP is done with the processing, vendors can use the data. Event is fired with name = signalStatus and data = ready. |
| Event Order | Event Name | Data | Description | ||
| 1 | initial data of PingReturn is {gppVersion:1.1, cmpStatus: loading, cmpDisplayStatus: hidden, signalStatus: not ready, ... } | ||||
| 2 | listenerRegistered |
CMP has registered the event listener. Event is immediately fired after registering. | |||
| 3 | cmpStatus |
loaded |
CMP is now loaded. Event is fired with name = cmpStatus and data = loaded | ||
| 4 | signalStatus |
ready |
CMP is done with the processing (consent information is loaded, no further processing needed, consent layer will not be shown), vendors can use the data. Event is fired with name = signalStatus and data = ready | ||
| 5 | User clicks on a link or button to resurface the consent layer in order to change their choice | ||||
| 6 | signalStatus
| ||||
| 7 | cmpDisplayStatus |
visible |
CMP now displays the consent layer. Event is fired with name = cmpDisplayStatus and data = visible | ||
| 8 | User makes their choices and clicks on accept or reject or save | ||||
| 9 | cmpDisplayStatus |
hidden |
CMP closed the consent layer and processes user input. Event is fired with name = cmpDisplayStatus and data = hidden | ||
| 10 | sectionChange |
tcfcav1 |
CMP changes the section based on user input. Event is fired with name = sectionChange and data = tcfcav1 Note: If multiple sections are present, multiple sectionChange events may occur after another |
||
| 11 | signalStatus |
ready |
CMP is done with the processing, vendors can use the data. Event is fired with name = signalStatus and data = ready | ||
| argument | type | value |
command |
string | "removeEventListener" |
callback |
function | function (data: boolean, success: boolean) |
parameter |
number | ID of the listenerId property that was returned from addEventListener command |
| argument | type | value |
command |
string | "hasSection" |
callback |
function | function (data: boolean, success: boolean) |
parameter |
string | API Prefix string |
| argument | type | value |
command |
string | "getSection" |
callback |
function | function (data: array of objects or null, success: boolean) |
parameter |
string | API Prefix string |
| argument | type | value |
command |
string | "getField" |
callback |
function | function (data: mixed or null, success) |
parameter |
string | API Prefix string + "." (dot) + fieldname |
| Key Name | Data type | Description |
IABGPP_HDR_Version |
String | GPP Version |
IABGPP_HDR_Sections |
String | List of Section IDs |
IABGPP_HDR_GppString |
String | Full consent string in its encoded form |
IABGPP_GppSID |
String | Section ID(s) considered to be in force. Multiple IDs are separated by underscore, e.g. “2_3” |
IABGPP_[SectionID]_String |
String | String representaiton of each section. E.g. IAB TCF EU v2 String will be found at IABGPP_2_String |
| Input Data Type | In-app Data Type | Description |
Boolean |
Integer (0/1) | Convert True = 1, False = 0 |
Integer / Integer Fibonacci |
Integer | unchanged |
String |
String | unchanged |
Datetime |
Integer | Convert date to amount of milliseconds since 1.1.1970 00:00:00 UTC |
Bitfield / Vairable length Bitfield / Range / Range Fibonacci / Optimized Range |
String | Convert all included IDs into a string separated by underscore, e.g. “1_4_5_6_99” |
ArrayOfRanges |
String | The key name will be combined by a static name and the key of the record. If the input data contains multiple records, the CMP SDK will create multiple keys, each with a combination of name and key. The value consists of a sequence of "id:type"-pairs separated by underscore. E.g. "3:0_5:1_6:1_7:2_12:0" |
| Key Name | Description |
IABGPP_TCFEU2_Version |
IAB TCF EU v2 Version number (see IAB TCF EU v2 specification) |
IABGPP_TCFEU2_Created |
IAB TECF EU v2 creation date |
IABGPP_TCFEU2_LastUpdated |
IAB TCF EU v2 last update date |
IABGPP_TCFEU2_CmpId |
IAB TCF EU v2 CMP ID |
IABGPP_TCFEU2_CmpVersion |
IAB TCF EU v2 CMP Version |
IABGPP_TCFEU2_PurposesConsent |
IAB TCF EU v2 CMP Purpose consents list |
IABGPP_TCFEU2_VendorConsent |
IAB TCF EU v2 CMP Vendor consents list |
IABGPP_TCFEU2_... |
Other IAB TCF EU v2 fields according to IAB TCF UE specification |
IABGPP_TCFCA1_Version |
IAB TCF CA v1 Version number (see IAB TCF CA v1 specification) |
IABGPP_TCFCA1_Created |
IAB TCF CA v1 creation date |
IABGPP_TCFCA1_… |
Other IAB TCF CA v1 fields according to IAB TCF CA specification |
IABGPP_USP1_Version |
IAB US Privacy String Version number (see IAB US Privacy v1 specification) |
IABGPP_USP1_Notice |
IAB US Privacy notice has been provided |
IABGPP_USP1_OptOut |
IAB US Privacy opt out of sale |
IABGPP_USP1_LSPACovered |
IAB US Privacy publisher is signatory to the LSPA |