Defining URL parameters best practice

When defining url parameters, is it a best practice to use regex as in ‘/^/ident/(\d+)$/’, query parameter as in ‘?=asdfasd’, or use a route parameter as in ‘identity/:id’? I’m using express if that matters.

Use a route parameter, and if you need to constrain it to a particular format before the backend receives it, then append the regex right after the parameter name in parentheses, like identity/:id(\d+) – just like your regex example, but with the parameter name added. Don’t use bare regexes unless you’re matching part of a path not bound to a parameter