Enable or disable the WAB DNS Discovery TXT record on any Plesk-managed domain via the Plesk REST API.
GET /api/discovery/provider/record-template) for TXT value.GET /api/v2/domains?name=….GET /api/v2/dns/records?domain=… to look up existing _wab TXT records.POST /api/v2/dns/records; if exists with different value, DELETE + POST (Plesk doesn't support TXT update in place).DELETE /api/v2/dns/records/{id}./api/discovery/provider/status. Run dns-on for the domain if updates aren't propagating.// npm install node-fetch@2
const fetch = require('node-fetch');
const HOST = 'plesk.example.com';
const PORT = 8443;
const APIKEY = process.env.PLESK_API_KEY;
const DOMAIN = 'example.com';
const TXT_VAL = `v=wab1; endpoint=https://${DOMAIN}/.well-known/wab.json`;
const headers = { 'X-API-Key': APIKEY, 'Content-Type': 'application/json' };
const base = `https://${HOST}:${PORT}/api/v2`;
async function getDomainId() {
const r = await fetch(`${base}/domains?name=${DOMAIN}`, { headers });
const j = await r.json();
return j[0] && j[0].id;
}
async function listWabRecords() {
const r = await fetch(`${base}/dns/records?domain=${DOMAIN}&type=TXT`, { headers });
const j = await r.json();
return (j || []).filter(rec => rec.host === `_wab.${DOMAIN}.` || rec.host === `_wab.${DOMAIN}`);
}
async function enableWAB() {
const records = await listWabRecords();
if (records.length) {
// remove old, then add new (Plesk REST API doesn't allow in-place TXT edit)
await fetch(`${base}/dns/records/${records[0].id}`, { method: 'DELETE', headers });
}
await fetch(`${base}/dns/records`, {
method: 'POST', headers,
body: JSON.stringify({ domain: DOMAIN, type: 'TXT', host: `_wab.${DOMAIN}`, value: TXT_VAL })
});
console.log('WAB Discovery ENABLED');
}
async function disableWAB() {
const records = await listWabRecords();
if (!records.length) return console.log('Already disabled.');
await fetch(`${base}/dns/records/${records[0].id}`, { method: 'DELETE', headers });
console.log('WAB Discovery DISABLED');
}
enableWAB().catch(console.error);
# Plesk API Key auth
KEY="your-api-key"
HOST="plesk.example.com:8443"
DOMAIN="example.com"
TXT='v=wab1; endpoint=https://example.com/.well-known/wab.json'
# 1. List existing _wab TXT records
curl -sk -H "X-API-Key: $KEY" "https://$HOST/api/v2/dns/records?domain=$DOMAIN&type=TXT"
# 2. Add (enable)
curl -sk -X POST -H "X-API-Key: $KEY" -H "Content-Type: application/json" \
"https://$HOST/api/v2/dns/records" \
-d "{\"domain\":\"$DOMAIN\",\"type\":\"TXT\",\"host\":\"_wab.$DOMAIN\",\"value\":\"$TXT\"}"
# 3. Delete (disable) — replace REC_ID
curl -sk -X DELETE -H "X-API-Key: $KEY" "https://$HOST/api/v2/dns/records/REC_ID"
import os, requests
HOST = 'plesk.example.com'
PORT = 8443
APIKEY = os.environ['PLESK_API_KEY']
DOMAIN = 'example.com'
TXT_VAL = f'v=wab1; endpoint=https://{DOMAIN}/.well-known/wab.json'
HEADERS = {'X-API-Key': APIKEY, 'Content-Type': 'application/json'}
BASE = f'https://{HOST}:{PORT}/api/v2'
def list_wab():
r = requests.get(f'{BASE}/dns/records', params={'domain': DOMAIN, 'type': 'TXT'}, headers=HEADERS, verify=False)
return [rec for rec in r.json() if rec['host'].rstrip('.') == f'_wab.{DOMAIN}']
def enable_wab():
for rec in list_wab():
requests.delete(f'{BASE}/dns/records/{rec["id"]}', headers=HEADERS, verify=False)
requests.post(f'{BASE}/dns/records',
json={'domain': DOMAIN, 'type': 'TXT', 'host': f'_wab.{DOMAIN}', 'value': TXT_VAL},
headers=HEADERS, verify=False)
print('WAB ENABLED')
def disable_wab():
recs = list_wab()
if not recs: return print('Already disabled')
requests.delete(f'{BASE}/dns/records/{recs[0]["id"]}', headers=HEADERS, verify=False)
print('WAB DISABLED')
enable_wab()
← Provider Onboarding · Cloudflare · cPanel · Route 53 · DNS Discovery