Send sellers to KYC review past a payout threshold
Start a KYC check when a seller's payouts in Supabase cross a limit, once per seller, through your verification provider's API. Trigger SQL included.
- Supabase
- Any REST API
- Slack
- Compliance
- once per seller
The trigger
One read-only SELECT against Supabase. Rowfire polls it for new rows, and the rule fires once per seller.
WITH running AS (
SELECT p.seller_id,
p.amount_cents,
p.paid_at,
sum(p.amount_cents) OVER (PARTITION BY p.seller_id
ORDER BY p.paid_at, p.id) AS total_cents
FROM payouts p
WHERE p.status = 'paid'
)
SELECT r.seller_id,
s.legal_name,
s.country,
s.email,
r.total_cents / 100.0 AS total_paid_out,
r.paid_at AS crossed_at
FROM running r
JOIN sellers s ON s.id = r.seller_id
WHERE r.total_cents >= 1000000
AND r.total_cents - r.amount_cents < 1000000
AND s.kyc_level = 'basic'
AND s.is_test = falseA marketplace can let new sellers start with light checks, then verify them properly once real money flows. The money arrives as payout rows. Nothing in the app runs when a seller’s running total passes the line, so the full check waits until someone in compliance pulls a report.
The query finds the moment instead. It adds up each seller’s paid payouts in
time order and returns the one payout that took the total past $10,000. The
key is seller_id and the clock is crossed_at, when that payout was paid.
When a poll sees a new row, the rule fires once per seller. Sellers who
already passed full verification drop out, and so do test accounts. Tables
without a schema are read as public, where an app on Supabase usually keeps
them. Table and column names are a sketch; adapt them to your schema.
The REST API side
Add your verification provider as an integration: its base URL, its auth header and one action that opens a check. Templates fill the body from the row:
POST /verifications
{"reference": "{{ seller_id }}", "legal_name": "{{ legal_name }}", "country": "{{ country }}", "email": "{{ email }}"}
The provider’s API key is added at send time, so it is never stored with the recorded request. If your own app has an endpoint that marks a seller as under review, bind it to the same rule as a second action. Each binding sends its own request.
A heads-up for the compliance team
Add a second rule on the same trigger with a Slack action that posts to
#compliance:
{{ legal_name }} ({{ country }}) passed $10,000 in payouts. KYC check requested.
Each rule keeps its own count, so the Slack message can go live while the provider call is still in shadow.
A second tier
Some programs check again at a higher amount. That is a second trigger with
the larger number and its own kyc_level filter, and its own rule. Changing
a threshold is a trigger edit, not a release. Editing a trigger sends its
rules back to shadow, so you see the effect before anything sends.
A backtest shows how many sellers would have been sent over past weeks. It reads rows as they are now, so a seller who has since been verified is not counted: treat the number as a floor.
For another review that starts from a query, see send flagged orders to a fraud service. For more on reading Supabase, see how to send Slack alerts from Supabase, or try a trigger on the live demo.
Questions
Will the seller's next payout start another check?
No. Only the payout that crossed the limit matches the query, and the key is seller_id with a once-per-seller cadence, so each seller fires one time.
Can this hold the payout until the check clears?
Not by itself. Rowfire reads the database after the payout is recorded, within a minute by default, and never writes to it. Blocking a payout belongs in the code that sends it.
Does Rowfire need my Supabase database password?
No. It sends the query to Supabase's read-only query endpoint, which runs it as Supabase's read-only user. You connect with OAuth (Projects: Read and Database: Read) or a personal access token.
Will sellers already past the limit fire when I switch it on?
No. The poller starts every trigger at now, so history never fires. A backtest shows what the rule would have done over past days, without sending anything.