{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/yardstick-team/json-schema/yardstick-team-email-sender-settings-schema.json",
  "title": "EmailSenderSettings",
  "x-generated": "2026-11-29",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/yardstick-team-openapi.json#/components/schemas/EmailSenderSettings",
  "type": "object",
  "properties": {
    "object": {
      "type": "string",
      "enum": [
        "email_sender_settings"
      ]
    },
    "livemode": {
      "type": "boolean"
    },
    "connections": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "object": {
            "type": "string",
            "enum": [
              "email_sender_connection"
            ]
          },
          "provider_connection_id": {
            "type": "string"
          },
          "user_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "provider": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "provider_account_email": {
            "type": [
              "string",
              "null"
            ]
          },
          "provider_account_name": {
            "type": [
              "string",
              "null"
            ]
          },
          "scopes_granted": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "expires_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "last_refresh_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "last_error_code": {
            "type": [
              "string",
              "null"
            ]
          },
          "sender_identity_sync_status": {
            "type": "string"
          },
          "sender_identity_sync_error_code": {
            "type": [
              "string",
              "null"
            ]
          },
          "sender_identity_sync_last_attempted_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "sender_identity_sync_last_synced_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "identity_count": {
            "type": "integer",
            "minimum": 0
          },
          "available_identity_count": {
            "type": "integer",
            "minimum": 0
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "updated_at": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "object",
          "provider_connection_id",
          "user_id",
          "provider",
          "status",
          "provider_account_email",
          "provider_account_name",
          "scopes_granted",
          "expires_at",
          "last_refresh_at",
          "last_error_code",
          "sender_identity_sync_status",
          "sender_identity_sync_error_code",
          "sender_identity_sync_last_attempted_at",
          "sender_identity_sync_last_synced_at",
          "identity_count",
          "available_identity_count",
          "created_at",
          "updated_at"
        ],
        "additionalProperties": false
      }
    },
    "identities": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "object": {
            "type": "string",
            "enum": [
              "email_sender_identity"
            ]
          },
          "id": {
            "type": "string"
          },
          "user_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "provider_connection_id": {
            "type": "string"
          },
          "provider": {
            "type": "string"
          },
          "identity_type": {
            "type": "string"
          },
          "email": {
            "type": "string"
          },
          "display_name": {
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "type": "string"
          },
          "validation_error_code": {
            "type": [
              "string",
              "null"
            ]
          },
          "validated_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "unavailable_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "updated_at": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "object",
          "id",
          "user_id",
          "provider_connection_id",
          "provider",
          "identity_type",
          "email",
          "display_name",
          "status",
          "validation_error_code",
          "validated_at",
          "unavailable_at",
          "created_at",
          "updated_at"
        ],
        "additionalProperties": false
      }
    },
    "defaults": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "object": {
            "type": "string",
            "enum": [
              "email_sender_default"
            ]
          },
          "id": {
            "type": [
              "string",
              "null"
            ]
          },
          "email_type": {
            "type": "string"
          },
          "default_sender_type": {
            "type": "string"
          },
          "org_shared_sender_identity_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "org_shared_sender_email": {
            "type": [
              "string",
              "null"
            ]
          },
          "org_shared_sender_display_name": {
            "type": [
              "string",
              "null"
            ]
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "updated_at": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "object",
          "id",
          "email_type",
          "default_sender_type",
          "org_shared_sender_identity_id",
          "org_shared_sender_email",
          "org_shared_sender_display_name",
          "created_at",
          "updated_at"
        ],
        "additionalProperties": false
      }
    },
    "queue": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "object": {
            "type": "string",
            "enum": [
              "email_sender_queue_item"
            ]
          },
          "id": {
            "type": "string"
          },
          "email_draft_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "application_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "email_type": {
            "type": "string"
          },
          "queue_status": {
            "type": "string"
          },
          "sender_resolution_type": {
            "type": [
              "string",
              "null"
            ]
          },
          "requested_sender_identity_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "resolved_sender_identity_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "reason_code": {
            "type": [
              "string",
              "null"
            ]
          },
          "attempts_count": {
            "type": "integer",
            "minimum": 0
          },
          "last_attempt_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "last_error_code": {
            "type": [
              "string",
              "null"
            ]
          },
          "next_attempt_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "latest_attempt_status": {
            "type": [
              "string",
              "null"
            ]
          },
          "latest_attempt_provider": {
            "type": [
              "string",
              "null"
            ]
          },
          "latest_attempt_error_code": {
            "type": [
              "string",
              "null"
            ]
          },
          "latest_attempt_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "diagnostic_schema_version": {
            "type": [
              "integer",
              "null"
            ],
            "exclusiveMinimum": true,
            "minimum": 0
          },
          "failure_phase": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "default_missing",
              "job_resolution_failed",
              "identity_unavailable",
              "provider_connection_unavailable",
              "token_unavailable",
              "provider_send_failed",
              "system_fallback_disallowed",
              "system_fallback_failed"
            ]
          },
          "selected_transport": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "google",
              "microsoft",
              "resend",
              "none"
            ]
          },
          "fallback_eligible": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "safe_next_action": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "configure_default_sender",
              "assign_job_sender",
              "review_sender_identity",
              "reconnect_provider",
              "configure_customer_sender",
              "configure_system_sender",
              "retry_after_provider_recovery"
            ]
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "updated_at": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "object",
          "id",
          "email_draft_id",
          "application_id",
          "email_type",
          "queue_status",
          "sender_resolution_type",
          "requested_sender_identity_id",
          "resolved_sender_identity_id",
          "reason_code",
          "attempts_count",
          "last_attempt_at",
          "last_error_code",
          "next_attempt_at",
          "latest_attempt_status",
          "latest_attempt_provider",
          "latest_attempt_error_code",
          "latest_attempt_at",
          "diagnostic_schema_version",
          "failure_phase",
          "selected_transport",
          "fallback_eligible",
          "safe_next_action",
          "created_at",
          "updated_at"
        ],
        "additionalProperties": false,
        "description": "Redacted send-queue summary. Diagnostic fields are allowlisted summaries and never include raw metadata, recipient addresses, bodies, provider payloads, or secret material."
      }
    }
  },
  "required": [
    "object",
    "livemode",
    "connections",
    "identities",
    "defaults",
    "queue"
  ],
  "additionalProperties": false
}