ALLOW_ANONYMOUS
Allow unauthenticated access to the endpoint, overriding the global RequiresAuthorization setting.
Keywords
allow_anonymous, anonymous, allow_anon, anon
Syntax
allow_anonymousExamples
Public Endpoint
sql
create function get_public_info()
returns json
language sql
as $$select '{"version": "1.0"}'::json$$;
comment on function get_public_info() is
'HTTP GET
allow_anonymous';Short Form
sql
comment on function health_check() is
'HTTP GET
anon';Public Read, Protected Write Pattern
sql
-- Anyone can read
comment on function get_products() is
'HTTP GET
allow_anonymous';
-- Only authenticated users can create
comment on function create_product(text, numeric) is
'HTTP POST
authorize';Behavior
- Overrides the global
RequiresAuthorization: truesetting - Allows requests without authentication tokens
- Useful for public APIs, health checks, and login endpoints
Related
- Authentication configuration - Configure authentication providers
- NpgsqlRest Options configuration - Configure RequiresAuthorization setting
- Comment Annotations Guide - How annotations work
- Configuration Guide - How configuration works