© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•3y ago•
5 replies
e.mc

Accessing anon_key or url from sql

@

Hi there!

I have the following function and trigger definitions:

CREATE OR REPLACE FUNCTION handle_insert() RETURNS TRIGGER AS $$
BEGIN
    PERFORM net.http_post(
            url:='<WOULD BE NICE TO ACCESS SUPABASE_URL HERE>',
            body:=json_build_object('target',NEW.data)::jsonb,
            headers:='{"Content-Type": "application/json", "Authorization": "Bearer <NEED_TO_ACCESS_SENSITIVE_KEY_HERE>"}'::jsonb
    );
    RETURN NEW;
END;
$$ LANGUAGE plpgsql;

CREATE OR REPLACE TRIGGER some_insert BEFORE INSERT OR UPDATE ON public.sometable
    FOR EACH ROW EXECUTE FUNCTION handle_insert();
CREATE OR REPLACE FUNCTION handle_insert() RETURNS TRIGGER AS $$
BEGIN
    PERFORM net.http_post(
            url:='<WOULD BE NICE TO ACCESS SUPABASE_URL HERE>',
            body:=json_build_object('target',NEW.data)::jsonb,
            headers:='{"Content-Type": "application/json", "Authorization": "Bearer <NEED_TO_ACCESS_SENSITIVE_KEY_HERE>"}'::jsonb
    );
    RETURN NEW;
END;
$$ LANGUAGE plpgsql;

CREATE OR REPLACE TRIGGER some_insert BEFORE INSERT OR UPDATE ON public.sometable
    FOR EACH ROW EXECUTE FUNCTION handle_insert();


I'm wondering what the best practice is for accessing these secrets within sql?

I would like to version control these function and trigger definitions but I don't want to expose them unnecessarily.

Thanks in advance!
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Get anon-key in SQL
SupabaseSSupabase / help-and-questions
4y ago
Migrating from anon > publishable key supabase JS
SupabaseSSupabase / help-and-questions
6mo ago
API KEY "ANON_KEY " for REPLIT
SupabaseSSupabase / help-and-questions
2mo ago
Supabase branch API URL/anon key for expo preview build
SupabaseSSupabase / help-and-questions
5mo ago