Arbitrary HTTP routes


database.route([path,] [headers]): Route

Returns a new Route instance for the given path (relative to the database) that can be used to perform arbitrary HTTP requests.


  • path: string (optional)

    The database-relative URL of the route.

  • headers: Object (optional)

    Default headers that should be sent with each request to the route.

If path is missing, the route will refer to the base URL of the database.

For more information on Route instances see the Route API below.


const db = new Database();
const myFoxxService = db.route('my-foxx-service');
const response = await'users', {
  username: 'admin',
  password: 'hunter2'
// response.body is the result of
// POST /_db/_system/my-foxx-service/users
// with JSON request body '{"username": "admin", "password": "hunter2"}'