Supabase
Call SendFS from a Supabase Edge Function when a row is inserted. The service role stays on Supabase. The SendFS key stays in the function secret.
In the Supabase dashboard, set SENDFS_API_KEY and SENDFS_FROM. Deploy the function below and invoke it from a database webhook on auth.users or your own profiles table.
import "jsr:@supabase/functions-js/edge-runtime.d.ts";
Deno.serve(async (req) => {
const payload = await req.json();
const email = payload.record?.email;
if (!email) return new Response("missing email", { status: 400 });
const response = await fetch(Deno.env.get("SENDFS_URL") + "/api/emails", {
method: "POST",
headers: {
Authorization: `Bearer ${Deno.env.get("SENDFS_API_KEY")}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
from: Deno.env.get("SENDFS_FROM"),
to: [email],
template: "welcome",
variables: { email }
})
});
return new Response(await response.text(), { status: response.status });
});