Skip to content

Custom Parameters

Set custom key-value configuration for the endpoint.

Syntax

<key> = <value>

Dynamic Parameter Values

Some parameters support dynamic values using the {param_name} format, where param_name references a function parameter. The value is resolved at runtime from the actual parameter value passed to the endpoint.

Example

sql
create function upload_file(_path text, _file text)
returns void
language sql as $$
  -- function body
$$;

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

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

Built-in Parameters

The following parameters are recognized by NpgsqlRest and its handlers.

General Parameters

ParameterDescription
buffer_rows, bufferSets the buffered amount of rows before they are written to the response.
columns, names, column_namesIf true and endpoint is in raw mode, response will contain header names.
connection, connection_nameDefines an alternative connection name that must exist in the ConnectionStrings dictionary.
new_line, raw_new_lineDefines the separator between raw value rows when raw mode is enabled.
raw, raw_mode, raw_resultsSets response to raw mode where HTTP response is written exactly as received from PostgreSQL.
separator, raw_separatorDefines the separator between raw value columns when raw mode is enabled.

Upload Handler Parameters

Shared Parameters

ParameterDescription
stop_after_first_successWhen true, stops processing after the first successful upload handler.
included_mime_typesComma-separated list of MIME type patterns to include for upload processing.
excluded_mime_typesComma-separated list of MIME type patterns to exclude from upload processing.

Large Object Upload Handler

ParameterDescription
buffer_size, large_object_buffer_sizeSize of the buffer used for reading/writing large object data.
check_text, large_object_check_textWhen true, checks if the uploaded content is text format.
check_image, large_object_check_imageWhen true, checks if the uploaded content is an image format.
test_buffer_size, large_object_test_buffer_sizeSize of the buffer used for testing file content type.
non_printable_threshold, large_object_non_printable_thresholdThreshold for determining if content contains non-printable characters.
oid, large_object_oidPostgreSQL large object OID to use for storage.
large_object_included_mime_typesMIME type patterns to include for large object upload processing.
large_object_excluded_mime_typesMIME type patterns to exclude from large object upload processing.

File System Upload Handler

ParameterDescription
buffer_size, file_system_buffer_sizeSize of the buffer used for reading/writing file system data.
check_text, file_system_check_textWhen true, checks if the uploaded content is text format.
check_image, file_system_check_imageWhen true, checks if the uploaded content is an image format.
test_buffer_size, file_system_test_buffer_sizeSize of the buffer used for testing file content type.
non_printable_threshold, file_system_non_printable_thresholdThreshold for determining if content contains non-printable characters.
path, file_system_pathFile system path where uploaded files will be stored.
file, file_system_fileSpecific file name to use for the uploaded content.
unique_name, file_system_unique_nameWhen true, generates unique file names to avoid conflicts.
create_path, file_system_create_pathWhen true, creates the directory path if it doesn't exist.
file_system_included_mime_typesMIME type patterns to include for file system upload processing.
file_system_excluded_mime_typesMIME type patterns to exclude from file system upload processing.

CSV Upload Handler

ParameterDescription
test_buffer_size, csv_test_buffer_sizeSize of the buffer used for testing CSV content type.
non_printable_threshold, csv_non_printable_thresholdThreshold for determining if content contains non-printable characters.
check_format, csv_check_formatWhen true, validates the CSV format before processing.
delimiters, csv_delimitersCharacters used as field delimiters in CSV files (e.g., comma, semicolon).
has_fields_enclosed_in_quotes, csv_has_fields_enclosed_in_quotesWhen true, expects CSV fields to be enclosed in quotes.
set_white_space_to_null, csv_set_white_space_to_nullWhen true, converts whitespace-only fields to NULL values.
row_command, csv_row_commandSQL command to execute for each CSV row during processing.
csv_included_mime_typesMIME type patterns to include for CSV upload processing.
csv_excluded_mime_typesMIME type patterns to exclude from CSV upload processing.

Excel Upload Handler

ParameterDescription
sheet_name, excel_sheet_nameName of the specific Excel worksheet to process.
all_sheets, excel_all_sheetsWhen true, processes all worksheets in the Excel file.
time_format, excel_time_formatFormat string for parsing time values from Excel cells.
date_format, excel_date_formatFormat string for parsing date values from Excel cells.
datetime_format, excel_datetime_formatFormat string for parsing datetime values from Excel cells.
row_is_json, excel_row_is_jsonWhen true, treats each Excel row as JSON data.
row_command, excel_row_commandSQL command to execute for each Excel row during processing.
excel_included_mime_typesMIME type patterns to include for Excel upload processing.
excel_excluded_mime_typesMIME type patterns to exclude from Excel upload processing.

SSE (Server-Sent Events) Parameters

SSE Events Path

Additional path appended as a subpath to the main endpoint path for SSE events streaming. If the endpoint path is /path and this value is set to /info, the streaming path will be /path/info. Set to true to use the notice level name as the path.

ParameterValues
sse, sse_path, sse_events_path<path>, true, false

SSE Events Level

Sets the PostgreSQL notice level for SSE events. Determines which PostgreSQL notice messages will be streamed to the client.

ParameterValues
sse_level, sse_events_levelinfo, notice, warning

SSE Events Scope

Scope that determines to whom events are streamed:

ParameterValues
sse_scope, sse_events_scopematching, authorize, all, authorize role1, role2, ...
ScopeDescription
matchingSessions with matching security context of the endpoint initiator.
authorizeOnly authorized sessions receive messages. Optionally specify roles.
allAll sessions regardless of security context receive messages.

TypeScript Client Parameters

ParameterDescription
tsclientSet to false, off, disabled, disable, or 0 to disable TypeScript client code generation for the endpoint.
tsclient_eventsEnable or disable SSE events parameter for endpoints with SSE events enabled.
tsclient_parse_urlEnable or disable URL parsing in generated client.
tsclient_parse_requestEnable or disable request parsing in generated client.
tsclient_status_codeEnable or disable status code in the return value.
tsclient_moduleSets different module name for the generated TypeScript client file.

Released under the MIT License.