Annotations Reference
Complete reference for all NpgsqlRest comment annotations. For an introduction to how annotations work, see the Comment Annotations Guide.
INFO
All annotations work in both PostgreSQL function/procedure comments (COMMENT ON FUNCTION ...) and SQL file endpoints (-- and /* */ comments in .sql files). The "SQL File Annotations" section below lists annotations that are specific to SQL files.
Looking for a specific keyword?
Annotations often have aliases (@timeout → COMMAND_TIMEOUT, @retry → RETRY_STRATEGY, @anon → ALLOW_ANONYMOUS). See the A–Z Index for every name and alias.
How to Use This Reference
Each annotation has its own page with:
- Recognized keywords
- Syntax explanation
- Working examples from the test suite
- Related annotations
Annotation Categories
HTTP & Routing
- HTTP - Expose function as HTTP endpoint
- PATH - Set custom endpoint path
- PROXY - Mark endpoint as reverse proxy
- PROXY_OUT - Execute function first, then forward result to upstream
- ENABLED - Re-enable an endpoint after
@disabled, optionally only for specific tags - DISABLED - Disable endpoint, optionally only for specific tags
- TAGS - Filter annotations by tags
- OPENAPI - Hide from the OpenAPI document or override the section tag
- MCP - Expose a routine as a Model Context Protocol (MCP) tool for AI agents
- HTTP CUSTOM TYPES - Define HTTP request on composite type for external API calls
- INTERNAL - Mark endpoint as internal-only (accessible via proxy/HTTP client types, not public HTTP)
Authorization
- AUTHORIZE - Require authentication
- ALLOW_ANONYMOUS - Allow unauthenticated access
- LOGIN - Mark as sign-in endpoint
- LOGOUT - Mark as sign-out endpoint
Basic Authentication
- BASIC_AUTH - Enable HTTP Basic Authentication
- BASIC_AUTH_REALM - Set authentication realm
- BASIC_AUTH_COMMAND - Set validation function
Request Configuration
- REQUEST_PARAM_TYPE - Query string vs body parameters
- REQUEST_HEADERS_MODE - Control header passing
- REQUEST_HEADERS_PARAMETER_NAME - Header parameter name
- BODY_PARAMETER_NAME - Body parameter name
- QUERY_STRING_NULL_HANDLING - NULL handling in query strings
- VALIDATE - Parameter validation before database execution
Response Configuration
- Response Headers - Set custom response headers
- RESPONSE_NULL_HANDLING - NULL handling in responses
- NESTED - Serialize composite type columns as nested JSON objects
- SINGLE - Return a single record as a JSON object instead of an array
- VOID - Force endpoint to return 204 No Content
Table Format Output
- TABLE_FORMAT -
table_format,excel_file_name,excel_sheetfor HTML table and Excel rendering
Client Code Generation
- TSCLIENT - Control TypeScript client generation per endpoint (disable, module names, URL exports, TanStack Query hooks opt-out)
- DARTCLIENT - Control Dart (Flutter) client generation per endpoint (disable, module names, URL exports, response options)
Raw Output Mode
- RAW - Return raw text instead of JSON
- SEPARATOR - Column separator for raw output
- NEW_LINE - Row separator for raw output
- COLUMN_NAMES - Include column headers
Caching
- CACHED - Enable response caching
- CACHE_EXPIRES_IN - Set cache expiration
- CACHE_PROFILE - Select a named cache profile (multiple backends, dynamic TTL, skip-on-condition rules)
Performance
- BUFFER_ROWS - Row buffering count
- COMMAND_TIMEOUT - Query timeout
- RETRY_STRATEGY - Retry behavior
Format References
- Interval Format - Time/duration format for timeouts and cache expiration
Server-Sent Events
- SSE - Enable Server-Sent Events
- SSE_EVENTS_LEVEL - Notice level for SSE
- SSE_EVENTS_SCOPE - SSE distribution scope
Upload
- UPLOAD - File upload handling
Policies
- ERROR_CODE_POLICY - Error handling policy
- RATE_LIMITER_POLICY - Rate limiting policy
Context & Security
- USER_CONTEXT - Enable user context
- USER_PARAMETERS - Add user parameters
- CONNECTION - Named database connection
- SECURITY_SENSITIVE - Obfuscate logs
Parameter Annotations
- PARAM - Rename, retype, set defaults, and configure parameters
- PARAMETER_HASH - Hash one parameter using another
- ENCRYPT - Encrypt parameter values before sending to PostgreSQL
- DECRYPT - Decrypt result column values before returning to client
- Parameter Value Substitution -
{name}placeholders in annotation values - Resolved Parameters - Compute a parameter value server-side from a SQL expression
SQL File Annotations
- DEFINE_PARAM - Define virtual HTTP parameters not bound to SQL
- RESULT_NAME - Rename result keys in multi-command SQL file endpoints
- SKIP - Exclude commands from multi-command results
- RETURNS - Skip Describe step and resolve return columns from a composite type (for runtime-created temp tables)
Test File Annotations
These apply only to test files run by the SQL test runner (npgsqlrest --test) — not to endpoint SQL files or routine comments:
- TEST @setup - Run named steps before an individual test file
- TEST @teardown - Run named steps after an individual test file, always
- TEST @connection - Run a test file on a different named connection
- TEST @tag - Tag a test file for Tag/ExcludeTag filtering
- TEST @claim - Set the acting principal for an in-process endpoint call (HTTP block directive)
- TEST @response - Name the captured response temp table (HTTP block directive)
Custom
- Custom Parameters - Custom key-value settings
A–Z Index (Names and Aliases)
Most annotations accept one or more aliases, so the keyword you remember may not be the page name (for example, @timeout is documented under COMMAND_TIMEOUT). All keywords work with or without the @ prefix. Use your browser's find (Ctrl+F / ⌘F) on this table to look up any keyword.
| Annotation | Also accepted | What it does |
|---|---|---|
| ALLOW_ANONYMOUS | anonymous, allow_anon, anon | Allow unauthenticated access |
| AUTHORIZE | authorized, requires_authorization | Require authentication |
| BASIC_AUTH | basic_authentication | Enable HTTP Basic Authentication |
| BASIC_AUTH_COMMAND | basic_authentication_command, challenge_command | Set validation function |
| BASIC_AUTH_REALM | basic_authentication_realm, realm | Set authentication realm |
| BODY_PARAMETER_NAME | body_param_name | Body parameter name |
| BUFFER_ROWS | buffer | Row buffering count |
| CACHE_EXPIRES_IN | cache_expires | Set cache expiration |
| CACHE_PROFILE | — | Select a named cache profile (multiple backends, dynamic TTL, skip-on-condition rules) |
| CACHED | — | Enable response caching |
| COLUMN_NAMES | columns, names | Include column headers |
| COMMAND_TIMEOUT | timeout | Query timeout |
| CONNECTION | connection_name | Named database connection |
| Custom Parameters | — | Custom key-value settings |
| DARTCLIENT | — | Control Dart (Flutter) client generation per endpoint (disable, module names, URL exports, response options) |
| DECRYPT | decrypted, unprotect, unprotected | Decrypt result column values before returning to client |
| DEFINE_PARAM | — | Define virtual HTTP parameters not bound to SQL |
| DISABLED | — | Disable endpoint, optionally only for specific tags |
| ENABLED | — | Re-enable an endpoint after @disabled, optionally only for specific tags |
| ENCRYPT | encrypted, protect, protected | Encrypt parameter values before sending to PostgreSQL |
| ERROR_CODE_POLICY | error_code_policy_name, error_code | Error handling policy |
| HTTP | — | Expose function as HTTP endpoint |
| HTTP CUSTOM TYPES | — | Define HTTP request on composite type for external API calls |
| INTERNAL | internal_only | Mark endpoint as internal-only (accessible via proxy/HTTP client types, not public HTTP) |
| Interval Format | — | Time/duration format for timeouts and cache expiration |
| LOGIN | signin | Mark as sign-in endpoint |
| LOGOUT | signout | Mark as sign-out endpoint |
| MCP | — | Expose a routine as a Model Context Protocol (MCP) tool for AI agents |
| NESTED | nested_json, nested_composite | Serialize composite type columns as nested JSON objects |
| NEW_LINE | raw_new_line | Row separator for raw output |
| OPENAPI | — | Hide from the OpenAPI document or override the section tag |
| PARAM | parameter | Rename, retype, set defaults, and configure parameters |
| Parameter Value Substitution | — | {name} placeholders in annotation values |
| PARAMETER_HASH | param … is hash of … form of PARAM | Hash one parameter using another |
| PATH | — | Set custom endpoint path |
| PROXY | reverse_proxy | Mark endpoint as reverse proxy |
| PROXY_OUT | forward_proxy | Execute function first, then forward result to upstream |
| QUERY_STRING_NULL_HANDLING | query_null_handling, query_string_null, query_null | NULL handling in query strings |
| RATE_LIMITER_POLICY | rate_limiter_policy_name, rate_limiter | Rate limiting policy |
| RAW | raw_mode, raw_results | Return raw text instead of JSON |
| REQUEST_HEADERS_MODE | request_headers | Control header passing |
| REQUEST_HEADERS_PARAMETER_NAME | request_headers_param_name, request-headers-param-name | Header parameter name |
| REQUEST_PARAM_TYPE | param_type | Query string vs body parameters |
| Resolved Parameters | — | Compute a parameter value server-side from a SQL expression |
| Response Headers | — | Set custom response headers |
| RESPONSE_NULL_HANDLING | response_null | NULL handling in responses |
| RESULT_NAME | result | Rename result keys in multi-command SQL file endpoints |
| RETRY_STRATEGY | retry_strategy_name, retry | Retry behavior |
| RETURNS | — | Skip Describe step and resolve return columns from a composite type (for runtime-created temp tables) |
| SECURITY_SENSITIVE | sensitive, security | Obfuscate logs |
| SEPARATOR | raw_separator | Column separator for raw output |
| SINGLE | single_record, single_result | Return a single record as a JSON object instead of an array |
| SKIP | skip_result, no_result | Exclude commands from multi-command results |
| SSE | sse_events_path, sse_path | Enable Server-Sent Events |
| SSE_EVENTS_LEVEL | sse_level | Notice level for SSE |
| SSE_EVENTS_SCOPE | sse_scope | SSE distribution scope |
| TABLE_FORMAT | — | table_format, excel_file_name, excel_sheet for HTML table and Excel rendering |
| TAGS | for, tag | Filter annotations by tags |
| TEST @claim | — | Set the acting principal for an in-process endpoint call (HTTP block directive) |
| TEST @connection | — | Run a test file on a different named connection |
| TEST @response | — | Name the captured response temp table (HTTP block directive) |
| TEST @setup | — | Run named steps before an individual test file |
| TEST @tag | — | Tag a test file for Tag/ExcludeTag filtering |
| TEST @teardown | — | Run named steps after an individual test file, always |
| TSCLIENT | — | Control TypeScript client generation per endpoint (disable, module names, URL exports, TanStack Query hooks opt-out) |
| UPLOAD | — | File upload handling |
| USER_CONTEXT | — | Enable user context |
| USER_PARAMETERS | user_params | Add user parameters |
| VALIDATE | — | Parameter validation before database execution |
| VOID | void_result | Force endpoint to return 204 No Content |