Generate API Key
To obtain your API key, simply utilize our dedicated endpoint designed explicitly for this purpose. When sending a request to this endpoint, you have the flexibility to define the lifespan of your API key according to your needs. Specify the desired duration for validity by setting a value for "expires_at". Alternatively, if you require an API key with an indefinite lifespan, simply send an empty request body. With this seamless process, you can swiftly acquire the access you need to leverage our powerful AML Watcher APIs.
info
Maximum API Keys a user can generate is 5.
Endpoint: https://api.amlwatcher.com/api/api-key
Method: POST
- HTTP
- Javascript
- PHP
- Python
- Ruby
- Java
- cURL
- C#
- Go
Sample Request
POST /api/api-key HTTP/1.1
Host: api.amlwatcher.com
Authorization: Bearer Token
Content-Type: application/json
Content-Length: 24
{
"expires_at": 12
}
Sample Request
const myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer Token");
myHeaders.append("Content-Type", "application/json");
const payload = JSON.stringify({
expires_at: "",
});
const requestOptions = {
method: "POST",
headers: myHeaders,
body: payload,
redirect: "follow",
};
fetch("https://api.amlwatcher.com/api/api-key", 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/api-key',
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 => json_encode(['expires_at' => 12]),
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer Token',
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
Sample Request
import requests
import json
url = "https://api.amlwatcher.com/api/api-key"
payload = json.dumps({
'expires_at': ''
})
headers = {
'Authorization': 'Bearer Token',
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
Sample Request
require "uri"
require "net/http"
require "json"
url = URI("https://api.amlwatcher.com/api/api-key")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer Token"
request['Content-Type'] = "application/json"
payload = { expires_at: 12 }.to_json
request.body = payload
response = https.request(request)
puts response.read_body
Sample Request
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
public class Main {
public static void main(String[] args) {
HttpURLConnection connection = null;
DataOutputStream outputStream = null;
BufferedReader in = null;
try {
// Define the URL
URL url = new URL("https://api.amlwatcher.com/api/api-key");
// Open a connection to the URL
connection = (HttpURLConnection) url.openConnection();
// Set the request method to POST
connection.setRequestMethod("POST");
// Set the request headers
connection.setRequestProperty("Authorization", "Bearer Token");
connection.setRequestProperty("Content-Type", "application/json");
// Enable input/output streams
connection.setDoOutput(true);
// Define the JSON request body
String jsonPayload = "{\"expires_at\": 2}";
// Write the request body
outputStream = new DataOutputStream(connection.getOutputStream());
outputStream.writeBytes(jsonPayload);
outputStream.flush();
// Get the response code
int responseCode = connection.getResponseCode();
System.out.println("Response Code: " + responseCode);
// Read the response
in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
StringBuilder response = new StringBuilder();
String inputLine;
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
// Print the response
System.out.println("Response Body: " + response.toString());
} catch (IOException e) {
e.printStackTrace();
// Print the error response if available
if (connection != null) {
try (BufferedReader errorReader = new BufferedReader(new InputStreamReader(connection.getErrorStream()))) {
StringBuilder errorResponse = new StringBuilder();
String errorLine;
while ((errorLine = errorReader.readLine()) != null) {
errorResponse.append(errorLine);
}
System.out.println("Error Response: " + errorResponse.toString());
} catch (IOException ignored) {
}
}
} finally {
// Close resources
try {
if (outputStream != null) outputStream.close();
if (in != null) in.close();
} catch (IOException ignored) {
}
}
}
}
Sample Request
curl --location --request POST 'https://api.amlwatcher.com/api/api-key'
--header 'Authorization: Bearer Token'
--header 'Content-Type: application/json'
--data-raw '{"expires_at": 12}'
Sample Request
using System;
using System.Threading.Tasks;
using RestSharp;
public class Program
{
public static async Task Main(string[] args)
{
var client = new RestClient(new RestClientOptions("https://api.amlwatcher.com")
{
Timeout = TimeSpan.FromSeconds(30)
});
var request = new RestRequest("/api/api-key", Method.Post);
request.AddHeader("Authorization", "Bearer Token");
request.AddHeader("Content-Type", "application/json");
var requestBody = new
{
expires_at = 12
};
request.AddJsonBody(requestBody);
RestResponse response = await client.ExecuteAsync(request);
Console.WriteLine(response.Content);
if (response.IsSuccessful)
{
Console.WriteLine("Request successful");
}
else
{
Console.WriteLine($"Error: {response.StatusCode} - {response.StatusDescription}");
Console.WriteLine(response.Content);
}
}
}
Sample Request
package main
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
)
func main() {
url := "https://api.amlwatcher.com/api/api-key"
method := "POST"
payload := map[string]interface{}{
"expires_at": 2,
}
payloadBytes, err := json.Marshal(payload)
if err != nil {
fmt.Println(err)
return
}
client := &http.Client{}
req, err := http.NewRequest(method, url, bytes.NewBuffer(payloadBytes))
if err != nil {
fmt.Println(err)
return
}
// Set headers
req.Header.Set("Authorization", "Bearer Token")
req.Header.Set("Content-Type", "application/json")
// Execute the request
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 |
---|---|---|---|
expires_at | Yes | Integer | Min: 1 Max: 365 The expires_at represents the number of days. |
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 containing the actual response elements. |
Sample Response
{
"data": {
"api_key": {
"created_at": "Wed, 08 May 2024 06:13:24 GMT",
"expires_at": "Mon, 20 May 2024 06:13:24 GMT",
"key": "Generated API Key"
}
},
"error": false,
"status": "SUCCESS"
}