Domains under an existing user
Collects domains belonging to the same customer within the user's vdomains and quota limits.
DirectAdmin's da api-url command generates a short-lived Login Key for the target user. Combined with CMD_API_DOMAIN, it can create hundreds of domains without storing the panel password in plaintext.
API_URL="$(da api-url --user=siteuser)"
curl -ksS -X POST "${API_URL}/CMD_API_DOMAIN" -d action=create -d domain=ornek.com -d uquota=unlimited -d ubandwidth=unlimited -d ssl=ON -d php=ON
da docs-root
Bulk automation should not accelerate a wrong architecture. Decide customer isolation, resource limits, application roots, mail and DNS ownership first.
Collects domains belonging to the same customer within the user's vdomains and quota limits.
For different customers and security boundaries, create user accounts with packages first.
da api-url generates short-lived credentials for each use and is safer than embedding a permanent admin password.
DirectAdmin may use Apache, nginx+Apache, nginx or OpenLiteSpeed templates. Let the panel API handle domain creation.
Ensure vdomains, quota, bandwidth, DNS and PHP features can accommodate new domains.
grep -E '^(vdomains|quota|bandwidth|dnscontrol|php)=' /usr/local/directadmin/data/users/siteuser/user.conf Read the domain list in the target user's context without using a permanent password.
curl -ksS "$(da api-url --user=siteuser)/CMD_API_SHOW_DOMAINS" Confirm that the API returns error=0 and web server templates are generated.
head -n 2 /root/domainler.txt > /root/domainler-test.txt A new short-lived API URL is generated before each request and the response is stored in CSV.
chmod 700 /root/directadmin-toplu-domain.sh
/root/directadmin-toplu-domain.sh Check DirectAdmin background tasks and web server template generation.
tail -f /var/log/directadmin/system.log
/usr/local/directadmin/dataskq d Use da docs-root to display actual HTTP and HTTPS paths as JSON.
da docs-root Includes short-lived Login Keys, domain validation, CSV results and error logging.
#!/usr/bin/env bash
set -Eeuo pipefail
DOMAIN_DOSYASI="/root/domainler.txt"
HEDEF_KULLANICI="siteuser"
SONUC="/root/directadmin-domain-sonuclari.csv"
HATA="/root/directadmin-domain-errorlari.log"
[[ "$EUID" -eq 0 ]] || { echo "root gerekli"; exit 1; }
[[ -f "$DOMAIN_DOSYASI" ]] || { echo "domain listesi bulunamadi"; exit 1; }
printf '"domain","durum","kullanici","yanit"\n' > "$SONUC"
: > "$HATA"
chmod 600 "$SONUC" "$HATA"
while IFS= read -r SATIR || [[ -n "$SATIR" ]]; do
DOMAIN="$(printf '%s' "$SATIR" | tr -d '\r' | tr '[:upper:]' '[:lower:]' | sed -E 's#^[[:space:]]+##;s#[[:space:]]+$##;s#^https?://##;s#^www\.##;s#/.*$##')"
[[ -z "$DOMAIN" ]] && continue
[[ "$DOMAIN" == \#* ]] && continue
if [[ ! "$DOMAIN" =~ ^[a-z0-9][a-z0-9.-]*\.[a-z]{2,63}$ ]]; then
printf '"%s","gecersiz","%s",""\n' "$DOMAIN" "$HEDEF_KULLANICI" >> "$SONUC"
continue
fi
API_URL="$(da api-url --user="$HEDEF_KULLANICI" | sed -n 's/^URL:[[:space:]]*//p')"
[[ -n "$API_URL" ]] || API_URL="$(da api-url --user="$HEDEF_KULLANICI")"
YANIT="$(curl -ksS --request POST "${API_URL}/CMD_API_DOMAIN" \
--data-urlencode "action=create" \
--data-urlencode "domain=${DOMAIN}" \
--data-urlencode "ubandwidth=unlimited" \
--data-urlencode "uquota=unlimited" \
--data-urlencode "ssl=ON" \
--data-urlencode "cgi=OFF" \
--data-urlencode "php=ON" 2>&1 || true)"
HATA_KODU="$(printf '%s' "$YANIT" | tr '&' '\n' | awk -F= '$1=="error"{print $2}' | head -n1)"
if [[ "$HATA_KODU" == "0" ]]; then
TEMIZ="$(printf '%s' "$YANIT" | tr '\n' ' ' | sed 's/"/""/g')"
printf '"%s","basarili","%s","%s"\n' "$DOMAIN" "$HEDEF_KULLANICI" "$TEMIZ" >> "$SONUC"
else
printf '%s | %s\n' "$DOMAIN" "$YANIT" >> "$HATA"
TEMIZ="$(printf '%s' "$YANIT" | tr '\n' ' ' | sed 's/"/""/g')"
printf '"%s","errorli","%s","%s"\n' "$DOMAIN" "$HEDEF_KULLANICI" "$TEMIZ" >> "$SONUC"
fi
done < "$DOMAIN_DOSYASI"
echo "Tamamlandi: $SONUC"
echo "Errorlar: $HATA"
Validate the same POST parameters with one domain before bulk processing.
API_URL="$(da api-url --user=siteuser | sed -n 's/^URL:[[:space:]]*//p')"
curl -ksS -X POST "${API_URL}/CMD_API_DOMAIN" --data-urlencode action=create --data-urlencode domain=ornek.com --data-urlencode ubandwidth=unlimited --data-urlencode uquota=unlimited --data-urlencode ssl=ON --data-urlencode cgi=OFF --data-urlencode php=ON
Fetch existing domains through the API to prevent duplicate creation.
curl -ksS "$(da api-url --user=siteuser)/CMD_API_SHOW_DOMAINS"
Run only when verified necessary after template changes or broken vhosts.
cd /usr/local/directadmin/custombuild
./build rewrite_confs
systemctl reload httpd 2>/dev/null || systemctl reload nginx
In standard DirectAdmin setups, domain vhosts are generated from user data; avoid manual vhost additions.
da docs-roothttpd -tsystemctl reload httpdnginx may be the front end and Apache the backend. Test and check reload status for both configurations.
nginx -thttpd -tsystemctl reload nginx && systemctl reload httpdUse DirectAdmin templates and CustomBuild management; do not assume Apache/nginx paths.
cd /usr/local/directadmin/custombuild && ./build options | grep -i webserversystemctl status openlitespeed --no-pagerda docs-rootThe domain may already exist, the user's vdomains limit may be reached or syntax may be rejected.
The Login Key may have expired, the wrong user context may be used or the API URL may be parsed incorrectly.
The domain may exist under another DirectAdmin user, as a pointer or as a DNS zone.
Hundreds of domains can queue web, DNS, mail and SSL tasks and cause delays.
A custom CustomBuild template, invalid rewrite or conflicting domain definition may exist.
No matching error was found.
It generates a short-lived Login Key. Do not log or cache the output and avoid exposing it in process listings.
The official legacy API documentation lists action=create, domain, bandwidth/quota options and ssl, cgi and php flags.
No. Domain, pointer and DNS-zone conflicts must be prevented. Check ownership server-wide first.
Depending on the installation, Apache, nginx+Apache, nginx or OpenLiteSpeed may be used. Adding domains through the panel API handles these differences.
Performance depends more on vhosts, certificates, logs, mail, PHP workers and application load than the raw domain count. Measure file descriptors and reload time.
No. This page is built to be crawlable and structured-data friendly, but final rankings cannot be guaranteed.
We implement panel selection, DNS, SSL, web server, security, backup and verification according to your actual server architecture.