Create Webhook
Creating a webhook allows you to receive immediate updates and alerts regarding changes in the status of important entities or events.
Endpoint: https://api.amlwatcher.com/api/webhook
Method: POST
- HTTP
- Javascript
- PHP
- Python
- Ruby
- Java
- cURL
- C#
- Go
Sample Request
POST /api/webhook HTTP/1.1
Host: api.amlwatcher.com
Authorization: Bearer Token
Content-Type: application/json
Content-Length: 144
{
"name":"Nodejs server",
"endpoint":"your-webhook-url",
"type":"monitored_status_updated"
}
Sample Request
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", "Bearer Token");
var raw = JSON.stringify({
name: "Test Webhook",
endpoint: "https://webhook.site/26184bd6-6d7c-429a-9131-fe009ee74e",
type: "monitored_status_updated",
});
var requestOptions = {
method: "POST",
headers: myHeaders,
body: raw,
redirect: "follow",
};
fetch("https://api.amlwatcher.com/api/webhook", requestOptions)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.log("error", error));
Sample Request
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.amlwatcher.com/api/webhook',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"name":"Test Webhook",
"endpoint":"https://webhook.site/26184bd6-6d7c-429a-9131-fe009ee74e",
"type":"monitored_status_updated"
}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'Authorization: Bearer Token'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
Sample Request
import requests
import json
url = "https://api.amlwatcher.com/api/webhook"
payload = json.dumps({
"name": "Test Webhook",
"endpoint": "https://webhook.site/26184bd6-6d7c-429a-9131-fe009ee74e",
"type": "monitored_status_updated"
})
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer Token'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
Sample Request
require "uri"
require "json"
require "net/http"
url = URI("https://api.amlwatcher.com/api/webhook")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer Token"
request.body = JSON.dump({
"name": "Test Webhook",
"endpoint": "https://webhook.site/26184bd6-6d7c-429a-9131-fe009ee74e",
"type": "monitored_status_updated"
})
response = https.request(request)
puts response.read_body
Sample Request
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
public class Main {
public static void main(String[] args) {
try {
// URL to the API endpoint
URL url = new URL("https://api.amlwatcher.com/api/webhook");
// Establishing the connection
HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
// Setting the request method to POST
httpURLConnection.setRequestMethod("POST");
// Setting the headers
httpURLConnection.setRequestProperty("Authorization", "Bearer Token");
httpURLConnection.setRequestProperty("Content-Type", "application/json");
// Enabling input and output streams
httpURLConnection.setDoOutput(true);
// JSON payload
String jsonInputString = "{\n \"name\":\"Nodejs server app01\",\n \"endpoint\":\"https://14a3-182-176-132-200.ngrok-free.app/api/test4\",\n \"type\":\"search_status_updated\"\n}";
// Writing the JSON payload to the output stream
try (OutputStream os = httpURLConnection.getOutputStream()) {
byte[] input = jsonInputString.getBytes("utf-8");
os.write(input, 0, input.length);
}
// Getting the response code
int responseCode = httpURLConnection.getResponseCode();
System.out.println("Response Code: " + responseCode);
// Reading the response or error message
BufferedReader br;
if (responseCode >= 200 && responseCode < 300) {
br = new BufferedReader(new InputStreamReader(httpURLConnection.getInputStream(), "utf-8"));
} else {
br = new BufferedReader(new InputStreamReader(httpURLConnection.getErrorStream(), "utf-8"));
}
// Print the response
StringBuilder response = new StringBuilder();
String responseLine;
while ((responseLine = br.readLine()) != null) {
response.append(responseLine.trim());
}
System.out.println("Response Message: " + response.toString());
// Closing the connection
httpURLConnection.disconnect();
} catch (Exception e) {
e.printStackTrace();
}
}
}
Sample Request
curl --location --request POST 'https://api.amlwatcher.com/api/webhook'
--header 'Content-Type: application/json'
--header 'Authorization: Bearer Token'
--data '{
"name":"Test Webhook",
"endpoint":"https://webhook.site/26184bd6-6d7c-429a-9131-fe009ee74e",
"type":"monitored_status_updated"
}'
Sample Request
using RestSharp; // Import RestSharp namespace
using System;
using System.Threading.Tasks;
class Program
{
static async Task Main(string[] args)
{
var url = "https://api.amlwatcher.com/api/webhook";
var options = new RestClientOptions(url)
{
ThrowOnAnyError = true,
Timeout = TimeSpan.FromMilliseconds(-1)
};
var client = new RestClient(options);
var request = new RestRequest(url, Method.Post);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Authorization", "Bearer Token");
var payload = new
{
name = "Test Webhook",
endpoint = "https://webhook.site/26184bd6-6d7c-429a-9131-fe009ee74e",
type = "monitored_status_updated"
};
request.AddJsonBody(payload);
RestResponse response = await client.ExecuteAsync(request);
Console.WriteLine(response.Content);
}
}
Sample Request
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.amlwatcher.com/api/webhook"
method := "POST"
payload := strings.NewReader(`{
"name":"Test Webhook",
"endpoint":"https://webhook.site/26184bd6-6d7c-429a-9131-fe009ee74e",
"type":"monitored_status_updated"
}`)
client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Authorization", "Bearer Token")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
Request
Parameters | Required | Type | Description |
---|---|---|---|
name | Yes | String | Represent your webhook name, making it easy to identify its purpose and function. |
endpoint | Yes | String | Specify the URL where you want to receive webhook notifications. This is where AML Watcher will send POST requests with event data. Example: https://webhook.site/26184bd6-6d7c-429a-9131-fe009ee74e |
type | Yes | String | Define the type of webhook, which may include event-specific types. Default type: monitored_status_updated Accepted Values: monitored_status_updated, status_change |
Response
Parameters | Description |
---|---|
error | Whenever there is an error in your request, this param will have details of that error; otherwise it’ll remain empty. |
status | The status field is set to either “SUCCESS” or “FAIL”, indicating that the API request resulted in a successful or failure/error condition respectively. |
data | An array/object containing the actual response elements. |
Sample Response
{
"data": {
"_id": {
"$oid": "653f715f2cd970a571dcd"
},
"created_at": {
"$date": 16986602294
},
"endpoint": "https://webhook.site/26184bd6-6d7c-429a-9131-fe009ee74e",
"name": "Test Webhook",
"organization_id": {
"$oid": "6512d7134bb9cd92fe394"
},
"type": "monitored_status_updated",
"updated_at": {
"$date": 169866094
},
"user_id": {
"$oid": "6512d715dadd1b87911a6"
}
},
"error": false,
"status": "SUCCESS"
}