Adventure Labs Logo
Scout Docs

Herd_invitations

Pending and historical invitations to join a herd

Column NameData TypeConstraints
idbigintNOT NULL
emailtextNOT NULL
herd_idbigintNOT NULL
herd_role_idbigintNOT NULL, FK herd_roles
invited_byuuidNOT NULL
statuspublic.herd_invitation_status (pending, accepted, revoked, expired)DEFAULT pending NOT NULL
created_attimestamp with time zoneDEFAULT timezone('utc'::text, now()) NOT NULL
accepted_attimestamp with time zone
expires_attimestamp with time zone

At most one pending invitation per (email, herd_id). Created via create_herd_invitation; accepted via accept_herd_invitations_for_current_user. Neither the RPC nor a direct update may assign a role that grants users_roles_per_herd.write unless the caller already holds that ability in the herd.

Security Policies (RLS)

RLS enabled. Herd scope: Herd from herd_invitations.herd_id.

Operationhas_herd_ability ability keyOther paths
SELECTherd_invitations.readInvitee: email = current_user_email() (no ability check)
INSERT—Via create_herd_invitation RPC (herd_invitations.write inside function)
UPDATEherd_invitations.writeChanging herd_role_id to a role holding users_roles_per_herd.write requires the caller to hold it (herd_invitations_role_guard)
DELETE—No direct user DELETE policy

Platform superadmin: FOR ALL bypass where defined.

On this page