Design note — Multiple accounts per provider (multi_account)

Target registry item: C1e (OB-GAP-6; checklist §5.5 — the vault holds one JSON secret per (tenant, provider), so a tenant with several Google Ads or Meta ad accounts has no modelled way to supply the second one). Status: design note only — NOT built; BLOCKED(owner) on the OB-GAP-6 decision. Measured on 2026-10-12: connector_credentials.py names the secret mizoki-connector-{tenant}-{provider} (collision-resistant form in secret_id, duplicated byte-for-byte in connectors/amazon_sp/client.py with a parity test); direct_connectors.resolve_provider_credentials builds ONE credential view per (tenant, provider) and binds account_id in the sync body as a confirmation against the single declared account.

Before designing a schema: the cheaper answer for Google Ads

Google Ads already models many accounts under one credential: login_customer_id (MCC) plus a per-pull customer_id. A tenant whose accounts sit under a manager account needs no multi-account schema — they need the MCC id on the card and the pull to accept any customer_id that listAccessibleCustomers returns under that MCC. That is a confirmation-set change (one declared MCC, N confirmable customers), not a second vault entry, and it should ship first. The schema below is for Meta (several ad accounts, one business) and for Google Ads without an MCC.

Schema

Two shapes were weighed:

option what changes verdict
A. One secret per account slot — mizoki-connector-{tenant}-{provider}-a{n} plus an index the naming formula (duplicated in two images, parity-pinned), the inventory labels, IAM grants per secret, secret_id's collision grammar Rejected: every consumer that reproduces the formula changes; the -h<12hex> collision suffix and an -a{n} suffix would need a new disambiguation rule.
B. One secret per (tenant, provider), payload schema 3 with an accounts list the payload only Proposed. The invariant "one JSON secret per (tenant, provider)" stays true; naming, IAM and inventory are untouched.

Schema-3 payload (illustrative shape, keys only):

{ "schema": 3, "provider": "meta_ads",
  "accounts": [ { "slot": "a1", "label": "<tenant-chosen>", "primary": true,
                  "<catalog fields for the provider>" … },
                { "slot": "a2", "primary": false, … } ] }

Binding rule (unchanged in spirit, widened in set)

account_id in a sync request is a confirmation that must match ONE declared account of the tenant — now a set membership check instead of an equality check — and never an override: a caller authorised for the tenant can select among the tenant's own declared accounts and nothing else. Absent account_id → the primary. The direction tests in tests/connectors/test_direct_connectors_governed.py are extended, not replaced: a foreign account id is still refused 403 with the existing detail text.

Readiness (onboarding_gaps): connectors.<p>:not-configured means no entry at all; a per-entry gap is connectors.<p>[<slot>].<field>:missing. Completion still reads credential STATE, never values, and still says nothing about arming.

UI contract

The card gains "Add another account" (schema-3 providers only, the catalog row carries multi_account: true), one test-connection per entry, a primary toggle, and removal of a non-primary entry. The entry form is the same field set the catalog serves — no second form.

Not a data-topic change: every account is inside the same tenant boundary and carries the same aggregate insights the single-account pull carries. The one posture property to pin: an entry's label is tenant-chosen free text — it is rendered, never logged with the secret, and never used in a secret name.

Mapper target

Unchanged. Each pull still produces CanonicalRecord rows whose account_id is the declared account the pull ran against; downstream nothing changes except that a tenant can now have rows from several of its own accounts.

Failure modes → test-connection verdicts

Failure Verdict / fix
account_id not among the tenant's declared accounts 403 — "account_id does not match an account this tenant declared" (existing text, set-widened).
Two entries declare the same account 422 duplicate_account at save.
List over the cap or document over the size limit 422 at save; nothing written.
Entry removed while a pull is scheduled against it the pull refuses merchant_credentials_not_configured for that slot; the readout names the slot.
Vault read error 503 fail-closed.

Flag

CONNECTOR_MULTI_ACCOUNT default OFF. Flag OFF: schema-3 payloads are still READ (a tenant's data is never unreadable because a flag moved) but the UI shows one entry and the save path refuses a second (422 multi_account_disabled).

Owner / operator gates

Vendor references

← All docsView source on GitHub →