{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/getmattered/json-schema/getmattered-mail-connections-response-schema.json",
  "title": "MailConnectionsResponse",
  "x-generated": "2026-11-11",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/getmattered-integrations-api-openapi.yml#/components/schemas/MailConnectionsResponse",
  "type": "object",
  "properties": {
    "access": {
      "$ref": "#/$defs/IntegrationsAccess"
    },
    "applicantAddress": {
      "$ref": "#/$defs/ApplicantAddress"
    },
    "gmailForwarding": {
      "$ref": "#/$defs/GmailForwardingView"
    },
    "mailboxes": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/MailboxConnectionView"
      }
    },
    "relayAddress": {
      "type": [
        "string",
        "null"
      ]
    }
  },
  "required": [
    "access",
    "applicantAddress",
    "gmailForwarding",
    "mailboxes",
    "relayAddress"
  ],
  "$defs": {
    "ApplicantAddress": {
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "email": {
              "type": [
                "string",
                "null"
              ]
            },
            "kind": {
              "type": "string",
              "enum": [
                "relay"
              ]
            }
          },
          "required": [
            "email",
            "kind"
          ]
        },
        {
          "type": "object",
          "properties": {
            "email": {
              "type": "string"
            },
            "kind": {
              "type": "string",
              "enum": [
                "mailbox"
              ]
            },
            "provider": {
              "type": "string",
              "enum": [
                "gmail",
                "outlook"
              ],
              "description": "Connected user mailbox provider"
            }
          },
          "required": [
            "email",
            "kind",
            "provider"
          ]
        }
      ]
    },
    "GmailForwardingConfirmation": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "code": {
          "type": "string"
        },
        "gmailAddress": {
          "type": "string"
        },
        "receivedAt": {
          "type": "integer"
        }
      },
      "required": [
        "code",
        "gmailAddress",
        "receivedAt"
      ]
    },
    "GmailForwardingView": {
      "type": "object",
      "properties": {
        "confirmation": {
          "$ref": "#/$defs/GmailForwardingConfirmation"
        },
        "relayAddress": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "confirmation",
        "relayAddress"
      ]
    },
    "IntegrationsAccess": {
      "type": "object",
      "properties": {
        "allowed": {
          "type": "boolean"
        },
        "requiredTier": {
          "type": "string",
          "enum": [
            "job_seeker",
            "hired_in_30",
            "hired_yesterday"
          ],
          "description": "Subscription plan tier level"
        },
        "state": {
          "type": "string",
          "enum": [
            "included",
            "plan_required",
            "beta_request",
            "beta_pending",
            "beta_denied"
          ],
          "description": "Whether integrations are open: included, the plan is missing, or the beta request is not made, pending or denied"
        }
      },
      "required": [
        "allowed",
        "requiredTier",
        "state"
      ]
    },
    "MailboxConnectionView": {
      "type": "object",
      "properties": {
        "connectedAt": {
          "type": "integer"
        },
        "email": {
          "type": "string"
        },
        "isApplicantAddress": {
          "type": "boolean"
        },
        "lastSyncedAt": {
          "type": [
            "integer",
            "null"
          ]
        },
        "provider": {
          "type": "string",
          "enum": [
            "gmail",
            "outlook"
          ],
          "description": "Connected user mailbox provider"
        },
        "stats": {
          "type": "object",
          "properties": {
            "codesRead": {
              "type": "integer",
              "minimum": 0
            },
            "jobEmails": {
              "type": "integer",
              "minimum": 0
            },
            "linkedToApplications": {
              "type": "integer",
              "minimum": 0
            }
          },
          "required": [
            "codesRead",
            "jobEmails",
            "linkedToApplications"
          ]
        },
        "status": {
          "type": "string",
          "enum": [
            "connected",
            "needs_reconnect"
          ],
          "description": "Whether a connected mailbox can be read and sent from"
        }
      },
      "required": [
        "connectedAt",
        "email",
        "isApplicantAddress",
        "lastSyncedAt",
        "provider",
        "stats",
        "status"
      ]
    }
  }
}