Shuntline›Solutions›Opt-in›Documentation
Shuntline Opt-in · documentation · version 1.0
Install, record, ask
For Snowflake administrators, privacy and marketing operations, integration teams and security reviewers: how to install Shuntline Opt-in, what it holds, how an answer is worked out, the SQL API that records and asks, how a privacy centre is built on it, how access works, and how the app is built.
Install and try
A Snowflake Native App, available on the Snowflake Marketplace. It runs entirely inside your Snowflake account: no container, no external connection, no task.
- 01 · INSTALL
From the listing
Install into your account and approve the one privilege it asks for.
- 02 · GRANT
Four roles
OPTIN_OPERATORto the privacy team,OPTIN_INTEGRATIONto the systems that record and ask,OPTIN_VIEWERto analysts and agents. The installing role is administrator; without the Hub, the console opens to administrators. - 03 · TRY
Sample company
One click in an empty console, or one call: five purposes, four channels, about three hundred people, email addresses on example domains and phone numbers from ranges reserved for fiction, a year and a half of decisions.
- 04 · CONFIGURE
Your vocabulary
Your purposes, their wordings and your channels, in the console or in SQL. Then your systems start recording.
CALL SHUNTLINE_OPTIN.API.MANAGE('load_sample', {});
| Privilege requested | Why |
|---|---|
CREATE WAREHOUSE | The app's own X-Small warehouse (SHUNTLINE_OPTIN_WH) for the console and the SQL API, suspended 60 seconds after the last query. |
Requires a paid Snowflake account on AWS or Azure: the register lives in hybrid tables, not available on trial accounts and in preview on Google Cloud. CALL SHUNTLINE_OPTIN.SETUP.STATUS(); shows the mode, the counts and the migrations applied.
Concepts
A register: what each person decided about being contacted, recorded once, kept for ever. It sends nothing and never says whether you may contact someone.
| Purpose | What people are asked about: a newsletter, product news, partner offers. Its key is supplied once and never changes: it is what your systems send. A purpose is retired, never deleted: a retired purpose still takes withdrawals and still answers. |
|---|---|
| Wording | A purpose's text, numbered by the register. A draft can be revised or discarded; once published it is frozen, and every decision recorded from then on cites it. A decision keeps the wording in force when it was taken, whatever is published later. |
| Channel | How a person may be reached: email, sms, phone, post. Codes never change; a retired channel takes withdrawals only. |
| Subject | An identifier and nothing else about a person: an email address (trimmed, lower case) or a phone number in international format (+33639981234; spaces, dots, hyphens and brackets are stripped, a national number is refused). Unique. An email and a phone are separate subjects, never linked: a decision on one never touches the other. Asking about an identifier never creates it. |
| Rungs | Global (no purpose, no channel): "do not contact me at all". Channel: every purpose on it. Purpose on a channel. There is no fourth rung: a purpose always comes with a channel. |
| Journal | Every decision ever recorded, with how it arrived (method, source, collection point, language), when it was taken and when it was recorded. Never edited: a change of mind is a new entry. A decision dated before a newer one joins the journal and leaves the answer alone. |
| Erasure | A request records an intention and erases nothing. An administrator carries it out, retyping the identifier, or declines it. Carried out, the address or number becomes a token that leads nowhere; the journal stays, naming nobody, and anything an erasure cannot clean is reported. |
The decision rule
What a person decided about a purpose on a channel is read from at most three rows: the global rung, the channel's rung, the purpose's rung on it.
| 1 · A refusal wins | A refusal at any rung wins, and the most general rung that refused is reported. A global opt-out is never narrowed by an opt-in to one purpose. |
|---|---|
| 2 · The most specific yes | Otherwise the most specific opt-in applies: an opt-in to a channel answers for a purpose nobody asked about, because nothing contradicts it. |
| 3 · Otherwise unknown | UNKNOWN. A rung recorded as UNKNOWN and no rung at all are the same thing. |
| The answer | {status, level, determined}: OPT_IN, OPT_OUT or UNKNOWN; the rung that said it; and determined, false only when the answer could not be worked out: a fault to alert on, never a fact about the person. There is no allowed and no legal basis. |
SQL API
Functions and views to ask, procedures to record: from a worksheet, any Snowflake driver, the Snowflake SQL API (HTTPS), a BI tool or an AI agent. SHUNTLINE_OPTIN is the default app name.
Ask
| Object | Purpose |
|---|---|
DATA.DECISION(identifier, purpose, channel) | What this email address or phone number decided: {status, level, determined}. One indexed read. |
DATA.DECISIONS(purpose, channel) | Everyone with a decision bearing on this purpose and channel, resolved the same way. Returns identifier and kind. For a list: join on the identifier; one not returned is UNKNOWN. |
DATA.PREFERENCES(identifier) | Everything this identifier decided, one row per rung. |
DATA.HISTORY(identifier) | Every decision this identifier recorded, as receipts with the wording each cited. |
DATA.CHANGES_SINCE(since) | Events recorded after since (UTC), for the systems that act on them. Ids and codes, never an address or a number. |
DATA.CHANGES | Every event: consent.opted_in, consent.opted_out, consent.global_opted_out, consent.recorded (the answer did not move), privacy.erasure_requested, privacy.erased, privacy.erasure_declined. |
DATA.PURPOSES · DATA.PURPOSE_VERSIONS · DATA.CHANNELS | The vocabulary: purposes with the wording in force and their drafts, every wording, channels. |
DATA.SUBJECTS · DATA.CONSENT_STATE · DATA.JOURNAL · DATA.ERASURE_REQUESTS | Subjects (an erased one carries its token), the current answer one row per rung with its wording, every decision ever recorded, the requests to be forgotten. |
API.PROFILE(identifier or id) | One person in one call: rungs, decisions per purpose and channel, history, erasure requests. |
Record
| Procedure | Purpose |
|---|---|
API.RECORD_CONSENT(decision) | Records a decision: {identifier, status, purpose, channel, source, collection_point, language, metadata, idempotency_key, occurred_at, method}. |
API.SUBSCRIBE(identifier, purpose, channel, options) | An opt-in to a purpose on a channel. |
API.UNSUBSCRIBE(identifier, purpose, channel, options) | An opt-out from a purpose on a channel. |
API.UNSUBSCRIBE_ALL(identifier, options) | A global opt-out. There is no subscribe-all: agreeing to every purpose at once would be bundled consent. |
API.REQUEST_ERASURE(identifier, options) | A request to be forgotten ({source, note}); erases nothing. |
Administer
| Procedure | Purpose |
|---|---|
API.SAVE_PURPOSE(object) | Creates {key, name, description} or changes a purpose; is_active false retires it. |
API.DRAFT_WORDING · API.REVISE_WORDING · API.PUBLISH_WORDING · API.DISCARD_WORDING | A purpose's wordings: draft, revise or discard the draft, publish (frozen from then on, never removed). |
API.SAVE_CHANNEL(object) | Creates {code, name} or changes a channel. |
API.RUN_ERASURE(request id, identifier) | Carries out a request; the identifier retyped as a check. |
API.MANAGE(op, args) | config, load_sample, decline_erasure ({request_id, reason}), and the operations above. |
Recording. method says how your system collected the decision: API (the default), WEB_FORM, EMAIL_LINK or IMPORT; decisions recorded in the console are ADMIN. occurred_at dates a decision taken earlier, for an import. An idempotency key makes a retry safe: the database enforces it as unique, a retry answers the entry already recorded, and a key reused for a different decision is refused. Do not put personal data in metadata or in an idempotency key: the journal cannot be edited, so an erasure can only report such entries.
Examples
They run on a fresh install, as the role that installed the app.
Record, then ask
CALL SHUNTLINE_OPTIN.API.SUBSCRIBE('jane.doe@example.com', 'newsletter', 'email',
{'source': 'signup-form', 'method': 'WEB_FORM', 'idempotency_key': 'signup-2026-0001'});
SELECT * FROM TABLE(SHUNTLINE_OPTIN.DATA.DECISION('jane.doe@example.com', 'newsletter', 'email'));
-- a phone number is asked the same way, in international format
SELECT * FROM TABLE(SHUNTLINE_OPTIN.DATA.DECISION('+44 7700 900198', 'newsletter', 'sms'));
A whole list, before a send
SELECT c.customer_id, COALESCE(d.status, 'UNKNOWN') AS status, d.level
FROM my_crm.customers c
LEFT JOIN TABLE(SHUNTLINE_OPTIN.DATA.DECISIONS('newsletter', 'email')) d
ON d.identifier = LOWER(TRIM(c.email));
Following changes
-- keep the last recorded_at processed, and pass it next time
SELECT * FROM TABLE(SHUNTLINE_OPTIN.DATA.CHANGES_SINCE('2026-11-18 09:00:00'::TIMESTAMP_NTZ))
ORDER BY recorded_at;
Nothing leaves your account: systems poll. CHANGES_SINCE returns what was recorded up to ten seconds ago, so nothing still being written is skipped. A system that acts on opted_in, opted_out and global_opted_out and ignores consent.recorded is correct by construction.
Building a privacy centre
Not in the app, on purpose: a public page is a different security perimeter from a register inside your Snowflake account. It is built on the SQL API, by you, or from our blueprint, delivered on demand.
| The page shows or does | It calls |
|---|---|
| Each purpose on each channel, with the wording in force | DATA.PREFERENCES(identifier), DATA.PURPOSES, DATA.CHANNELS |
| Subscribe, Unsubscribe, per purpose; nothing pre-ticked | API.SUBSCRIBE, API.UNSUBSCRIBE, with method WEB_FORM or EMAIL_LINK |
| Stop contacting me about anything | API.UNSUBSCRIBE_ALL |
| What I decided, and when | DATA.HISTORY(identifier): each decision with the wording it cited |
| Forget me | API.REQUEST_ERASURE: recorded, carried out by an administrator |
Your backend calls these as a Snowflake service user holding OPTIN_INTEGRATION, through the Snowflake SQL API or a driver. Who may see a person's choices is decided by you, where you already know them: a customer login, a code you send, a link your system mints after its own check. The register records what was decided and by which method; it never pretends to have checked who was asking.
Links into the console
The console opens full page, without Snowsight's menus, on the subject or purpose its address names. A CRM can put the link on a customer's page; whoever opens it signs in to Snowflake. Without the Hub the console opens to administrators; with it, to everyone the Hub gives a role, each seeing what that role allows.
https://app.snowflake.com/streamlit/<organization>/<account>/#/apps/<console id>?subject=jane.doe@example.com
-- the console id is your install's own (url_id)
SHOW STREAMLITS IN APPLICATION SHUNTLINE_OPTIN;
| subject=<identifier or id> | A phone number's + is written %2B (?subject=%2B447700900198). The subject: decisions per purpose and channel, rungs, history, requests. |
|---|---|
| purpose=<key> | The purpose and its wordings. |
| tab=journal | The journal. |
Access
The same rule applies at every way in: the console, the functions and views, the procedures and the AI agents that use them.
| Application role | Opens |
|---|---|
OPTIN_VIEWER | The DATA views and functions, API.PROFILE. |
OPTIN_OPERATOR | Recording decisions and erasure requests (includes viewer). |
OPTIN_INTEGRATION | For systems: asking (DECISION, DECISIONS, PREFERENCES, HISTORY, CHANGES_SINCE, the vocabulary, API.PROFILE), the recording procedures, API.REQUEST_ERASURE. |
OPTIN_ADMIN | The console; purposes, wordings, channels, carrying out erasures, the sample, setup (includes operator and integration). The installing role holds it. |
The app's four roles
Granted by your Snowflake administrator; the grant is the whole decision, and no role reaches more than its own. The console runs with the app's rights and cannot tell its users' roles apart, so it opens to OPTIN_ADMIN only; operators and viewers work through SQL. A web app that shows the console as its viewer runs each action through the door of its tier (API.ACT_EDIT for operators, API.ACT_ADMIN for administrators), each granted to that role.
Roles per person
Administrator, operator, viewer and integration, decided per person. The console opens to everyone you grant OPTIN_VIEWER, and shows each what their role allows: a viewer, no write. Connecting and disconnecting change the grants at once. No scope: the register has no tenancy, and a refusal at the global rung concerns every purpose. Shuntline Hub →
GRANT APPLICATION ROLE SHUNTLINE_OPTIN.OPTIN_OPERATOR TO ROLE <privacy team role>;
GRANT APPLICATION ROLE SHUNTLINE_OPTIN.OPTIN_INTEGRATION TO ROLE <email platform service role>;
GRANT APPLICATION ROLE SHUNTLINE_OPTIN.OPTIN_VIEWER TO ROLE <analyst role>;
-- with Shuntline Hub
GRANT APPLICATION ROLE SHUNTLINE_HUB.SOLUTION_RUNTIME TO APPLICATION SHUNTLINE_OPTIN;
CALL SHUNTLINE_OPTIN.SETUP.CONNECT_HUB('SHUNTLINE_HUB', 'optin');
Architecture
Installed from the Marketplace into your account, the app runs there with your data, and nothing leaves.
| Component | What it is |
|---|---|
| Console | Streamlit in Snowsight, one page: overview, subjects (each with its decisions per purpose and channel, rungs, history and requests), journal (filtered by kind, rung, the answer recorded, purpose, channel or method), purposes and their wordings (retiring one is confirmed), channels, erasure. Reference data goes to the browser once; subjects and the journal are read on demand, a page at a time. |
| Engine | JavaScript procedures: validation, recording, the ladder, wordings, erasure, access. The ladder is one function, checked case for case against the original register's. |
| Hybrid tables | Purposes, wordings, channels, subjects, rungs, the journal, idempotency keys, erasure requests, audit. |
| Read functions and views | DATA.*: one indexed read per answer, keyset pages for lists. |
Design choices
| One table of rungs | Global, channel and purpose rungs in one table with a unique key per person and rung: an answer is at most three rows, read by index. |
|---|---|
| Append-only journal | Written with the rung in the same transaction; never edited. The current answer and its history cannot disagree. |
| Unique keys the database enforces | An identifier, a rung per subject, an idempotency key and a wording's number: a retry or a race cannot record twice. |
| A feed, not webhooks | Nothing leaves the account: integrations read what changed, ids and codes only, in order. |
| Versioned data, safely | A migration ledger from the first version: each change to the stored data runs once, and destructive changes take two versions. |
| No container, no external connection, no task | Simpler to install and to review; nothing to patch; an idle install costs nothing. |
Structure
Schemas inside the app: core (state), logic (the console's operations), api (what people, agents and systems call), data (read functions and views), setup (installation), ui (the console).