Javascript API (Old Version)
Overview
The Pandectes JavaScript API allows your store to interact with the consent banner without relying solely on the banner's built-in behavior. It gives developers a set of tools to read the current state of the banner and consent, trigger actions, and listen for events all from your store's theme or custom scripts. This page describes the capabilities available in the Legacy Banner version of the API.
What can you do with the Legacy JavaScript API?
Read the state of the banner and consent
The API exposes a set of read-only properties that reflect the current state of the banner and the visitor's consent at any given moment. You can check:
- Whether the API and banner have fully loaded and are ready to use
- Whether the banner is currently visible on screen
- Whether the banner is applicable to the current visitor at all (based on geolocation rules)
- Whether geolocation is active and which country the visitor is detected in
- Which language the banner is currently displayed in
- The visitor's consent status for each individual cookie category: strictly necessary, functionality, performance, targeting, and unclassified cookies
- Whether the visitor has clicked Allow, Decline, or Dismiss on the banner
This gives your store a real-time snapshot of exactly what a visitor has agreed to and how they interacted with the banner.
Control the banner display
The API lets you show or hide the banner programmatically, rather than relying only on the automatic display rules. Specifically, you can:
- Show the banner — force the consent banner to appear for the visitor
- Hide the banner — remove it from view, with the option to also show or hide the revoke/reopen button at the same time
- Show or hide the revoke button — the small button that lets visitors reopen the banner after they've already made a choice
This is useful when you want to trigger the banner in response to a specific user action, such as clicking a "Cookie settings" link in your footer.
Open and close the preferences popup
Beyond the main banner, the API also gives you control over the cookie preferences popup, the panel where visitors can accept or decline individual cookie categories. You can:
- Open the preferences popup directly
- Close it programmatically
- Save the visitor's current preferences and close the popup in one action
- Set the status of individual category checkboxes within the popup
- Apply consent changes at a category level with different levels of granularity
This allows for fully custom consent flows where the preferences panel is triggered or managed outside of the banner itself.
Trigger a consent revoke
The API allows you to revoke a visitor's previously given consent programmatically. This resets their consent state and, by default, will reopen the banner so they can make a new choice. Optionally the banner can be prevented from reopening automatically if you want to handle that step yourself.
Force a "leave site" action
The API includes a method to trigger the leave site functionality — the same action that occurs when a visitor clicks a leave-site button on the banner. This is useful in scenarios where you want to offer visitors an explicit way to exit the store as part of a custom privacy flow.
Listen for banner and consent events
The API fires events at key moments during the banner lifecycle, so your store can react in real time. You can listen for:
- When the Pandectes API has initialised and is ready
- When the page has fully loaded
- When the visitor's location has been detected (useful for geolocation-based logic)
- When the language of the banner has been set
- When the banner becomes visible
- When the banner is hidden
- When the visitor clicks the leave site button
- When the banner is closed (after a consent decision)
- When a consent decision is made or updated
- When the visitor opens the preferences panel
These events allow other scripts and integrations on your store to respond immediately to consent changes — for example, loading a tracking script the moment a visitor grants consent, without requiring a page reload.
Who is this for?
The JavaScript API is intended for merchants with a developer or for stores using a custom or headless storefront. The banner works fully on its own without any API usage — this is for advanced scenarios where tighter integration with your store's behaviour is needed.
Getting started
To view the full API reference, navigate to Settings → JavaScript API inside the Pandectes app. If you need help with a specific use case, reach out to our support team.
Updated on: 17/04/2026
Thank you!
