Integration Tutorial Sample For An API Company
Integrating SentinelAPI with a Web Application
A Step-by-Step Tutorial Sample
Overview
This tutorial demonstrates how to integrate SentinelAPI into a simple web application–that'll be used to track events and trigger automated workflows.
You will:
1.Send events from your app
2.View them via the API
3.Trigger an automation workflow
Step 1: Get Your API Key
Sign into the SentinelAPI dashboard and copy your API key.
Store it securely as an environment variable:
SENTINEL_API_KEY=your_key_here
Step 2: Install Dependencies
Using Node.js:
npm install axios
Step 3: Send Events from Your App
Example JavaScript:
const axios = require("axios");
async function sendEvent() {
const response = await axios.post(
"https://api.sentinelapi.com/v1/events",
{
source: "web-app",
type: "error",
message: "Login failure",
timestamp: new Date().toISOString()
},
{
headers: {
Authorization: `Bearer ${process.env.SENTINEL_API_KEY}`
}
}
);
console.log(response.data);
}
sendEvent();
Step 4: Trigger a Workflow
When a critical event is detected, trigger automation.
async function triggerWorkflow(eventId) {
await axios.post(
"https://api.sentinelapi.com/v1/workflows/trigger",
{
workflow_id: "wf_102",
event_id: eventId
},
{
headers: {
Authorization: `Bearer ${process.env.SENTINEL_API_KEY}`
}
}
);
}
Step 5: Verify the Integration
Use the List Events endpoint to confirm if your events has being received.
GET https://api.sentinelapi.com/v1/events
Best Practices
• Validate data before sending
• Implement retries
• Log errors
• Monitor rate limits
Conclusion
You have now integrated SentinelAPI into your application and enabled real-time event tracking and automation.
Comments
Post a Comment