Code Examples
Ready-to-use code snippets for common tasks.
Verify API Key
cURL
curl -X GET "https://trigglio.com/api/integrations/webhooks/auth/verify" \
-H "Authorization: Bearer tr_live_your_api_key"List Forms
cURL
curl -X GET "https://trigglio.com/api/integrations/webhooks/actions/forms" \
-H "Authorization: Bearer tr_live_your_api_key"Subscribe to Webhooks
cURL
curl -X POST "https://trigglio.com/api/integrations/webhooks/triggers/subscribe" \
-H "Authorization: Bearer tr_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"hookUrl": "https://your-app.com/webhook",
"formId": "frm_abc123"
}'Handle Incoming Webhook
Example server to receive form submission webhooks.
Node.js (Express)
import express from 'express';
const app = express();
app.use(express.json());
app.post('/webhook', (req, res) => {
const { eventType, eventId, data } = req.body;
// Idempotency check (recommended)
// if (await isEventProcessed(eventId)) {
// return res.status(200).json({ received: true });
// }
if (eventType === 'form_response') {
console.log('New form submission!');
console.log('Form:', data.formName);
console.log('Response ID:', data.responseId);
// Process each field
for (const field of data.fields) {
console.log(`${field.label}: ${field.value}`);
}
// Example: Send to your database
// await db.submissions.create({ data });
}
// Always respond with 200 to acknowledge receipt
res.status(200).json({ received: true });
});
app.listen(3000, () => console.log('Webhook server running on port 3000'));Complete Integration Example
A full example showing how to set up a webhook and handle submissions:
// setup.js - Run once to set up your webhook
const API_KEY = 'tr_live_your_api_key';
async function setupWebhook() {
// 1. List available forms
const formsResponse = await fetch(
'https://trigglio.com/api/integrations/webhooks/actions/forms',
{ headers: { 'Authorization': `Bearer ${API_KEY}` } }
);
const forms = await formsResponse.json();
console.log('Available forms:', forms);
// 2. Subscribe to a specific form (or omit formId for all)
const subscribeResponse = await fetch(
'https://trigglio.com/api/integrations/webhooks/triggers/subscribe',
{
method: 'POST',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
hookUrl: 'https://your-app.com/webhook',
formId: forms[1]?.id // First actual form (index 0 is "All Forms")
})
}
);
const result = await subscribeResponse.json();
console.log('Webhook subscription:', result);
// Save result.hookId to unsubscribe later
}
setupWebhook();Last updated on