View our GitHub

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

Edit Page


req.options allows altering of (or providing defaults for) request parameters without modifying the original object.

Any properties provided in a custom route configuration are made available in the req.options object. For example, given the following in config/routes.js:

"GET /foo": {controller: 'user', action: 'myAction', owl: 'hoot'}

req.options.controller, req.options.action and req.options.owl will all be available.

Additionally, several special req.options objects are available for use with blueprints, specifically to programatically change the criteria and/or values that a blueprint action uses when accessing a data store. These are best used in policies to, for example, filter requested records based on the logged-in user.


In a config/policies/filterByUser.js policy:

module.exports = function filterByUser (req, res, next) {

  if (req.session.user) {

    req.options.where = req.options.where || {};
    req.options.where.userId =;


  return next();


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