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.
Then register your microservice, adding a Name, URL and API Key.
This is the URL we will call when invoking your microservice.
Make sure to add the https://
prefix.
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"
Every microservice will be sent the following properties as input (when invoked by the MAPT platform):
data
: an Object containing the event data.event_type
: a String defining the 'event_type' of the event.output_type
: a String defining the 'output_type' from the most recent microservice.In comparison to Amazon EventBridge:
data
is like detail
, event_type
is like detail-type
and output_type
is like source
.
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:
data
: an Object containing the event data plus anything new appended.event_type
: this is the same as the received 'event_type'. output_type
: a String defining the 'output_type' from this microservice invocation.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;};