30 days free. No credit card. Full access from the moment you connect your site.

Start free trial

Declare a Cookie

consent/add-cookie adds a cookie to the declared list, so the preference centre names it under its consent category.

It needs the name a browser stores the cookie under, a category, and a description a visitor can actually understand.

At a glance

Abilityconsent/add-cookie
ToolsetCookieYes — toolset/cookieyes
GroupCookieYes › Declared Cookies
RequiresCookieYes, active on the site
Capabilitymanage_options
SafetyWrites data
RepeatableNot idempotent — each call changes the row set, so re-running is not a no-op
Ships inAcrossAI Abilities Manager 0.0.34 and later

Declaring is not controlling

This changes what the banner says, not what the site does. Declaring _ga does not make Google Analytics load, and not declaring it does not stop it. The declaration is the disclosure, and the disclosure is what the banner is for.

Which means the failure mode runs the other way from what people expect: an inaccurate inventory makes the banner wrong, not the site. A cookie the site sets and does not declare is the gap that matters.

The banner a visitor receives is not assembled on the fly. It is cached HTML, built from the declared cookies, the consent categories and the settings, and rebuilt only when the consent plugin’s own save hooks fire. Write the consent tables any other way — through the database abilities, through another plugin — and the row reads back correctly while every visitor still sees the previous banner, with no error anywhere to say so.

So the write goes through the plugin’s own writer and then checks. The response reports whether the banner was refreshed, what it now contains per language, and whether a rebuild is still pending — the difference between stored and actually being served.

Description and duration each take either one string, applied to every language, or a map keyed by language code.

Input

NameTypeRequiredWhat it is
namestringYesThe cookie name as the browser stores it, for example _ga.
category_idintegerYesConsent category ID, from consent/list-categories.
descriptionstring | objectNoWhat the cookie does, in plain language. A plain string is applied to every language. A map keyed by language code sets them individually, and languages you leave out keep the text they already had.
durationstring | objectNoHow long it lasts, for example 1 year. A plain string is applied to every language. A map keyed by language code sets them individually, and languages you leave out keep the text they already had.
domainstringNoThe domain that sets it.
typeintegerNoThe consent plugin’s own numeric cookie type. It publishes no meaning for the codes, so leave it unset unless you are copying an existing entry.
url_patternstringNoRestrict the declaration to pages matching this pattern.

What comes back

NameTypeWhat it is
cookieobjectThe declared cookie as stored.
banner_refreshedbooleanWhether the cached banner was rebuilt after the write. This is the field that says the change actually reached visitors.
languagesarrayThe languages the banner is built for.
renderedobjectThe size of the built banner, per language.
pending_rebuildbooleanWhether the banner is still waiting to be rebuilt. True after a write means the change is stored but not yet being served.
successbooleanWhether the call completed.
messagestringA one-line summary of what happened, suitable for showing a human.
error_codestringPresent only on failure — a stable machine-readable reason, such as a missing field, a wrong field type or an unmet confirmation.

Example

Ask your assistant:

Add the _ga cookie to our analytics category with a one-year duration.

It resolves to one call:

{
  "ability": "consent/add-cookie",
  "parameters": {
    "name": "_ga",
    "category_id": 3,
    "description": "Distinguishes visitors so we can count them without identifying them.",
    "duration": "1 year",
    "domain": ".example.com"
  }
}

Worth knowing

  • Write the description for a visitor, not for a developer. It is the text somebody reads before deciding.
  • Not idempotent — declaring the same cookie twice lists it twice.
  • Check banner_refreshed in the response. A stored cookie that is not in the built banner is not being shown to anybody.
  • The category decides whether the cookie may load before consent. Put it in the right one.

Related abilities


Get the plugins:
AcrossAI Abilities Manager · AcrossAI MCP Manager

Browse the rest: Every ability, by category


Keep reading