From d75b1a7e964252c4b4e750dd826c1f0cb399b4f7 Mon Sep 17 00:00:00 2001 From: Taimoor Zaeem Date: Mon, 26 Jan 2026 12:53:27 +0500 Subject: [PATCH] docs: using default parameters on RPC with GET request Signed-off-by: Taimoor Zaeem --- docs/references/api/functions.rst | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/docs/references/api/functions.rst b/docs/references/api/functions.rst index 216a1a213..9502df9b3 100644 --- a/docs/references/api/functions.rst +++ b/docs/references/api/functions.rst @@ -69,6 +69,26 @@ If the function doesn't modify the database, it will also run under the GET meth The function parameter names match the JSON object keys in the POST case, for the GET case they match the query parameters ``?a=1&b=2``. +If the function is defined to have default values for the parameters then arguments for these parameters can be omitted in the request. For instance: + +.. code-block:: postgres + + CREATE FUNCTION greet_user(username TEXT DEFAULT 'guest') + RETURNS TEXT AS $$ + SELECT 'Hello ' || username || '!'; + $$ LANGUAGE SQL IMMUTABLE; + +.. code-block:: bash + + curl -i "http://localhost:3000/rpc/greet_user" + +.. code-block:: http + + HTTP/1.1 200 OK + Context-Type: application/json; charset=utf-8 + + "Hello guest!" + .. _function_single_json: Functions with an array of JSON objects