Skip to content

Cookie Consent API

The cookie consent module shows a banner on the client area until the visitor accepts it. These calls read and save the banner’s texts and get the banner a page shows. See Cookie consent for the settings page.

Admin calls need Module access on the Cookieconsent card of the staff group’s Permissions tab, plus each call’s own permission below (Super Administrators have all). See Authentication.

POST /api/admin/cookieconsent/get_settings

Returns the banner as visitors see it in the caller’s current language.

Permission: Manage settings (cookieconsent.manage_settings)

No parameters.

Returns: An object: message, button, privacy_url (empty when there is no link) and position (bar or card). A text left blank in the settings comes back as the built-in text.

POST /api/admin/cookieconsent/get_config

Returns the saved settings for an edit form, with the built-in texts of every language.

Permission: Manage settings (cookieconsent.manage_settings)

No parameters.

Returns: An object: message and button (empty when the built-in text is used), privacy_url, position, translations (language code => message, button), builtin (language code => the built-in message and button, for each turned-on language), default_locale and default_builtin (the built-in texts of the default language).

Example

Request parameters:

{}

result:

{
"message": "",
"button": "",
"privacy_url": "https://example.com/privacy",
"position": "bar",
"translations": {
"de_DE": {
"message": "Diese Website verwendet Cookies.",
"button": "OK"
}
},
"builtin": {
"en_US": {
"message": "This website uses cookies. By continuing to use this website, you consent to our use of these cookies.",
"button": "Accept"
}
},
"default_locale": "en_US",
"default_builtin": {
"message": "This website uses cookies. By continuing to use this website, you consent to our use of these cookies.",
"button": "Accept"
}
}

POST /api/admin/cookieconsent/save_settings

Saves the banner settings. Every setting is replaced, so send them all.

Permission: Manage settings (cookieconsent.manage_settings)

Parameter Type Description
position string, required bar (across the bottom) or card (a box in a corner).
message string Up to 1000 characters. Blank: the built-in text, translated into each language.
button string The button text, up to 40 characters. Blank: the built-in text.
privacy_url string A link to your privacy policy, starting with https:// or http://. Empty: no link.
translations object Your own texts per language: language code (such as de_DE) => message and button. A language with both blank is dropped and uses the main texts.

Returns: true

Errors:

  • Choose where the banner shows.
  • Enter a message of up to 1000 characters.
  • The button text can be up to 40 characters.
  • The Privacy Policy address must start with https:// or http://.
  • Invalid locale code: (a language that is not installed)
Example

Request parameters:

{
"position": "card",
"message": "",
"button": "Got it",
"privacy_url": "https://example.com/privacy",
"translations": {
"de_DE": {
"message": "Diese Website verwendet Cookies.",
"button": "OK"
}
}
}

result:

true

POST /api/guest/cookieconsent/message

Returns the banner message in the current language.

No parameters.

Returns: The message text: the language’s own text, else the main text, else the built-in text.

POST /api/guest/cookieconsent/settings

Returns the banner a page should show, in the current language.

No parameters.

Returns: An object: message, button, privacy_url (empty when there is no link) and position (bar or card).

Example

Request parameters:

{}

result:

{
"message": "This website uses cookies. By continuing to use this website, you consent to our use of these cookies.",
"button": "Accept",
"privacy_url": "https://example.com/privacy",
"position": "bar"
}