# Set up or change the cookie and consent widget

`PUT /crm/consent-widget` · Rivier · contacts

Set up or change the cookie and consent widget. Visitors are asked again after a change. A person's setting.

- Scope: contacts:admin
- Sdk: contacts.consentWidget.save
- Cli: contacts consent widget save

## Request body

`application/json`

```json
{
  "type": "object",
  "properties": {
    "ownerMode": {
      "type": "string",
      "enum": [
        "M0",
        "M1",
        "M2"
      ],
      "default": "M1"
    },
    "childAudience": {
      "type": "boolean",
      "default": false
    },
    "categories": {
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "preferences",
          "analytics",
          "marketing",
          "notifications"
        ]
      },
      "maxItems": 4,
      "default": []
    },
    "cookies": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "category": {
            "type": "string",
            "enum": [
              "necessary",
              "preferences",
              "analytics",
              "marketing",
              "notifications"
            ]
          },
          "purpose": {
            "type": "string",
            "minLength": 3,
            "maxLength": 200
          },
          "duration": {
            "type": "string",
            "minLength": 1,
            "maxLength": 60
          },
          "provider": {
            "type": "string",
            "maxLength": 100
          }
        },
        "required": [
          "name",
          "category",
          "purpose",
          "duration"
        ],
        "additionalProperties": false
      },
      "maxItems": 100,
      "default": []
    },
    "defaultLanguage": {
      "type": "string",
      "pattern": "^[a-z]{2}(-[A-Za-z]{2})?$",
      "default": "en"
    },
    "copy": {
      "type": "object",
      "additionalProperties": {
        "type": "object",
        "properties": {
          "title": {
            "type": "string",
            "maxLength": 120
          },
          "body": {
            "type": "string",
            "maxLength": 600
          },
          "categoryText": {
            "type": "object",
            "additionalProperties": {
              "type": "string",
              "maxLength": 200
            },
            "propertyNames": {
              "enum": [
                "preferences",
                "analytics",
                "marketing",
                "notifications"
              ]
            }
          }
        },
        "additionalProperties": false
      },
      "propertyNames": {
        "pattern": "^[a-z]{2}(-[A-Za-z]{2})?$"
      }
    },
    "design": {
      "type": "object",
      "properties": {
        "theme": {
          "type": "string",
          "enum": [
            "auto",
            "light",
            "dark"
          ],
          "default": "auto"
        },
        "position": {
          "type": "string",
          "enum": [
            "bar",
            "card"
          ],
          "default": "bar"
        },
        "accent": {
          "type": "string",
          "pattern": "^#[0-9a-f]{6}$"
        },
        "radius": {
          "type": "integer",
          "minimum": 0,
          "maximum": 32
        }
      },
      "additionalProperties": false,
      "default": {}
    },
    "googleConsentMode": {
      "type": "boolean",
      "default": false
    },
    "expiryDays": {
      "type": "integer",
      "minimum": 30,
      "maximum": 395,
      "default": 180
    },
    "allowedOrigins": {
      "type": "array",
      "items": {
        "type": "string",
        "maxLength": 200
      },
      "maxItems": 20
    },
    "policyUrl": {
      "type": "string",
      "format": "uri",
      "maxLength": 300
    }
  },
  "additionalProperties": false
}
```

## Responses

- `200`: Success
- `400`: The request was malformed
- `401`: No valid credential
- `403`: The credential lacks the scope, origin or address
- `429`: Over the key's rate limit; see Retry-After

## Example

```sh
curl -X PUT 'https://api.rivier.ai/crm/consent-widget' \
  -H 'Authorization: Bearer $KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "ownerMode": "M1",
  "childAudience": false,
  "categories": [],
  "cookies": [],
  "defaultLanguage": "en",
  "copy": {},
  "design": {},
  "googleConsentMode": false
}'
```
