Flexible MX Record Matching
MX (Mail Exchange) records direct email to mail servers. Flexible matching allows you to verify that specific mail servers are configured while permitting customers to add backup or additional mail providers.
The Need for Flexible MX Matching
When customers use your email service, they need your MX records in their DNS. But they might also want backup mail servers or use additional email services. Exact matching would trigger false alerts whenever they make these additions.
Exact Matching Limitations
curl -X POST https://api.dnsradar.dev/monitors \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"domain": "piedpiper.com",
"record_type": "MX",
"expected_value": [
"mx1.mail-provider.com",
"mx2.mail-provider.com"
],
"is_exact_match": true
}'const response = await fetch('https://api.dnsradar.dev/monitors', {
method: 'POST',
headers: {
"X-API-Key": "YOUR_API_KEY",
"Content-Type": "application/json"
},
body: JSON.stringify({
"domain": "piedpiper.com",
"record_type": "MX",
"expected_value": [
"mx1.mail-provider.com",
"mx2.mail-provider.com"
],
"is_exact_match": true
})
});
const data = await response.json();import requests
response = requests.post(
'https://api.dnsradar.dev/monitors',
headers={
'X-API-Key': 'YOUR_API_KEY',
'Content-Type': 'application/json'
},
json={
"domain": "piedpiper.com",
"record_type": "MX",
"expected_value": [
"mx1.mail-provider.com",
"mx2.mail-provider.com"
],
"is_exact_match": true
}
)require 'net/http'
require 'json'
uri = URI('https://api.dnsradar.dev/monitors')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri)
request['X-API-Key'] = 'YOUR_API_KEY'
request['Content-Type'] = 'application/json'
request.body = {
"domain": "piedpiper.com",
"record_type": "MX",
"expected_value": [
"mx1.mail-provider.com",
"mx2.mail-provider.com"
],
"is_exact_match": true
}.to_json
response = http.request(request)package main
import (
"bytes"
"encoding/json"
"net/http"
)
data := {
"domain": "piedpiper.com",
"record_type": "MX",
"expected_value": [
"mx1.mail-provider.com",
"mx2.mail-provider.com"
],
"is_exact_match": true
}
jsonData, _ := json.Marshal(data)
req, _ := http.NewRequest("POST", "https://api.dnsradar.dev/monitors", bytes.NewBuffer(jsonData))
req.Header.Set("X-API-Key", "YOUR_API_KEY")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
response, _ := client.Do(req)<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.dnsradar.dev/monitors');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
$headers = [
'X-API-Key: YOUR_API_KEY',
'Content-Type: application/json'
];
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$data = json_encode({
"domain": "piedpiper.com",
"record_type": "MX",
"expected_value": [
"mx1.mail-provider.com",
"mx2.mail-provider.com"
],
"is_exact_match": true
});
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$response = curl_exec($ch);
curl_close($ch);import java.net.http.*;
import java.net.URI;
HttpClient client = HttpClient.newHttpClient();
String json = """{
"domain": "piedpiper.com",
"record_type": "MX",
"expected_value": [
"mx1.mail-provider.com",
"mx2.mail-provider.com"
],
"is_exact_match": true
}""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.dnsradar.dev/monitors"))
.header("X-API-Key", "YOUR_API_KEY")
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString(json))
.build();
HttpResponse<String> response = client.send(request,
HttpResponse.BodyHandlers.ofString());using System.Net.Http;
using System.Text;
using System.Text.Json;
var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-API-Key", "YOUR_API_KEY");
var data = new
{
"domain": "piedpiper.com",
"record_type": "MX",
"expected_value": [
"mx1.mail-provider.com",
"mx2.mail-provider.com"
],
"is_exact_match": true
};
var json = JsonSerializer.Serialize(data);
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync(
"https://api.dnsradar.dev/monitors",
content
);If the customer adds a backup mail server, the DNS response becomes:
mx1.mail-provider.com
mx2.mail-provider.com
mx.backup-service.com
With exact matching, this triggers a MISMATCH alert even though your required servers are still present.
Enabling Flexible Matching
Set is_exact_match to false to verify only that your required MX records exist:
curl -X POST https://api.dnsradar.dev/monitors \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"domain": "piedpiper.com",
"record_type": "MX",
"expected_value": [
"mx1.mail-provider.com",
"mx2.mail-provider.com"
],
"is_exact_match": false
}'const response = await fetch('https://api.dnsradar.dev/monitors', {
method: 'POST',
headers: {
"X-API-Key": "YOUR_API_KEY",
"Content-Type": "application/json"
},
body: JSON.stringify({
"domain": "piedpiper.com",
"record_type": "MX",
"expected_value": [
"mx1.mail-provider.com",
"mx2.mail-provider.com"
],
"is_exact_match": false
})
});
const data = await response.json();import requests
response = requests.post(
'https://api.dnsradar.dev/monitors',
headers={
'X-API-Key': 'YOUR_API_KEY',
'Content-Type': 'application/json'
},
json={
"domain": "piedpiper.com",
"record_type": "MX",
"expected_value": [
"mx1.mail-provider.com",
"mx2.mail-provider.com"
],
"is_exact_match": false
}
)require 'net/http'
require 'json'
uri = URI('https://api.dnsradar.dev/monitors')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri)
request['X-API-Key'] = 'YOUR_API_KEY'
request['Content-Type'] = 'application/json'
request.body = {
"domain": "piedpiper.com",
"record_type": "MX",
"expected_value": [
"mx1.mail-provider.com",
"mx2.mail-provider.com"
],
"is_exact_match": false
}.to_json
response = http.request(request)package main
import (
"bytes"
"encoding/json"
"net/http"
)
data := {
"domain": "piedpiper.com",
"record_type": "MX",
"expected_value": [
"mx1.mail-provider.com",
"mx2.mail-provider.com"
],
"is_exact_match": false
}
jsonData, _ := json.Marshal(data)
req, _ := http.NewRequest("POST", "https://api.dnsradar.dev/monitors", bytes.NewBuffer(jsonData))
req.Header.Set("X-API-Key", "YOUR_API_KEY")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
response, _ := client.Do(req)<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.dnsradar.dev/monitors');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
$headers = [
'X-API-Key: YOUR_API_KEY',
'Content-Type: application/json'
];
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$data = json_encode({
"domain": "piedpiper.com",
"record_type": "MX",
"expected_value": [
"mx1.mail-provider.com",
"mx2.mail-provider.com"
],
"is_exact_match": false
});
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$response = curl_exec($ch);
curl_close($ch);import java.net.http.*;
import java.net.URI;
HttpClient client = HttpClient.newHttpClient();
String json = """{
"domain": "piedpiper.com",
"record_type": "MX",
"expected_value": [
"mx1.mail-provider.com",
"mx2.mail-provider.com"
],
"is_exact_match": false
}""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.dnsradar.dev/monitors"))
.header("X-API-Key", "YOUR_API_KEY")
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString(json))
.build();
HttpResponse<String> response = client.send(request,
HttpResponse.BodyHandlers.ofString());using System.Net.Http;
using System.Text;
using System.Text.Json;
var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-API-Key", "YOUR_API_KEY");
var data = new
{
"domain": "piedpiper.com",
"record_type": "MX",
"expected_value": [
"mx1.mail-provider.com",
"mx2.mail-provider.com"
],
"is_exact_match": false
};
var json = JsonSerializer.Serialize(data);
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync(
"https://api.dnsradar.dev/monitors",
content
);How Flexible Matching Works
With flexible matching enabled for MX records, DNSRadar:
- Verifies all MX records in your
expected_valueare present in the DNS response - Ignores additional MX records not in your expected list
- Allows any priority values unless you explicitly specify them
- Considers the monitor VALID as long as your required servers exist
Valid MX Configurations
With the flexible configuration above, these MX record sets would all be VALID:
# Just your servers
mx1.mail-provider.com
mx2.mail-provider.com
# With backup server
mx1.mail-provider.com
mx2.mail-provider.com
mx.backup-service.com
# With multiple additional servers
mx1.mail-provider.com
mx2.mail-provider.com
mx.google.com
mx.microsoft.com
All contain your required MX records, so they pass validation.
Managing MX Priorities
MX records include priority values that determine mail server preference. You can monitor priorities or ignore them based on your needs.
Without Priorities (Default)
If you don't specify priorities, any priority value is accepted:
curl -X POST https://api.dnsradar.dev/monitors \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"domain": "piedpiper.com",
"record_type": "MX",
"expected_value": [
"mx1.mail-provider.com",
"mx2.mail-provider.com"
],
"is_exact_match": false
}'const response = await fetch('https://api.dnsradar.dev/monitors', {
method: 'POST',
headers: {
"X-API-Key": "YOUR_API_KEY",
"Content-Type": "application/json"
},
body: JSON.stringify({
"domain": "piedpiper.com",
"record_type": "MX",
"expected_value": [
"mx1.mail-provider.com",
"mx2.mail-provider.com"
],
"is_exact_match": false
})
});
const data = await response.json();import requests
response = requests.post(
'https://api.dnsradar.dev/monitors',
headers={
'X-API-Key': 'YOUR_API_KEY',
'Content-Type': 'application/json'
},
json={
"domain": "piedpiper.com",
"record_type": "MX",
"expected_value": [
"mx1.mail-provider.com",
"mx2.mail-provider.com"
],
"is_exact_match": false
}
)require 'net/http'
require 'json'
uri = URI('https://api.dnsradar.dev/monitors')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri)
request['X-API-Key'] = 'YOUR_API_KEY'
request['Content-Type'] = 'application/json'
request.body = {
"domain": "piedpiper.com",
"record_type": "MX",
"expected_value": [
"mx1.mail-provider.com",
"mx2.mail-provider.com"
],
"is_exact_match": false
}.to_json
response = http.request(request)package main
import (
"bytes"
"encoding/json"
"net/http"
)
data := {
"domain": "piedpiper.com",
"record_type": "MX",
"expected_value": [
"mx1.mail-provider.com",
"mx2.mail-provider.com"
],
"is_exact_match": false
}
jsonData, _ := json.Marshal(data)
req, _ := http.NewRequest("POST", "https://api.dnsradar.dev/monitors", bytes.NewBuffer(jsonData))
req.Header.Set("X-API-Key", "YOUR_API_KEY")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
response, _ := client.Do(req)<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.dnsradar.dev/monitors');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
$headers = [
'X-API-Key: YOUR_API_KEY',
'Content-Type: application/json'
];
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$data = json_encode({
"domain": "piedpiper.com",
"record_type": "MX",
"expected_value": [
"mx1.mail-provider.com",
"mx2.mail-provider.com"
],
"is_exact_match": false
});
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$response = curl_exec($ch);
curl_close($ch);import java.net.http.*;
import java.net.URI;
HttpClient client = HttpClient.newHttpClient();
String json = """{
"domain": "piedpiper.com",
"record_type": "MX",
"expected_value": [
"mx1.mail-provider.com",
"mx2.mail-provider.com"
],
"is_exact_match": false
}""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.dnsradar.dev/monitors"))
.header("X-API-Key", "YOUR_API_KEY")
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString(json))
.build();
HttpResponse<String> response = client.send(request,
HttpResponse.BodyHandlers.ofString());using System.Net.Http;
using System.Text;
using System.Text.Json;
var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-API-Key", "YOUR_API_KEY");
var data = new
{
"domain": "piedpiper.com",
"record_type": "MX",
"expected_value": [
"mx1.mail-provider.com",
"mx2.mail-provider.com"
],
"is_exact_match": false
};
var json = JsonSerializer.Serialize(data);
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync(
"https://api.dnsradar.dev/monitors",
content
);These would all match:
10 mx1.mail-provider.com, 20 mx2.mail-provider.com
5 mx1.mail-provider.com, 10 mx2.mail-provider.com
100 mx1.mail-provider.com, 100 mx2.mail-provider.com
With Priorities
To enforce specific priorities, include them in your expected values:
curl -X POST https://api.dnsradar.dev/monitors \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"domain": "piedpiper.com",
"record_type": "MX",
"expected_value": [
"10 mx1.mail-provider.com",
"20 mx2.mail-provider.com"
],
"is_exact_match": false
}'const response = await fetch('https://api.dnsradar.dev/monitors', {
method: 'POST',
headers: {
"X-API-Key": "YOUR_API_KEY",
"Content-Type": "application/json"
},
body: JSON.stringify({
"domain": "piedpiper.com",
"record_type": "MX",
"expected_value": [
"10 mx1.mail-provider.com",
"20 mx2.mail-provider.com"
],
"is_exact_match": false
})
});
const data = await response.json();import requests
response = requests.post(
'https://api.dnsradar.dev/monitors',
headers={
'X-API-Key': 'YOUR_API_KEY',
'Content-Type': 'application/json'
},
json={
"domain": "piedpiper.com",
"record_type": "MX",
"expected_value": [
"10 mx1.mail-provider.com",
"20 mx2.mail-provider.com"
],
"is_exact_match": false
}
)require 'net/http'
require 'json'
uri = URI('https://api.dnsradar.dev/monitors')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri)
request['X-API-Key'] = 'YOUR_API_KEY'
request['Content-Type'] = 'application/json'
request.body = {
"domain": "piedpiper.com",
"record_type": "MX",
"expected_value": [
"10 mx1.mail-provider.com",
"20 mx2.mail-provider.com"
],
"is_exact_match": false
}.to_json
response = http.request(request)package main
import (
"bytes"
"encoding/json"
"net/http"
)
data := {
"domain": "piedpiper.com",
"record_type": "MX",
"expected_value": [
"10 mx1.mail-provider.com",
"20 mx2.mail-provider.com"
],
"is_exact_match": false
}
jsonData, _ := json.Marshal(data)
req, _ := http.NewRequest("POST", "https://api.dnsradar.dev/monitors", bytes.NewBuffer(jsonData))
req.Header.Set("X-API-Key", "YOUR_API_KEY")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
response, _ := client.Do(req)<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.dnsradar.dev/monitors');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
$headers = [
'X-API-Key: YOUR_API_KEY',
'Content-Type: application/json'
];
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$data = json_encode({
"domain": "piedpiper.com",
"record_type": "MX",
"expected_value": [
"10 mx1.mail-provider.com",
"20 mx2.mail-provider.com"
],
"is_exact_match": false
});
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$response = curl_exec($ch);
curl_close($ch);import java.net.http.*;
import java.net.URI;
HttpClient client = HttpClient.newHttpClient();
String json = """{
"domain": "piedpiper.com",
"record_type": "MX",
"expected_value": [
"10 mx1.mail-provider.com",
"20 mx2.mail-provider.com"
],
"is_exact_match": false
}""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.dnsradar.dev/monitors"))
.header("X-API-Key", "YOUR_API_KEY")
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString(json))
.build();
HttpResponse<String> response = client.send(request,
HttpResponse.BodyHandlers.ofString());using System.Net.Http;
using System.Text;
using System.Text.Json;
var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-API-Key", "YOUR_API_KEY");
var data = new
{
"domain": "piedpiper.com",
"record_type": "MX",
"expected_value": [
"10 mx1.mail-provider.com",
"20 mx2.mail-provider.com"
],
"is_exact_match": false
};
var json = JsonSerializer.Serialize(data);
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync(
"https://api.dnsradar.dev/monitors",
content
);Priority Format: When specifying priorities, use the format "<priority> <hostname>". The priority must be the first part, followed by a space, then the hostname.
With priorities specified, the monitor validates both the hostname AND the priority value. This configuration would only match:
10 mx1.mail-provider.com
20 mx2.mail-provider.com
But NOT:
5 mx1.mail-provider.com ❌ Wrong priority
20 mx2.mail-provider.com
Priority Consistency
All or Nothing: You must be consistent within each monitor. Either specify priorities for all MX records or for none. Mixing formatted records causes validation errors.
Invalid configuration (mixed formats):
{
"expected_value": ["10 mx1.mail-provider.com", "mx2.mail-provider.com"]
// ❌ Inconsistent: one with priority, one without
}
Valid configurations:
// All without priorities ✓
{
"expected_value": ["mx1.mail-provider.com", "mx2.mail-provider.com"]
}
// All with priorities ✓
{
"expected_value": ["10 mx1.mail-provider.com", "20 mx2.mail-provider.com"]
}
When Monitors Trigger
A MISMATCH alert is triggered if:
- One or more of your required MX records are removed
- Priority values don't match (when you've specified priorities)
- All MX records are removed
- DNS query returns an error
Priority Independence: The is_exact_match parameter only controls whether additional MX records are allowed. It doesn't affect priority validation, which is controlled by whether you include priorities in expected_value.
Best Practices
- Omit Priorities for Flexibility: Unless priority order is critical, omit priorities to avoid false alerts
- Monitor Primary Servers Only: Focus on your critical mail servers, allowing customers to add backups
- Use Flexible Matching: Enable
is_exact_match: falsefor MX monitors unless you need strict control - Document Requirements: Clearly communicate to customers which MX records must remain configured
Combining with Email Authentication
Complete email infrastructure monitoring:
curl -X POST https://api.dnsradar.dev/monitors/bulk \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"monitors": [
{
"domain": "piedpiper.com",
"record_type": "MX",
"expected_value": [
"mx1.service.com"
],
"is_exact_match": false
},
{
"domain": "piedpiper.com",
"record_type": "TXT",
"expected_value": "v=spf1 include:_spf.service.com",
"is_exact_match": false
},
{
"domain": "piedpiper.com",
"subdomain": "_dmarc",
"record_type": "TXT",
"expected_value": "v=DMARC1",
"is_exact_match": false
}
],
"group": "email-infrastructure"
}'const response = await fetch('https://api.dnsradar.dev/monitors/bulk', {
method: 'POST',
headers: {
"X-API-Key": "YOUR_API_KEY",
"Content-Type": "application/json"
},
body: JSON.stringify({
"monitors": [
{
"domain": "piedpiper.com",
"record_type": "MX",
"expected_value": [
"mx1.service.com"
],
"is_exact_match": false
},
{
"domain": "piedpiper.com",
"record_type": "TXT",
"expected_value": "v=spf1 include:_spf.service.com",
"is_exact_match": false
},
{
"domain": "piedpiper.com",
"subdomain": "_dmarc",
"record_type": "TXT",
"expected_value": "v=DMARC1",
"is_exact_match": false
}
],
"group": "email-infrastructure"
})
});
const data = await response.json();import requests
response = requests.post(
'https://api.dnsradar.dev/monitors/bulk',
headers={
'X-API-Key': 'YOUR_API_KEY',
'Content-Type': 'application/json'
},
json={
"monitors": [
{
"domain": "piedpiper.com",
"record_type": "MX",
"expected_value": [
"mx1.service.com"
],
"is_exact_match": false
},
{
"domain": "piedpiper.com",
"record_type": "TXT",
"expected_value": "v=spf1 include:_spf.service.com",
"is_exact_match": false
},
{
"domain": "piedpiper.com",
"subdomain": "_dmarc",
"record_type": "TXT",
"expected_value": "v=DMARC1",
"is_exact_match": false
}
],
"group": "email-infrastructure"
}
)require 'net/http'
require 'json'
uri = URI('https://api.dnsradar.dev/monitors/bulk')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri)
request['X-API-Key'] = 'YOUR_API_KEY'
request['Content-Type'] = 'application/json'
request.body = {
"monitors": [
{
"domain": "piedpiper.com",
"record_type": "MX",
"expected_value": [
"mx1.service.com"
],
"is_exact_match": false
},
{
"domain": "piedpiper.com",
"record_type": "TXT",
"expected_value": "v=spf1 include:_spf.service.com",
"is_exact_match": false
},
{
"domain": "piedpiper.com",
"subdomain": "_dmarc",
"record_type": "TXT",
"expected_value": "v=DMARC1",
"is_exact_match": false
}
],
"group": "email-infrastructure"
}.to_json
response = http.request(request)package main
import (
"bytes"
"encoding/json"
"net/http"
)
data := {
"monitors": [
{
"domain": "piedpiper.com",
"record_type": "MX",
"expected_value": [
"mx1.service.com"
],
"is_exact_match": false
},
{
"domain": "piedpiper.com",
"record_type": "TXT",
"expected_value": "v=spf1 include:_spf.service.com",
"is_exact_match": false
},
{
"domain": "piedpiper.com",
"subdomain": "_dmarc",
"record_type": "TXT",
"expected_value": "v=DMARC1",
"is_exact_match": false
}
],
"group": "email-infrastructure"
}
jsonData, _ := json.Marshal(data)
req, _ := http.NewRequest("POST", "https://api.dnsradar.dev/monitors/bulk", bytes.NewBuffer(jsonData))
req.Header.Set("X-API-Key", "YOUR_API_KEY")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
response, _ := client.Do(req)<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.dnsradar.dev/monitors/bulk');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
$headers = [
'X-API-Key: YOUR_API_KEY',
'Content-Type: application/json'
];
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$data = json_encode({
"monitors": [
{
"domain": "piedpiper.com",
"record_type": "MX",
"expected_value": [
"mx1.service.com"
],
"is_exact_match": false
},
{
"domain": "piedpiper.com",
"record_type": "TXT",
"expected_value": "v=spf1 include:_spf.service.com",
"is_exact_match": false
},
{
"domain": "piedpiper.com",
"subdomain": "_dmarc",
"record_type": "TXT",
"expected_value": "v=DMARC1",
"is_exact_match": false
}
],
"group": "email-infrastructure"
});
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$response = curl_exec($ch);
curl_close($ch);import java.net.http.*;
import java.net.URI;
HttpClient client = HttpClient.newHttpClient();
String json = """{
"monitors": [
{
"domain": "piedpiper.com",
"record_type": "MX",
"expected_value": [
"mx1.service.com"
],
"is_exact_match": false
},
{
"domain": "piedpiper.com",
"record_type": "TXT",
"expected_value": "v=spf1 include:_spf.service.com",
"is_exact_match": false
},
{
"domain": "piedpiper.com",
"subdomain": "_dmarc",
"record_type": "TXT",
"expected_value": "v=DMARC1",
"is_exact_match": false
}
],
"group": "email-infrastructure"
}""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.dnsradar.dev/monitors/bulk"))
.header("X-API-Key", "YOUR_API_KEY")
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString(json))
.build();
HttpResponse<String> response = client.send(request,
HttpResponse.BodyHandlers.ofString());using System.Net.Http;
using System.Text;
using System.Text.Json;
var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-API-Key", "YOUR_API_KEY");
var data = new
{
"monitors": [
{
"domain": "piedpiper.com",
"record_type": "MX",
"expected_value": [
"mx1.service.com"
],
"is_exact_match": false
},
{
"domain": "piedpiper.com",
"record_type": "TXT",
"expected_value": "v=spf1 include:_spf.service.com",
"is_exact_match": false
},
{
"domain": "piedpiper.com",
"subdomain": "_dmarc",
"record_type": "TXT",
"expected_value": "v=DMARC1",
"is_exact_match": false
}
],
"group": "email-infrastructure"
};
var json = JsonSerializer.Serialize(data);
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync(
"https://api.dnsradar.dev/monitors/bulk",
content
);