Seamless Introduction
This page provides a guide on how to use and configure webhooks.
Prerequisites
Section titled “Prerequisites”- Endpoint URL
- API Key
Request Information
Section titled “Request Information”- Method:
POST - Content-Type:
text/plain
Encryption Specification
Section titled “Encryption Specification”- Algorithm:
Advanced Encryption Standard (AES) - Key Size:
256 bits - Mode of Operation:
Electronic Codebook (ECB) - Padding Scheme:
PKCS#7 (also known as PKCS5)
Usage ExpressJS
Section titled “Usage ExpressJS”const express = require('express')const app = express()const { encrypt, decrypt } = require('./utils');
const PORT = 3000const API_KEY = ''
app.use(express.text({ type: 'text/plain' }))
app.post('/endpoint_url', (req, res) => { const plainText = req.body const decryptedData = decrypt(plainText, API_KEY) // Process the webhook here... // Encrypt the raw data... const encryptedData = encrypt(rawResponse, API_KEY) // The response status must be HTTP 200 OK return res.status(200).json(encryptedData)})
app.listen(PORT, () => { console.log(`Server running on http://localhost:${PORT}`)})const crypto = require('crypto')
function encrypt(plainText, encryptionKey) { try { const cipher = crypto.createCipheriv( 'aes-256-ecb', Buffer.from(encryptionKey), null ) cipher.setAutoPadding(true) let encryptedData = cipher.update(plainText, 'utf8', 'base64') encryptedData += cipher.final('base64') return encryptedData } catch (error) { return null }}
function decrypt(encryptedData, encryptionKey) { try { const decipher = crypto.createDecipheriv( 'aes-256-ecb', Buffer.from(encryptionKey), null ) decipher.setAutoPadding(true) let decryptedData = decipher.update(encryptedData, 'base64', 'utf8') decryptedData += decipher.final('utf8') return decryptedData } catch (error) { return null }}
module.exports = { encrypt, decrypt }Events
Section titled “Events”Different types of events will be sent to your endpoint when triggered. Refer to the next page for details on each event type.