{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/modoboa/json-schema/modoboa-domain-schema.json",
  "title": "Domain",
  "description": "Domain serializer for v2 API.",
  "x-generated": "2026-10-28",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/modoboa-openapi.json#/components/schemas/Domain",
  "type": "object",
  "properties": {
    "pk": {
      "type": "integer",
      "readOnly": true,
      "title": "ID"
    },
    "name": {
      "type": "string",
      "description": "The domain name",
      "maxLength": 253
    },
    "quota": {
      "type": "string",
      "description": "Quota shared between mailboxes. Can be expressed in KB, MB (default) or GB. A value of 0 means no quota."
    },
    "default_mailbox_quota": {
      "type": "string",
      "description": "Default quota in MB applied to mailboxes. A value of 0 means no quota."
    },
    "enabled": {
      "type": "boolean",
      "description": "Check to activate this domain"
    },
    "type": {
      "type": "string",
      "maxLength": 20
    },
    "enable_dkim": {
      "type": "boolean",
      "title": "Enable DKIM signing",
      "description": "If you activate this feature, a DKIM key will be generated for this domain."
    },
    "dkim_key_selector": {
      "type": "string",
      "maxLength": 30
    },
    "dkim_key_length": {
      "nullable": true,
      "title": "Key length",
      "minimum": 0,
      "maximum": 9223372036854775807,
      "oneOf": [
        {
          "$ref": "#/$defs/DkimKeyLengthEnum"
        },
        {
          "$ref": "#/$defs/NullEnum"
        }
      ]
    },
    "dkim_public_key": {
      "type": "string",
      "readOnly": true
    },
    "dkim_private_key_path": {
      "type": "string",
      "readOnly": true
    },
    "mailbox_count": {
      "type": "integer",
      "readOnly": true
    },
    "mbalias_count": {
      "type": "integer",
      "readOnly": true
    },
    "domainalias_count": {
      "type": "integer",
      "readOnly": true
    },
    "dns_global_status": {
      "type": "string",
      "description": "Return global DNS status.",
      "readOnly": true
    },
    "message_limit": {
      "type": [
        "integer",
        "null"
      ],
      "maximum": 9223372036854775807,
      "minimum": 0,
      "format": "int64",
      "title": "Message sending limit",
      "description": "Number of messages this domain can send per day"
    },
    "creation": {
      "type": "string",
      "format": "date-time",
      "readOnly": true
    },
    "last_modification": {
      "type": "string",
      "format": "date-time",
      "readOnly": true
    },
    "allocated_quota_in_percent": {
      "type": "string",
      "readOnly": true
    },
    "enable_dns_checks": {
      "type": "boolean",
      "description": "Check to enable DNS checks for this domain"
    },
    "domain_admin": {
      "allOf": [
        {
          "$ref": "#/$defs/CreateDomainAdmin"
        }
      ],
      "writeOnly": true
    },
    "transport": {
      "$ref": "#/$defs/Transport"
    },
    "opened_alarms_count": {
      "type": "integer",
      "description": "Number of alarms currently opened for this domain.",
      "readOnly": true
    },
    "sent_messages": {
      "type": "string",
      "readOnly": true
    },
    "sent_messages_in_percent": {
      "type": [
        "integer",
        "null"
      ],
      "description": "Return number of sent messages as a percentage.",
      "readOnly": true
    },
    "last_dns_check_execution": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    }
  },
  "required": [
    "allocated_quota_in_percent",
    "creation",
    "dkim_private_key_path",
    "dkim_public_key",
    "dns_global_status",
    "domainalias_count",
    "last_modification",
    "mailbox_count",
    "mbalias_count",
    "name",
    "opened_alarms_count",
    "pk",
    "sent_messages",
    "sent_messages_in_percent"
  ],
  "$defs": {
    "CreateDomainAdmin": {
      "type": "object",
      "description": "Sub serializer for domain administrator creation.",
      "properties": {
        "username": {
          "type": "string"
        },
        "password": {
          "type": "string"
        },
        "with_mailbox": {
          "type": "boolean",
          "default": false
        },
        "with_aliases": {
          "type": "boolean",
          "default": false
        }
      },
      "required": [
        "username"
      ]
    },
    "DkimKeyLengthEnum": {
      "enum": [
        1024,
        2048,
        4096
      ],
      "type": "integer",
      "description": "* `1024` - 1024\n* `2048` - 2048\n* `4096` - 4096"
    },
    "NullEnum": {
      "enum": [
        null
      ]
    },
    "Transport": {
      "type": "object",
      "description": "Serializer for Transport model.",
      "properties": {
        "service": {
          "type": "string",
          "maxLength": 30
        },
        "settings": {
          "type": "object",
          "additionalProperties": {}
        }
      },
      "required": [
        "service",
        "settings"
      ]
    }
  }
}