External Flex Services

As well as running in the FlexService Runtime, FlexServices can be deployed on any PaaS, local server, or hosting provider.

This guide covers the creation of FlexServices as well as running FlexServices outside of Kinvey.


  1. Git for working with Kinvey repositories
  2. NodeJS v6.x and NPM (node package manager). We recommend installing NodeJS and NPM using NVM.

Creating a FlexService

The Kinvey Flex SDK emits events within your node service when Collection data is requested from your Kinvey app. These events are paired with user-defined handlers that fetch and transform data (from any number of sources) into Kinvey collections. The Flex SDK also includes modules for interacting with other Kinvey APIs (such as push notifications, email, collections access, and more).

Use the Flex SDK to write your FlexService. For more information on how to use it and API documentation, see the FlexServices Guide.

When initializing the SDK for external use, you can specify a host and port to listen on by passing an options object with an optional host and port. If no host/port is specified, localhost:10001 will be used:

sdk.service({ host: 'somehost', port: 7777 }, (err, flex) => {
  // code goes here

Provisioning Your External FlexService

Before you can deploy your Node.js service and connect it to Kinvey, you must provision an External Flex Service in the Kinvey Console.

  1. Log in to the Kinvey Console and select an environment.
  2. Select the Service Catalog tab.
  3. Click Add a service.
  4. Click Flex and select the External service type.
  5. Complete the required fields marked with an asterisk such as Name, Secret, and Host.
  6. Click Save.
  7. The newly-created External Flex Service appears in your Service Catalog.

Running Your External FlexService

To run your FlexService, execute node . in the root of your project. Routes are:

For FlexData:

GET     /:serviceObject/                // Get all entities in a Service Object
GET     /:serviceObject/:id             // Get a single entity by id
GET     /:serviceObject/?{query}        // Get entities by query
POST    /:serviceObject/                // Create an entity
PUT     /:serviceObject/:id             // Update a service object entity
DELETE  /:serviceObject/                // Delete all service objects
DELETE  /:serviceObject/:id             // Delete a single entity by id
DELETE  /:serviceObject/?{query}        // Delete a service object by query
GET     /:serviceObject/_count          // Get a count of all records in the service object
GET     /:serviceObject/_count/?{query} // Get the count of a query result

For FlexFunctions:

POST    /_flexFunctions/:handlerName    // Execute the handler function
Got a question?