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), MOKLAV VPS orders (manual review) and enterprise enquiries. 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
ベース URL: https://dns.moklav.com/api/v1 · OpenAPI 仕様: openapi.json (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
エンドポイント
| 方法 | パス | 説明 |
|---|---|---|
| GET | /zones | このキーでアクセスできるゾーンの一覧 |
| GET | /zones/{zone} | ゾーンの詳細とレコードを取得 |
| GET | /zones/{zone}/records | レコードの一覧(名前・タイプで絞り込み可) |
| POST | /zones/{zone}/records | レコードを 1 件追加(既存の RRset に追記) |
| DELETE | /zones/{zone}/records | レコード値または RRset 全体を削除 |
| PUT | /zones/{zone}/rrset | RRset 全体を置き換え(名前とタイプのすべての値) |
| GET | /zones/{zone}/dnssec | DNSSEC の状態とレジストラ用 DS レコード |
| GET | /zones/{zone}/export | ゾーンを BIND ゾーンファイル形式でエクスポート |
| POST | /acme/present | ACME DNS-01:TXT チャレンジを追加(acme.sh / certbot フック) |
| POST | /acme/cleanup | ACME DNS-01:TXT チャレンジを削除 |
| GET | /hosting/plans | ホスティングプランと料金の一覧(認証不要) |
| GET | /hosting/apps | インストール可能なワンクリックアプリ(認証不要) |
| POST | /hosting/orders | プランを注文 |
| GET | /hosting/orders | 注文の一覧 |
| POST | /hosting/orders/{oid}/cancel | Cancel one of your pending orders |
| GET | /hosting/accounts | ホスティングアカウントの一覧 |
| GET | /hosting/accounts/{aid} | アカウント詳細、プラン、現在の使用量 |
| DELETE | /hosting/accounts/{aid} | すべてのサイト・メール・DB を含めてアカウントを完全に削除(非同期) |
| GET | /hosting/accounts/{aid}/stats | 月別のディスク・帯域幅の履歴(グラフ用) |
| GET | /hosting/accounts/{aid}/sites | ウェブサイトの一覧 |
| POST | /hosting/accounts/{aid}/sites | ウェブサイトを追加(非同期:Web + DNS + Let's Encrypt) |
| GET | /hosting/accounts/{aid}/sites/{domain} | ウェブサイトの詳細、DNS レコード、SFTP パス |
| DELETE | /hosting/accounts/{aid}/sites/{domain} | ウェブサイトとそのファイルを削除(非同期) |
| POST | /hosting/accounts/{aid}/sites/{domain}/ssl | Let's Encrypt SSL を発行・再発行(非同期) |
| PUT | /hosting/accounts/{aid}/sites/{domain}/ssl/force | Force HTTPS (redirect http to https) on or off |
| GET | /hosting/accounts/{aid}/sites/{domain}/aliases | Domain aliases of a website (www is included automatically) |
| POST | /hosting/accounts/{aid}/sites/{domain}/aliases | Add a domain alias (same website under another name) |
| DELETE | /hosting/accounts/{aid}/sites/{domain}/aliases/{alias} | Remove a domain alias |
| PUT | /hosting/accounts/{aid}/sites/{domain}/php | PHP バージョンを切り替え(非同期) |
| POST | /hosting/accounts/{aid}/sites/{domain}/wordpress | ワンクリック WordPress(非同期、パスワードはジョブ結果に一度だけ表示) |
| DELETE | /hosting/accounts/{aid}/sites/{domain}/wordpress | Delete WordPress from this website (its files and its database only; ?confirm=<domain>) |
| POST | /hosting/accounts/{aid}/sites/{domain}/wordpress/credentials | Show the WordPress admin login once (then it is wiped) |
| POST | /hosting/accounts/{aid}/sites/{domain}/apps/{app}/credentials | Show a one-click app's admin login once |
| POST | /hosting/accounts/{aid}/sites/{domain}/wordpress/password | Reset the WordPress admin password (async; new password in job result once) |
| POST | /hosting/accounts/{aid}/sites/{domain}/apps | 対応アプリをワンクリックでインストール(非同期) |
| GET | /hosting/accounts/{aid}/mail/domains | メールドメインの一覧(クライアント設定付き) |
| POST | /hosting/accounts/{aid}/mail/domains | メールドメインを追加(非同期、MX/SPF/DKIM/DMARC は自動設定) |
| GET | /hosting/accounts/{aid}/mail/domains/{domain}/dns | メールに必要な DNS レコード(DKIM を含む) |
| DELETE | /hosting/accounts/{aid}/mail/domains/{domain} | メールドメインとそのすべてのメールボックスを削除 |
| GET | /hosting/accounts/{aid}/mail/domains/{domain}/mailboxes | メールボックスの一覧 |
| POST | /hosting/accounts/{aid}/mail/domains/{domain}/mailboxes | メールボックスを作成 |
| PUT | /hosting/accounts/{aid}/mail/domains/{domain}/mailboxes/{local}/password | メールボックスのパスワードを変更 |
| GET | /hosting/accounts/{aid}/mail/domains/{domain}/mailboxes/{local}/settings | Forwarding and autoreply of a mailbox |
| PUT | /hosting/accounts/{aid}/mail/domains/{domain}/mailboxes/{local}/forward | Set mail forwarding (replaces the list) |
| PUT | /hosting/accounts/{aid}/mail/domains/{domain}/mailboxes/{local}/autoreply | Set or turn off the autoreply (vacation message) |
| DELETE | /hosting/accounts/{aid}/mail/domains/{domain}/mailboxes/{local} | メールボックスを削除 |
| GET | /hosting/accounts/{aid}/databases | MariaDB データベースの一覧 |
| POST | /hosting/accounts/{aid}/databases | データベースとユーザーを作成 |
| POST | /hosting/accounts/{aid}/databases/{name}/phpmyadmin | One-time phpMyAdmin sign-in link (single use, valid 30 seconds, bound to this session/key and IP) |
| PUT | /hosting/accounts/{aid}/databases/{name}/password | データベースのパスワードを変更 |
| DELETE | /hosting/accounts/{aid}/databases/{name} | データベースを削除 |
| GET | /hosting/accounts/{aid}/ftp | List FTP users (all sites) |
| POST | /hosting/accounts/{aid}/ftp | サイトの FTP ユーザーを作成 |
| DELETE | /hosting/accounts/{aid}/ftp/{domain}/{login} | FTP ユーザーを削除 |
| GET | /hosting/accounts/{aid}/cron | cron ジョブの一覧 |
| POST | /hosting/accounts/{aid}/cron | cron ジョブを追加 |
| DELETE | /hosting/accounts/{aid}/cron/{cid} | cron ジョブを削除 |
| GET | /hosting/accounts/{aid}/ssh-keys | SSH/SFTP 鍵の一覧 |
| POST | /hosting/accounts/{aid}/ssh-keys | SSH/SFTP 鍵を追加 |
| DELETE | /hosting/accounts/{aid}/ssh-keys/{kid} | SSH 鍵を削除 |
| GET | /hosting/accounts/{aid}/backups | バックアップの一覧 |
| POST | /hosting/accounts/{aid}/backups | 今すぐバックアップ(非同期) |
| GET | /hosting/accounts/{aid}/backups/schedule | Automatic backup schedule of this plan |
| POST | /hosting/accounts/{aid}/backups/restore | バックアップから復元(非同期) |
| PUT | /hosting/accounts/{aid}/plan | プランを変更(非同期) |
| POST | /hosting/accounts/{aid}/suspend | アカウントを停止(スタッフ用) |
| POST | /hosting/accounts/{aid}/unsuspend | アカウントの停止を解除(スタッフ用) |
| POST | /hosting/accounts/{aid}/cancel | Cancel the plan at the end of the paid period (解約). Nothing is deleted now. |
| GET | /admin/hosting/orders | 全注文(スタッフ用) |
| POST | /admin/hosting/orders/{oid}/approve | 注文を承認してプロビジョニング(スタッフ用) |
| POST | /admin/hosting/orders/{oid}/reject | 注文を却下(スタッフ用) |
| GET | /admin/hosting/accounts | 全ホスティングアカウント(スタッフ用) |
| GET | /admin/hosting/nodes | ホスティングノード、負荷、API の状態(スタッフ用) |
| GET | /jobs/{jid} | 非同期ジョブの状態(succeeded/failed になるまでポーリング) |
| GET | /jobs | ジョブの一覧(新しい順) |
| GET | /webhooks | Webhook の一覧 |
| POST | /webhooks | Webhook を作成(署名シークレットは一度だけ返されます) |
| DELETE | /webhooks/{wid} | Webhook を削除 |
| GET | /audit | アクティビティログ(新しい順) |
| GET | /me | 現在のユーザー、キーのスコープ、レート制限 |
| GET | /vps/plans | List VPS plans, prices and live stock (no auth) |
| POST | /vps/orders | a VPS (manual review) を注文 |
| GET | /vps/orders | List your VPS orders |
| GET | /vps/orders/{oid} | One VPS order |
| POST | /vps/orders/{oid}/cancel | Cancel your pending VPS order (frees capacity) |
| POST | /enquiries | Send an enquiry for a service in preparation (ILL, transit, colocation, add-ons). No auth. |
| GET | /admin/vps/orders | All VPS orders + capacity (staff) |
| POST | /admin/vps/orders/{oid}/decide | Mark a VPS order approved / rejected / provisioned (status only; does NOT create a VM) |
| GET | /admin/enquiries | Enterprise enquiries (staff) |
| GET | /company | Company verification data with public sources (no auth) |
| GET | /invoices | List your invoices (請求書) |
| GET | /invoices/{iid} | One invoice |
| POST | /invoices/{iid}/checkout | Pay by card: Stripe Checkout for a monthly subscription |
| POST | /billing/portal | Stripe Customer Portal (cancel subscription, change card) |
| GET | /billing/subscriptions | Your card subscriptions |
| GET | /billing/methods | Available payment methods (no auth) |
| GET | /admin/invoices | All invoices (staff) |
| POST | /admin/invoices/{iid}/mark-paid | Mark invoice paid and approve the order (hosting auto-provisions; VPS stays manual) |
| POST | /admin/invoices/{iid}/void | Void an unpaid invoice |
| GET | /admin/billing/config | Bank-transfer / invoice issuer settings (staff) |
| PUT | /admin/billing/config | Set bank-transfer details / registration number (staff) |
| POST | /payments/webhook/{provider} | Payment provider webhook (disabled until online payment launches) |
| GET | /coupons/validate | Check a coupon code for a plan before paying (shows the first-invoice price) |
| GET | /hosting/accounts/{aid}/files | List a folder (path relative to the account home; empty = home) |
| DELETE | /hosting/accounts/{aid}/files | Delete a file or folder (folders recursively). Pass ?confirm=<name> |
| POST | /hosting/accounts/{aid}/files/download-link | One-time-ish download URL for a file (valid 60 s; works in a plain browser link) |
| GET | /hosting/files/dl | Download via a signed link from POST /files/download-link |
| GET | /hosting/accounts/{aid}/files/download | Download a file (API key / session header) |
| GET | /hosting/accounts/{aid}/files/content | Read a text file for editing (max 1 MB, UTF-8) |
| PUT | /hosting/accounts/{aid}/files/content | Save a text file (creates it if missing; max 1 MB) |
| POST | /hosting/accounts/{aid}/files/upload | Upload a file into a folder (multipart; size limit in GET /files `limits`) |
| POST | /hosting/accounts/{aid}/files/folder | Create a folder |
| POST | /hosting/accounts/{aid}/files/rename | Rename a file or folder (same folder) |
| PUT | /hosting/accounts/{aid}/files/mode | Change permissions (chmod, e.g. 644 / 755) |
| POST | /hosting/accounts/{aid}/files/zip | Create a .zip of files/folders (links are skipped) |
| POST | /hosting/accounts/{aid}/files/unzip | Extract a .zip into a folder (refuses '..', absolute paths, links, zip bombs; never overwrites) |
| GET | /catalog | Catalog Api |
Let's Encrypt DNS-01(ワイルドカード)
acme.sh
フックスクリプトを acme.sh の dnsapi フォルダーにダウンロードして、次を実行してください:
export MOKLAV_API_KEY="mk_..." acme.sh --issue --dns dns_moklav -d example.com -d '*.example.com'
certbot
フックスクリプトをダウンロードして、次を実行してください:
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'
ダイナミック DNS(DynDNS2)
ドメインの「ダイナミック DNS」タブでトークンを作成してください。ルーター(MikroTik、OpenWrt ddns-scripts、pfSense の「Custom」)、ddclient、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