View our GitHub

Please visit sails-docs on GitHub to view documentation on your mobile device.

Edit Page


Returns the value of the parameter with the specified name.


req.param(name[, defaultValue]);


req.param() searches the url path, query string, and body of the request for the specified parameter. If no parameter value exists anywhere in the request with the given name, it returns undefined, or the optional defaultValue if specified.

  • url path parameters (req.params)
    • e.g. a request "/foo/4" to route /foo/:id has url path params { id: 4 }
  • query string parameters (req.query)
    • e.g. a request "/foo?email=5" has query params { email: 5 }
  • body parameters (req.body)
    • e.g. a request with a parseable body (e.g. JSON, url-encoded, or XML) has body parameters equal to its parsed value


Consider a route (POST /product/:sku) which points to a blueprint, controller, or policy with the following code:

// -> 123

We can get the expected result by sending the sku parameter any of the following ways:

  • POST /product/123
  • POST /product?sku=123
  • POST /product
    • with a JSON request body: { "sku": 123 }


  • If you'd like to get ALL parameters from ALL sources (including the URL path, query string, and parsed request body) you can use req.allParams().

Is something missing?

If you notice something we've missed or could be improved on, please follow this link and submit a pull request to the sails-docs repo. Once we merge it, the changes will be reflected on the website the next time it is deployed.


We wrote a book!

Get early access to the book
with promotion code: mcneildoc

Get the Book