Skip to content
Written with Claude

REQUEST_PARAM_TYPE

Also known as

param_type (with or without @ prefix)

Control how parameters are transmitted to the endpoint - via query string or request body.

Syntax

code
@request_param_type <type>
@param_type <type>

type: query_string, query, body, body_json

Values

ValueDescription
query_stringParameters from URL query string
querySame as query_string
body_jsonParameters from JSON request body
bodySame as body_json

Default Behavior

When not specified:

  • GET and DELETE methods use query string
  • All other methods use JSON body

Examples

Force Query String Parameters

sql
sql
create function search_users(_name text, _active bool)
returns setof users
language sql
begin atomic;
select * from users where name ilike '%' || _name || '%' and active = _active;
end;

comment on function search_users(text, bool) is
'HTTP GET
@request_param_type query_string';

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

sql
sql
/*
HTTP GET
@request_param_type query_string
@param $1 name
@param $2 active boolean
*/
select * from users where name ilike '%' || $1 || '%' and active = $2;

Request: GET /api/search-users?_name=john&_active=true

Force JSON Body Parameters

sql
sql
create function get_filtered_data(_filters text)
returns json
language sql
begin atomic;
...;
end;

comment on function get_filtered_data(text) is
'HTTP GET
@request_param_type body_json';

Request:

http
http
GET /api/get-filtered-data
Content-Type: application/json

{"_filters": "status=active"}

Short Form Keywords

sql
sql
-- Using '@param_type' instead of '@request_param_type'
comment on function func1(text) is
'HTTP
@param_type query';

-- Using 'BODY' (case-insensitive)
comment on function func2(text) is
'HTTP
@param_type BODY';

POST with Query String

Override the default body behavior for POST:

sql
sql
create function quick_action(_id int)
returns text
language sql
begin atomic;
...;
end;

comment on function quick_action(int) is
'HTTP POST
@param_type query_string';

Request: POST /api/quick-action?_id=123

Behavior

When parameter type doesn't match the request format, the endpoint returns 404 Not Found:

  • Endpoint configured for query_string but receives JSON body → 404
  • Endpoint configured for body_json but receives query parameters → 404

Comments