{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/beel-es/json-schema/beel-es-company-email-configuration-schema.json",
  "title": "CompanyEmailConfiguration",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/beel-es-companyemailconfiguration-api-openapi.yml#/components/schemas/CompanyEmailConfiguration",
  "type": "object",
  "required": [
    "sender",
    "defaults"
  ],
  "properties": {
    "sender": {
      "$ref": "#/$defs/CompanyEmailSender"
    },
    "defaults": {
      "$ref": "#/$defs/CompanyEmailDefaults"
    }
  },
  "$defs": {
    "CompanyEmailDefaults": {
      "type": "object",
      "description": "The content applied to an invoice email that does not specify its own. The additional recipients are always added.",
      "required": [
        "subject",
        "message",
        "cc",
        "additional_recipients"
      ],
      "properties": {
        "subject": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 500,
          "description": "Subject template, with the variables of `GET /v1/email-template-variables`."
        },
        "message": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 5000,
          "description": "Message template, with the variables of `GET /v1/email-template-variables`."
        },
        "cc": {
          "type": [
            "array",
            "null"
          ],
          "items": {
            "$ref": "#/$defs/Email"
          },
          "description": "CC recipients, applied when the email request does not specify `cc`."
        },
        "additional_recipients": {
          "type": [
            "array",
            "null"
          ],
          "items": {
            "$ref": "#/$defs/Email"
          },
          "description": "Recipients added to those of every invoice email."
        }
      }
    },
    "CompanyEmailSender": {
      "type": "object",
      "description": "The sender chosen for the invoice emails of a company, and the one in effect.",
      "required": [
        "source",
        "email_domain_id",
        "local_part",
        "effective"
      ],
      "properties": {
        "source": {
          "$ref": "#/$defs/CompanyEmailSenderSource"
        },
        "email_domain_id": {
          "type": [
            "string",
            "null"
          ],
          "format": "uuid",
          "description": "The email domain of the account the company chose; `null` unless `source` is `EMAIL_DOMAIN`."
        },
        "local_part": {
          "type": [
            "string",
            "null"
          ],
          "description": "Part of the address before the `@`. `null` means `facturas`, and it is always `null` when `source` is `BEEL`."
        },
        "effective": {
          "$ref": "#/$defs/EffectiveEmailSender"
        }
      }
    },
    "CompanyEmailSenderSource": {
      "type": "string",
      "enum": [
        "ACCOUNT_DEFAULT",
        "EMAIL_DOMAIN",
        "BEEL"
      ],
      "description": "What the company chose as the sender of its invoice emails.\n\n- ACCOUNT_DEFAULT: no choice; it inherits the default email domain of the account.\n- EMAIL_DOMAIN: one of the email domains of the account, in `email_domain_id`.\n- BEEL: the address of BeeL.\n"
    },
    "EffectiveEmailSender": {
      "type": "object",
      "description": "The address the invoice emails of a company go out from, and why.",
      "required": [
        "from_address",
        "reason"
      ],
      "properties": {
        "from_address": {
          "type": "string",
          "format": "email",
          "description": "Address shown as the sender of the invoice emails."
        },
        "reason": {
          "$ref": "#/$defs/EmailSenderReason"
        },
        "email_domain_id": {
          "type": "string",
          "format": "uuid",
          "description": "The email domain of the account the address belongs to. Absent when the address is BeeL.'s."
        }
      }
    },
    "Email": {
      "type": "string",
      "format": "email",
      "minLength": 5,
      "maxLength": 255,
      "description": "Email address (minimum valid email is 5 chars, e.g. a@b.co)"
    },
    "EmailSenderReason": {
      "type": "string",
      "enum": [
        "CUSTOM_DOMAIN",
        "ADDON_INACTIVE",
        "DOMAIN_NOT_VERIFIED",
        "NO_DOMAIN",
        "BEEL_SELECTED"
      ],
      "description": "Why invoice emails go out from the address they go out from.\n\n- CUSTOM_DOMAIN: from a verified email domain of the account. Nothing to do.\n- ADDON_INACTIVE: the company or the account has an email domain but the account does not\n  hold the custom email domain add-on, so emails go out from BeeL. Contract the add-on with\n  BeeL. to use the domain.\n- DOMAIN_NOT_VERIFIED: the email domains that apply are not verified, so emails go out from\n  BeeL. Verify the domain with `POST /v1/accounts/{account_id}/email-domains/{email_domain_id}/verify`\n  once its DNS records are published.\n- NO_DOMAIN: neither the company nor the account has an email domain, so emails go out from\n  BeeL. Register one with `POST /v1/accounts/{account_id}/email-domains`.\n- BEEL_SELECTED: the company chose the address of BeeL. (`source` `BEEL`). Nothing to do.\n"
    }
  }
}