{
  "openapi" : "3.1.0",
  "info" : {
    "title" : "MathiWay API",
    "version" : "1.0.0",
    "summary" : "Domains, DNS records, availability, Dynamic DNS and ACME DNS-01 challenges.",
    "description" : "The MathiWay REST API manages the domains and DNS records of one MathiWay account.\n\n**Authentication.** Create an API key under Control panel › API keys. A key belongs to the\naccount it was made in and reaches only that account's domains, with the rights of the member\nwho made it. Send it as `Authorization: Bearer <key>`. Clients that only speak HTTP Basic\n(routers, lego's httpreq provider) may send any username and the key as the password.\n\n**Rate limits.** Per visitor address 120 requests a minute, per key owner 60 a minute and\n1,000 an hour. Answers carry `RateLimit-Limit` and `RateLimit-Remaining`; over a limit the\nanswer is HTTP 429 with `Retry-After` (seconds). Never retry in a tight loop.\n\n**Errors.** Failed calls answer JSON `{\"error\": \"...\"}` with 400 (bad input), 401 (no or\nunknown key), 403 (not a domain of the key's account), 429 (rate limited) or 502 (the\nregistry or DNS service refused or did not answer).\n",
    "contact" : {
      "name" : "MathiWay AB",
      "url" : "https://mathiway.com/contact"
    },
    "license" : {
      "name" : "Proprietary",
      "url" : "https://mathiway.com/terms"
    }
  },
  "servers" : [ {
    "url" : "https://mathiway.com"
  } ],
  "security" : [ {
    "bearerAuth" : [ ]
  }, {
    "basicAuth" : [ ]
  } ],
  "tags" : [ {
    "name" : "Domains"
  }, {
    "name" : "DNS"
  }, {
    "name" : "Availability"
  }, {
    "name" : "Dynamic DNS"
  }, {
    "name" : "ACME"
  } ],
  "paths" : {
    "/api/v1/domains" : {
      "get" : {
        "tags" : [ "Domains" ],
        "operationId" : "listDomains",
        "summary" : "List the account's domains",
        "description" : "The domains the API key's account holds and its owner may manage, sorted by name.",
        "responses" : {
          "200" : {
            "description" : "The domain names.",
            "content" : {
              "application/json" : {
                "schema" : {
                  "type" : "object",
                  "required" : [ "domains" ],
                  "properties" : {
                    "domains" : {
                      "type" : "array",
                      "items" : {
                        "type" : "string",
                        "example" : "example.se"
                      }
                    }
                  }
                }
              }
            }
          },
          "401" : {
            "$ref" : "#/components/responses/Unauthorized"
          },
          "429" : {
            "$ref" : "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/api/v1/domains/{domain}/dns" : {
      "parameters" : [ {
        "$ref" : "#/components/parameters/Domain"
      } ],
      "get" : {
        "tags" : [ "DNS" ],
        "operationId" : "listRecords",
        "summary" : "List a domain's DNS records",
        "responses" : {
          "200" : {
            "description" : "The records in the domain's zone.",
            "content" : {
              "application/json" : {
                "schema" : {
                  "type" : "object",
                  "required" : [ "records" ],
                  "properties" : {
                    "records" : {
                      "type" : "array",
                      "items" : {
                        "$ref" : "#/components/schemas/Record"
                      }
                    }
                  }
                }
              }
            }
          },
          "401" : {
            "$ref" : "#/components/responses/Unauthorized"
          },
          "403" : {
            "$ref" : "#/components/responses/Forbidden"
          },
          "429" : {
            "$ref" : "#/components/responses/TooManyRequests"
          },
          "502" : {
            "$ref" : "#/components/responses/Upstream"
          }
        }
      },
      "post" : {
        "tags" : [ "DNS" ],
        "operationId" : "addRecord",
        "summary" : "Add a DNS record",
        "requestBody" : {
          "required" : true,
          "content" : {
            "application/json" : {
              "schema" : {
                "$ref" : "#/components/schemas/RecordInput"
              },
              "example" : {
                "type" : "TXT",
                "host" : "@",
                "value" : "hello",
                "ttl" : "3600"
              }
            }
          }
        },
        "responses" : {
          "200" : {
            "$ref" : "#/components/responses/Result"
          },
          "401" : {
            "$ref" : "#/components/responses/Unauthorized"
          },
          "403" : {
            "$ref" : "#/components/responses/Forbidden"
          },
          "429" : {
            "$ref" : "#/components/responses/TooManyRequests"
          },
          "502" : {
            "$ref" : "#/components/responses/Upstream"
          }
        }
      },
      "delete" : {
        "tags" : [ "DNS" ],
        "operationId" : "deleteRecord",
        "summary" : "Delete a DNS record",
        "description" : "Deletes the record with this type, host and value.",
        "parameters" : [ {
          "name" : "type",
          "in" : "query",
          "required" : true,
          "schema" : {
            "$ref" : "#/components/schemas/RecordType"
          }
        }, {
          "name" : "host",
          "in" : "query",
          "required" : false,
          "schema" : {
            "type" : "string",
            "default" : "@"
          },
          "description" : "The record's name inside the zone; `@` is the domain itself."
        }, {
          "name" : "value",
          "in" : "query",
          "required" : true,
          "schema" : {
            "type" : "string"
          }
        } ],
        "responses" : {
          "200" : {
            "$ref" : "#/components/responses/Result"
          },
          "401" : {
            "$ref" : "#/components/responses/Unauthorized"
          },
          "403" : {
            "$ref" : "#/components/responses/Forbidden"
          },
          "429" : {
            "$ref" : "#/components/responses/TooManyRequests"
          },
          "502" : {
            "$ref" : "#/components/responses/Upstream"
          }
        }
      }
    },
    "/api/v1/availability" : {
      "get" : {
        "tags" : [ "Availability" ],
        "operationId" : "checkAvailability",
        "summary" : "Check whether a name can be registered",
        "parameters" : [ {
          "name" : "name",
          "in" : "query",
          "required" : true,
          "schema" : {
            "type" : "string",
            "example" : "mybrand.se"
          },
          "description" : "A full domain name."
        } ],
        "responses" : {
          "200" : {
            "description" : "The name's status.",
            "content" : {
              "application/json" : {
                "schema" : {
                  "type" : "object",
                  "required" : [ "name", "status" ],
                  "properties" : {
                    "name" : {
                      "type" : "string",
                      "example" : "mybrand.se"
                    },
                    "status" : {
                      "type" : "string",
                      "description" : "`available` can be registered; `regthroughothers` is taken; `reserved` is held by the registry.",
                      "enum" : [ "available", "regthroughothers", "reserved", "unknown" ]
                    }
                  }
                }
              }
            }
          },
          "400" : {
            "$ref" : "#/components/responses/BadRequest"
          },
          "401" : {
            "$ref" : "#/components/responses/Unauthorized"
          },
          "429" : {
            "$ref" : "#/components/responses/TooManyRequests"
          },
          "502" : {
            "$ref" : "#/components/responses/Upstream"
          }
        }
      }
    },
    "/api/v1/dyndns/update" : {
      "get" : {
        "tags" : [ "Dynamic DNS" ],
        "operationId" : "dynDnsUpdate",
        "summary" : "Point hosts at an address (dyndns2)",
        "description" : "The dyndns2 protocol spoken by routers, ddclient and inadyn. Use HTTP Basic with any\nusername and the API key as the password. Sets the A (IPv4) or AAAA (IPv6) record of\neach hostname. Answers one plain-text line per hostname.\n",
        "parameters" : [ {
          "name" : "hostname",
          "in" : "query",
          "required" : true,
          "schema" : {
            "type" : "string",
            "example" : "home.example.se"
          },
          "description" : "One or more hostnames, separated by commas."
        }, {
          "name" : "myip",
          "in" : "query",
          "required" : false,
          "schema" : {
            "type" : "string",
            "example" : "203.0.113.5"
          },
          "description" : "The address to set; without it the caller's address is used."
        } ],
        "responses" : {
          "200" : {
            "description" : "`good <ip>`, `nochg <ip>`, `nohost`, `notfqdn` or `dnserr`, one line per hostname.",
            "content" : {
              "text/plain" : {
                "schema" : {
                  "type" : "string",
                  "example" : "good 203.0.113.5"
                }
              }
            }
          },
          "401" : {
            "$ref" : "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/api/v1/acme/present" : {
      "post" : {
        "tags" : [ "ACME" ],
        "operationId" : "acmePresent",
        "summary" : "Publish an ACME DNS-01 challenge",
        "description" : "lego's `httpreq` format. Only `_acme-challenge` TXT records may be written (TTL 60).",
        "requestBody" : {
          "required" : true,
          "content" : {
            "application/json" : {
              "schema" : {
                "$ref" : "#/components/schemas/AcmeChallenge"
              }
            }
          }
        },
        "responses" : {
          "200" : {
            "$ref" : "#/components/responses/Result"
          },
          "400" : {
            "$ref" : "#/components/responses/BadRequest"
          },
          "401" : {
            "$ref" : "#/components/responses/Unauthorized"
          },
          "403" : {
            "$ref" : "#/components/responses/Forbidden"
          },
          "502" : {
            "$ref" : "#/components/responses/Upstream"
          }
        }
      }
    },
    "/api/v1/acme/cleanup" : {
      "post" : {
        "tags" : [ "ACME" ],
        "operationId" : "acmeCleanup",
        "summary" : "Remove an ACME DNS-01 challenge",
        "description" : "Removing a challenge that is already gone succeeds.",
        "requestBody" : {
          "required" : true,
          "content" : {
            "application/json" : {
              "schema" : {
                "$ref" : "#/components/schemas/AcmeChallenge"
              }
            }
          }
        },
        "responses" : {
          "200" : {
            "$ref" : "#/components/responses/Result"
          },
          "400" : {
            "$ref" : "#/components/responses/BadRequest"
          },
          "401" : {
            "$ref" : "#/components/responses/Unauthorized"
          },
          "403" : {
            "$ref" : "#/components/responses/Forbidden"
          }
        }
      }
    }
  },
  "components" : {
    "securitySchemes" : {
      "bearerAuth" : {
        "type" : "http",
        "scheme" : "bearer",
        "description" : "An API key from Control panel › API keys (starts with `mwk_`)."
      },
      "basicAuth" : {
        "type" : "http",
        "scheme" : "basic",
        "description" : "Any username, the API key as the password."
      }
    },
    "parameters" : {
      "Domain" : {
        "name" : "domain",
        "in" : "path",
        "required" : true,
        "schema" : {
          "type" : "string",
          "example" : "example.se"
        }
      }
    },
    "schemas" : {
      "RecordType" : {
        "type" : "string",
        "enum" : [ "A", "AAAA", "CNAME", "MX", "TXT", "NS", "SRV", "SOA" ]
      },
      "Record" : {
        "type" : "object",
        "properties" : {
          "type" : {
            "$ref" : "#/components/schemas/RecordType"
          },
          "host" : {
            "type" : "string",
            "example" : "www",
            "description" : "The name inside the zone; `@` is the domain itself."
          },
          "value" : {
            "type" : "string",
            "example" : "203.0.113.5"
          },
          "ttl" : {
            "type" : "string",
            "example" : "3600"
          },
          "priority" : {
            "type" : [ "string", "null" ],
            "example" : "10",
            "description" : "For MX and SRV records."
          }
        }
      },
      "RecordInput" : {
        "type" : "object",
        "required" : [ "type", "value" ],
        "properties" : {
          "type" : {
            "$ref" : "#/components/schemas/RecordType"
          },
          "host" : {
            "type" : "string",
            "default" : "@"
          },
          "value" : {
            "type" : "string"
          },
          "ttl" : {
            "type" : "string",
            "example" : "3600"
          },
          "priority" : {
            "type" : "string",
            "example" : "10"
          }
        }
      },
      "AcmeChallenge" : {
        "type" : "object",
        "required" : [ "fqdn", "value" ],
        "properties" : {
          "fqdn" : {
            "type" : "string",
            "example" : "_acme-challenge.example.se."
          },
          "value" : {
            "type" : "string",
            "example" : "LHDhK3oGRvkiefQnx7OOczTY5Tic_xZ6HcMOc_gmtoM"
          }
        }
      },
      "Result" : {
        "type" : "object",
        "properties" : {
          "ok" : {
            "type" : "boolean"
          },
          "message" : {
            "type" : "string"
          }
        }
      },
      "Error" : {
        "type" : "object",
        "required" : [ "error" ],
        "properties" : {
          "error" : {
            "type" : "string"
          }
        }
      }
    },
    "responses" : {
      "Result" : {
        "description" : "The change was made (`ok` is true).",
        "content" : {
          "application/json" : {
            "schema" : {
              "$ref" : "#/components/schemas/Result"
            }
          }
        }
      },
      "BadRequest" : {
        "description" : "The input was not valid.",
        "content" : {
          "application/json" : {
            "schema" : {
              "$ref" : "#/components/schemas/Error"
            }
          }
        }
      },
      "Unauthorized" : {
        "description" : "No API key, or one that is unknown or revoked."
      },
      "Forbidden" : {
        "description" : "Not a domain of the API key's account.",
        "content" : {
          "application/json" : {
            "schema" : {
              "$ref" : "#/components/schemas/Error"
            }
          }
        }
      },
      "TooManyRequests" : {
        "description" : "Rate limited; wait the seconds in `Retry-After`.",
        "headers" : {
          "Retry-After" : {
            "schema" : {
              "type" : "integer"
            }
          }
        }
      },
      "Upstream" : {
        "description" : "The registry or DNS service refused the change or did not answer.",
        "content" : {
          "application/json" : {
            "schema" : {
              "$ref" : "#/components/schemas/Error"
            }
          }
        }
      }
    }
  }
}