Add your microservices

Get an API Key

Log in to the MAPT portal and create an API Key within the Microservices section.

Your microservices will need to use this API Key to send their output back to the MAPT platform.


Register

Then register your microservice, adding a Name, URL and API Key.

URL

This is the URL we will call when invoking your microservice.

Make sure to add the https:// prefix.

API Key

This is specific to for each microservice and allows you to protect access to your microservices. It is different to the API Key created above.

MAPT will use this key as the (Bearer) token in the Authorization header when invoking your microservice:

"Authorization": "Bearer ApiKey123"


Input

Every microservice will be sent the following properties as input (when invoked by the MAPT platform):

In comparison to Amazon EventBridge:

data is like detail, event_type is like detail-type and output_type is like source.


Output

Your microservices will be invoked by MAPT (at the correct time) and must then send their output back to MAPT.

We have an endpoint where every registered microservice should send its output (events) to https://router.mapt.events.

The format of this data should be as follows:

You need to send the request with an API Key.

Here is NodeJS code to show an example of how to send the output back to MAPT:

const fetch = require('node-fetch');exports.handler = async event => {        const {data, event_type, output_type, ApiKey} = event;    const raw_response = await fetch("https://router.mapt.events", {        method: "post",        body: JSON.stringify({data, event_type, output_type}),        headers: {            'Authorization': "Bearer " + ApiKey,            'Content-Type': 'application/json'        },    });    const response = await raw_response.json();    console.log(JSON.stringify(response));    if(raw_response.status !== 200) throw Error('Invoke API error');        return;};