This page is for scripts and integrations. The dashboard uses a separate cookie session; that control API is not the contract below. Create a token in the dashboard under Settings → API tokens. Each token belongs to one workspace and can only see that workspace's zones.
Эта страница для скриптов и интеграций. Панель ходит отдельной cookie-сессией; это не контракт ниже. Токен создаётся в панели: Настройки → API-токены. Токен принадлежит одному воркспейсу и видит только его зоны.
Machine-readable schemas for these routes are in the OpenAPI document under the V1 tag:OpenAPI UI · JSON.
AuthenticationАутентификация
Send Authorization: Bearer <secret> on every request. Secrets start with mk_live_ and are shown once, when you create the token. Store the secret on the server that calls the API. Do not put it in browser JavaScript or a public repository.
- read — list and fetch zones, records, protection state, and firewall rules.список и чтение зон, записей, состояния защиты и правил файрвола.
- write — everything
readcan do, plus create, update, and delete.всё, что умеетread, плюс создание, изменение и удаление.
A missing or revoked token returns 401. A read token that tries to change data returns 403. An account can hold 10 active tokens. Revoke one in Settings before creating another if you are at the limit.
Base URL: https://api.madoka.pro/v1. Bodies are JSON. Errors look like { "message": "..." }.
curl -sS https://api.madoka.pro/v1/zones \
-H "Authorization: Bearer mk_live_…"Typical workflowОбычный порядок
- Create a write token for the workspace.Создайте токен с правом записи для воркспейса.
POST /zoneswith{ "name": "example.com" }. The zone is created in the token's account. The response includesnameservers.В ответе естьnameservers.POST /zones/:zoneId/delegationchecks the public NS set.statusbecomesactivewhen it matchesnameservers.dnsPublishedis true when this API writes the zone to authoritative DNS. Apex NS records are rejected. If PowerDNS is configured and unreachable, the write is rolled back and the API returns503.сверяет публичные NS.statusстановитсяactive, когда они совпали сnameservers.dnsPublishedистинен, когда API пишет зону в авторитетный DNS. NS на апексе отклоняются. Если PowerDNS настроен, но недоступен, запись откатывается и API отвечает503.POST /zones/:zoneId/protectionwith the origin IP,httporhttps, and an optional port. The response includes the TXT record you must publish.POST /zones/:zoneId/protection/verifyafter the TXT record is visible.после того как TXT-запись станет видна.- Manage DNS withДальше DNS через
/zones/:zoneId/records.
Zones and protectionЗоны и защита
| MethodМетод | PathПуть | ScopeДоступ |
|---|---|---|
GET | /zones | read |
GET | /zones/summary | read |
POST | /zones | write |
GET | /zones/:zoneId | read |
DELETE | /zones/:zoneId | write |
POST | /zones/:zoneId/delegation | write |
GET | /zones/:zoneId/protection | read |
POST | /zones/:zoneId/protection | write |
POST | /zones/:zoneId/protection/verify | write |
Protection body: { "originIp": "198.51.100.10", "protocol": "https", "port": 443 }. The origin must be a public IP. 409 means the domain is already registered. 404 means the zone is not in this token's account.
DNS recordsDNS-записи
Names are relative to the zone (@ for the apex). Types are A, AAAA, CNAME, MX, TXT, and NS. TTL is 60–86400 seconds and defaults to 3600. MX records need priority. Only A, AAAA, and CNAME may setproxied: true.
| MethodМетод | PathПуть | ScopeДоступ |
|---|---|---|
GET | /zones/:zoneId/records | read |
POST | /zones/:zoneId/records | write |
GET | /zones/:zoneId/records/:recordId | read |
PATCH | /zones/:zoneId/records/:recordId | write |
DELETE | /zones/:zoneId/records/:recordId | write |
curl -sS -X POST https://api.madoka.pro/v1/zones/ZONE_ID/records \
-H "Authorization: Bearer mk_live_…" \
-H "content-type: application/json" \
-d '{"type":"A","name":"www","content":"198.51.100.10","ttl":300,"proxied":true}'Firewall rulesПравила файрвола
Rules live at /zones/:zoneId/rules (list, create, update, delete). A zone can have at most 1000 rules. Match values are checked for the rule type (IP, ASN, or user agent).
Status codesКоды ответа
- 401 — missing, unknown, or revoked tokenтокен отсутствует, неизвестен или отозван
- 403 — token scope is too narrowу токена не хватает прав
- 404 — zone, record, or rule is not in this accountзона, запись или правило не в этом аккаунте
- 409 — duplicate domain, conflicting record, or a limit (tokens or rules)домен уже есть, запись конфликтует или упёрлись в лимит токенов или правил
- 422 — invalid domain, record, origin, or rule valueнекорректные домен, запись, ориджин или значение правила
- 429 — more than 300 requests per minute from one IPбольше 300 запросов в минуту с одного IP
- 503 — protection verify is unavailable because edge sync is not configuredпроверка защиты недоступна: синхронизация с edge не настроена
Managing tokensУправление токенами
Token create, list, and revoke use the dashboard session, not /v1. In the product that isSettings. The HTTP routes, if you call them with the session cookie, areGET and POST /accounts/:accountId/api-tokens andDELETE /accounts/:accountId/api-tokens/:tokenId.