@startuml
title Email Admin Write Validation (Before)

skinparam backgroundColor #FFFFFF
skinparam defaultFontColor #000000
skinparam ArrowColor #000000
skinparam SequenceLifeLineBorderColor #000000
skinparam SequenceLifeLineBackgroundColor #F7F7F7
skinparam ParticipantBorderColor #000000
skinparam ParticipantBackgroundColor #FFE8C2
skinparam NoteBackgroundColor #FFE9E9
skinparam NoteBorderColor #000000

actor "Admin Client" as Client
participant "AdminPlugin\n/email* create|update" as Plugin
participant "Admin Handlers" as Handlers
participant "Tenant Runtime\nDatabaseAdapter" as Adapter
database "tenant.emails / tenant.email_send_failures" as Tables

Client -> Plugin: POST /admin/email/create\nor /email/update\nor /email-failure/create
Plugin -> Handlers: parsed request body
Handlers -> Adapter: write with minimal field trimming
Adapter -> Tables: INSERT / UPDATE
Tables --> Adapter: OK
Adapter --> Handlers: OK
Handlers --> Plugin: success response
Plugin --> Client: 200

note right of Handlers
Required fields checked mostly by shape/length.\nWhitespace-only values and some empty updates\ncan pass into persistence.
end note

@enduml
