Add email to resend audience using database function

Hello, I am trying to basically add an email address to my resend audience every single time after a user creates an account.

The way I am trying to make this work is with my handle_new_user function by adding something that would call my supabase edge functionthat would add the email.

Here is the code I am using for that

begin
  -- Insert into profiles table
  insert into public.profiles (id, email, full_name)
  values (
    new.id,
    new.email,
    new.raw_user_meta_data->>'full_name'
  );

  -- Asynchronous HTTP POST using pg_net to notify Edge Function
  begin
    perform net.http_post(
      url := 'https://-----.supabase.co/functions/v1/add-to-resend',
      headers := jsonb_build_object(
        'Content-Type', 'application/json'
      ),
      body := jsonb_build_object(
        'email', new.email
      )
    );
  exception when others then
    -- Silently ignore any HTTP errors
    null;
  end;

  return new;
end;

I enabled pg_net in the extensions tab (see image)

Basically the user is getting added to the auth fine, but the supabase edge function is not getting called which is making me think there is an issue without how I am using the function and using pg_net/calling the edge function.
Was this page helpful?