# Didomi Consent String Structure

## Didomi Consent String V2 schema <a href="#pdf-page-wwo5iebb8qrzzogwftxg-didomi-consent-string-fields" id="pdf-page-wwo5iebb8qrzzogwftxg-didomi-consent-string-fields"></a>

```
"types": [
    "version",
    "uuid",
    "date",
    "u16",
    "enabled_disabled_ids",
    "bit_field_2_bits",
    "ranges_u16",
    "ranges_fibonacci"
  ],
  "fields": [
    {
      "type": "version",
      "description": "Didomi Consent String Specification Version, 6 bits number - 000010 or 'C' in Base64 for v2",
      "key": "version",
      "value": 2
    },
    {
      "type": "uuid",
      "description": "User ID (UUID)",
      "key": "user_id"
    },
    {
      "type": "date",
      "description": "UTC epoch time format when the Consent String was initially created",
      "key": "created"
    },
    {
      "type": "date",
      "description": "UTC epoch time format when the Consent String was last time updated",
      "key": "updated"
    },
    {
      "type": "u16",
      "description": "Regulation ID that was used to encode user status",
      "key": "regulation_id"
    },
    {
      "type": "date",
      "description": "Last sync date",
      "key": "sync",
      "optional": true
    },
    {
      "type": "enabled_disabled_ids",
      "description": "User Status for purposes opt-in",
      "key": "purposes_optin",
      "variants": [
        "bit_field_2_bits",
        "ranges_u16",
        "ranges_fibonacci"
      ]
    },
    {
      "type": "enabled_disabled_ids",
      "description": "User Status for purposes opt-out",
      "key": "purposes_optout",
      "variants": [
        "bit_field_2_bits",
        "ranges_u16",
        "ranges_fibonacci"
      ]
    },
    {
      "type": "enabled_disabled_ids",
      "description": "User Status for vendors opt-in",
      "key": "vendors_optin",
      "variants": [
        "bit_field_2_bits",
        "ranges_u16",
        "ranges_fibonacci"
      ]
    },
    {
      "type": "enabled_disabled_ids",
      "description": "User Status for vendors opt-out",
      "key": "vendors_optout",

      "variants": [
        "bit_field_2_bits",
        "ranges_u16",
        "ranges_fibonacci"
      ]
    }
  ]
```

{% hint style="info" %}
Optional fields should appear in an encoded string if the value of the related field is set accordingly.

For example, if `StartFromOne` is set to `0`, then `StartID` should be present in the encoded field. If `StartFromOne` is `1`, then `StartID` will be absent.
{% endhint %}

Within the same consent string, different sections may have different encoding (BitField, Range or Fibonacci) based on the range of the IDs to encode. The final goal being the generation of the smallest possible cookie. The `EncodingAlgorithm` property indicates which mechanism was used for encoding the given section.
