# Consent Object

The Consent Object is a standardised way to represent consent throughout all methods of the onsite JavaScript API (similar to the IAB TCF consent string). The object holds a `meta` property that includes metadata like the validity of the cookie and a `consent` property that holds that current consent settings stored on the browser.

{% hint style="warning" %}
The onsite API and Consent Object is the official way to access the consent settings of TrustCommander with JavaScript. The direct usage of the [Consent Cookie](https://community.commandersact.com/consent-management/knowledge-base/consent-cookie) is deprecated.
{% endhint %}

## Example Consent Object

```javascript
{
    meta: {
        version: "1.0",
        tcfPolicyVersion: "2",
        siteId: "1234",
        bannerId: "12",
        bannerVersion: "50",
        consentId: "183049723840253",
        dateCreated: 1614174067000,
        dateUpdated: 1614185078030,
        dateExpires: 1614236789942
    },
    consent: {
        status: "all-on|all-off|mixed|unset",
        categories: {
            "1": {
                status: "on",
                required: true
            },
            "2": {
                status: "on|off|unset"
            },
            "tcf2_1": {
                status: "on|off|unset"
            },
            "tcf2_2": {
                status: "on|off|unset",
                legIntStatus: "on|off|unset"
            },
            "tcf2_sf_1": {
                status: "on|off|unset"
            }
        },
        vendors: {
          "1": {
                status: "on|off|unset"
          },
          "tcf2_1": {
                status: "on|off|unset"
          },
          "tcf2_2": {
                status: "on|off|unset",
                legIntStatus: "on|off|unset"
          },
          "acm_1": {
                status: "on|off|unset"
          }
        }
    }
}
```

## Meta Properties

The `meta` property includes metadata and context for the consent that was provided on a browser.

| Property                | Description                                                                        | Type   |
| ----------------------- | ---------------------------------------------------------------------------------- | ------ |
| `meta.version`          | Version of the Consent Object.                                                     | String |
| `meta.tcfPolicyVersion` | Version of the IAB TCF consent.                                                    | String |
| `meta.siteId`           | Commanders Act site id associated to the consent.                                  | String |
| `meta.bannerId`         | Banner id associated to the consent.                                               | String |
| `meta.bannerVersion`    | Banner version associated to the consent.                                          | String |
| `meta.consentId`        | Id of the consent stored in the `TCPID` cookie.                                    | String |
| `meta.dateCreated`      | Timestamp when the consent was provided (UNIX Epoch in Milliseconds).              | Number |
| `meta.dateUpdated`      | Timestamp when the consent was updated the last time (UNIX Epoch in Milliseconds). | Number |
| `meta.dateExpires`      | Timestamp when the consent will expire (UNIX Epoch in Milliseconds).               | Number |

## Consent Properties

The consent property includes detailed information about the consent provided on the browser.

| Property                                   | Description                                                                                                                                                                                                                                                                                                                                                                                                                                |
| ------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `consent.status`                           | <p>Global status of the consent that can have one of the following values:<br><strong>all-on:</strong> All consent categories have been accepted.</p><p><strong>all-off:</strong> All consent categories have been refused (except blocked on).</p><p><strong>mixed:</strong> Some consent categories have been refused.</p><p><strong>unset:</strong> No consent has been provided yet.</p>                                               |
| `consent.categories[category_id].status`   | <p>Status of an individual category:</p><p><strong>on:</strong> Consent was provided.</p><p><strong>off:</strong> Consent was rejected.</p><p><strong>unset:</strong> No consent has been provided yet (In case neutral button position is configured it will switch to neutral button position for this category).</p><p></p><p><code>category\_id</code> is the category id configured under <code>TRUST > Categories & Tags</code>.</p> |
| `consent.categories[category_id].required` | The property was set to blocked on and the status is always **on**.                                                                                                                                                                                                                                                                                                                                                                        |
| `consent.vendors[vendor_id].status`        | <p>Status of an individual vendor:</p><p><strong>on:</strong> Consent was provided.</p><p><strong>off:</strong> Consent was rejected.</p><p><strong>unset:</strong> No consent has been provided yet (In case neutral button position is configured it will switch to neutral button position for this vendor).</p><p></p><p><code>vendor\_id</code> is the vendor id configured under <code>TRUST > Categories & Tags</code>. </p>        |

Category and Vendor IDs are prefixed with an identifier in case they are managed by a consent framework.

| Framework | Prefix                                                                     |
| --------- | -------------------------------------------------------------------------- |
| `tcf2_`   | IAB TCF 2 framework. Special features are additionally prefixed with `sf_` |
| `acm_`    | Google's Additional Consent Mode vendors.                                  |
