MOKLAV API (DNS + Hosting) v1.1.0
One API for MOKLAV DNS (zones on ns1/ns2.moklav.com) and MOKLAV Hosting (websites, SSL, mail, databases, FTP, cron, SSH keys, backups, one-click apps). Auth: `Authorization: Bearer <key>`. Scopes: `dns` (zones chosen at key creation), `hosting:read`, `hosting:write`. Errors: `{"error":{"code","message","status","details","request_id"}}`. Slow operations return `202` with a job; poll `GET /jobs/{id}` or use webhooks. Guide for humans and AI agents: https://dns.moklav.com/docs/guide and https://dns.moklav.com/llms.txt
Base URL: https://dns.moklav.com/api/v1 · OpenAPI spec: openapi.json (import into Postman / Insomnia / Swagger)
curl -H "Authorization: Bearer mk_..." https://dns.moklav.com/api/v1/zones
curl -X POST -H "Authorization: Bearer mk_..." -H "Content-Type: application/json" \
-d '{"name":"www","type":"A","content":"192.0.2.10","ttl":300}' https://dns.moklav.com/api/v1/zones/example.com/records
Endpoints
| Method | Path | Description |
|---|---|---|
| GET | /zones | List zones this key can access |
| GET | /zones/{zone} | Get zone details and records |
| GET | /zones/{zone}/records | List records (optionally filter by name/type) |
| POST | /zones/{zone}/records | Add one record (appends to an existing RRset) |
| DELETE | /zones/{zone}/records | Delete a record value or a whole RRset |
| PUT | /zones/{zone}/rrset | Replace a whole RRset (all values for name+type) |
| GET | /zones/{zone}/dnssec | DNSSEC status and DS records for the registrar |
| GET | /zones/{zone}/export | Export zone as BIND zone file text |
| POST | /acme/present | ACME DNS-01: add a TXT challenge (acme.sh / certbot hook) |
| POST | /acme/cleanup | ACME DNS-01: remove a TXT challenge |
| GET | /hosting/plans | List hosting plans and prices (no auth) |
| GET | /hosting/apps | One-click apps available for install (no auth) |
| POST | /hosting/orders | Order a plan |
| GET | /hosting/orders | List your orders |
| POST | /hosting/orders/{oid}/cancel | Cancel one of your pending orders |
| GET | /hosting/accounts | List hosting accounts |
| GET | /hosting/accounts/{aid} | Account details, plan and live usage |
| DELETE | /hosting/accounts/{aid} | Permanently delete account with all sites/mail/DBs (async) |
| GET | /hosting/accounts/{aid}/stats | Monthly disk/bandwidth history (for graphs) |
| GET | /hosting/accounts/{aid}/sites | List websites |
| POST | /hosting/accounts/{aid}/sites | Add website (async: web + DNS + Let's Encrypt) |
| GET | /hosting/accounts/{aid}/sites/{domain} | Website details, DNS records and SFTP path |
| DELETE | /hosting/accounts/{aid}/sites/{domain} | Delete website and its files (async) |
| POST | /hosting/accounts/{aid}/sites/{domain}/ssl | Issue / re-issue Let's Encrypt SSL (async) |
| PUT | /hosting/accounts/{aid}/sites/{domain}/php | Switch PHP version (async) |
| POST | /hosting/accounts/{aid}/sites/{domain}/wordpress | One-click WordPress (async; password in job result once) |
| POST | /hosting/accounts/{aid}/sites/{domain}/apps | One-click install any supported app (async) |
| GET | /hosting/accounts/{aid}/mail/domains | List mail domains (with client settings) |
| POST | /hosting/accounts/{aid}/mail/domains | Add mail domain (async; MX/SPF/DKIM/DMARC auto) |
| GET | /hosting/accounts/{aid}/mail/domains/{domain}/dns | DNS records needed for mail (incl. DKIM) |
| DELETE | /hosting/accounts/{aid}/mail/domains/{domain} | Delete mail domain and ALL its mailboxes |
| GET | /hosting/accounts/{aid}/mail/domains/{domain}/mailboxes | List mailboxes |
| POST | /hosting/accounts/{aid}/mail/domains/{domain}/mailboxes | Create mailbox |
| PUT | /hosting/accounts/{aid}/mail/domains/{domain}/mailboxes/{local}/password | Change mailbox password |
| DELETE | /hosting/accounts/{aid}/mail/domains/{domain}/mailboxes/{local} | Delete mailbox |
| GET | /hosting/accounts/{aid}/databases | List MariaDB databases |
| POST | /hosting/accounts/{aid}/databases | Create database + user |
| PUT | /hosting/accounts/{aid}/databases/{name}/password | Change database password |
| DELETE | /hosting/accounts/{aid}/databases/{name} | Delete database |
| POST | /hosting/accounts/{aid}/ftp | Create FTP user for a site |
| DELETE | /hosting/accounts/{aid}/ftp/{domain}/{login} | Delete FTP user |
| GET | /hosting/accounts/{aid}/cron | List cron jobs |
| POST | /hosting/accounts/{aid}/cron | Add cron job |
| DELETE | /hosting/accounts/{aid}/cron/{cid} | Delete cron job |
| GET | /hosting/accounts/{aid}/ssh-keys | List SSH/SFTP keys |
| POST | /hosting/accounts/{aid}/ssh-keys | Add SSH/SFTP key |
| DELETE | /hosting/accounts/{aid}/ssh-keys/{kid} | Remove SSH key |
| GET | /hosting/accounts/{aid}/backups | List backups |
| POST | /hosting/accounts/{aid}/backups | Back up now (async) |
| POST | /hosting/accounts/{aid}/backups/restore | Restore from backup (async) |
| PUT | /hosting/accounts/{aid}/plan | Change plan (async) |
| POST | /hosting/accounts/{aid}/suspend | Suspend account (staff) |
| POST | /hosting/accounts/{aid}/unsuspend | Unsuspend account (staff) |
| GET | /admin/hosting/orders | All orders (staff) |
| POST | /admin/hosting/orders/{oid}/approve | Approve order and provision (staff) |
| POST | /admin/hosting/orders/{oid}/reject | Reject order (staff) |
| GET | /admin/hosting/accounts | All hosting accounts (staff) |
| GET | /admin/hosting/nodes | Hosting nodes, load and API health (staff) |
| GET | /jobs/{jid} | Async job status (poll until succeeded/failed) |
| GET | /jobs | List your jobs (newest first) |
| GET | /webhooks | List webhooks |
| POST | /webhooks | Create webhook (signing secret returned once) |
| DELETE | /webhooks/{wid} | Delete webhook |
| GET | /audit | Your activity log (newest first) |
| GET | /me | Current user, key scopes and rate limit |
Let's Encrypt DNS-01 (wildcards)
acme.sh
Download the hook script into the acme.sh dnsapi folder, then run:
export MOKLAV_API_KEY="mk_..." acme.sh --issue --dns dns_moklav -d example.com -d '*.example.com'
certbot
Download the hook script, then run:
export MOKLAV_API_KEY="mk_..." certbot certonly --manual --preferred-challenges dns \ --manual-auth-hook "./certbot-moklav-hook.sh auth" --manual-cleanup-hook "./certbot-moklav-hook.sh cleanup" \ -d example.com -d '*.example.com'
Dynamic DNS (DynDNS2)
Create a token in your domain's Dynamic DNS tab. Works with routers (MikroTik, OpenWrt ddns-scripts, pfSense "Custom"), ddclient and curl:
https://dns.moklav.com/nic/update?hostname=home.example.com&myip=1.2.3.4 (HTTP basic auth: any username, password = token) # ddclient: protocol=dyndns2, server=dns.moklav.com, login=ddns, password=TOKEN