Skip to content

Custom Parameters

Set custom key-value configuration for the endpoint.

Syntax

code
@<key> = <value>

The @ prefix is optional - both @key = value and key = value work identically. Custom parameters with @ prefix are stored without the prefix (e.g., @my_param = value is stored as my_param).

Dynamic Parameter Values

Some parameters support dynamic values using the {param_name} format, where param_name references a function parameter or an allowlisted environment variable (NpgsqlRest:AvailableEnvVars). Parameter values are resolved at runtime from the actual value passed to the endpoint; environment variables are resolved once at startup, and a parameter with the same name takes precedence. Since 3.21.0 the strict forms work here too: {!name} resolves like {name} for known names, and {!name:fallback} substitutes the inline fallback when an allowlisted variable is unset (with no configured default) or when a parameter value is null — e.g. @file_system_path = {!UPLOAD_ROOT:/var/uploads}. The matching and substitution rules are shared across annotations — see Parameter Value Substitution.

Example

sql
sql
create function upload_file(_path text, _file text)
returns void
language sql
begin atomic;
  -- function body
end;

comment on function upload_file(text, text) is '
@upload for file_system
@file_system_path = {_path}
@file_system_file = {_file}
';

Equivalent as a SQL file endpoint (sql/upload-file.sql):

sql
sql
/*
HTTP POST
@upload for file_system
@file_system_path = {path}
@file_system_file = {file}
@param $1 path
@param $2 file
*/
select;

When called with {"_path": "/uploads/images", "_file": "photo.jpg"}, the file will be saved to /uploads/images/photo.jpg.

Built-in Parameters

Many annotations support the @key = value syntax. The following sections link to where each parameter group is documented.

General

These parameters are predefined annotations that also support the key = value syntax:

Upload

Upload handlers accept custom parameters to control file processing behavior per-endpoint:

Table Format

Per-endpoint control of HTML table and Excel spreadsheet rendering:

Server-Sent Events

SSE annotations that also support the key = value syntax:

TypeScript Client

Per-endpoint control of generated TypeScript client code:

Comments