Services Config


SOAJS provides the ability to store data per tenant. What this means is that each tenant has a config object, and this object is only accessed by the users of that specific tenant.

This space will show you:


Please make sure you have installed the SOAJS Dashboard before continuing!

Enable services config

Since the services config is tied to the tenant, our service must be multitenant, so we have to set extKeyRequired to true. Let's setup a simple microservice to demonstrate this.


Remember that a service is composed, at least, of a config.js and index.js file. Click here to remember how to build a service.

'use strict';

module.exports = {
   "serviceVersion": 1,
   "serviceName": "servicesConfig",
   "serviceGroup": "SOAJS Services Config Example",
   "servicePort": 4130,
   "requestTimeout": 30,
   "requestTimeoutRenewal": 5,
   "extKeyRequired": true,
   "errors": {},
   "schema": {
      "/get": {
         "_apiInfo": {
            "l": "get name"
'use strict';
var soajs = require('soajs');
var config = require('./config.js');

var service = new soajs.server.service(config);

service.init(function() {
   service.get("/get", function(req, res) {
      var name =;
      res.json(req.soajs.buildResponse(null, "Hello " + name));

Configure services config from Dashboard

We need to create at least two tenants to see how the response will differ based on which key we provide the request.

Check out the Multitenancy page to learn how to create a tenant and configure its services config.


Now that everything is set up, let's test our service though an example.

Deploy Service
# Go to the directory where you created your config.js and index.js files
cd /opt/soajs/node_modules/servicesConfig.example

# Export necessary environment variable
export SOAJS_ENV=dev 
# Run the service
node .

The service is now running and listening for requests. 

Using a terminal window, Postman, Insomnia, etc... we can test our service.


Make sure that the keys in the header of your requests are the keys that you created and not the one form the screenshot!

We see that depending on which key we use in the header, the response returns the name specified in the service config of each tenant!