@startuml
title Email Admin Create + Audit Targeting (Before)

skinparam backgroundColor #FFFFFF
skinparam defaultFontColor #000000
skinparam ArrowColor #000000
skinparam SequenceLifeLineBorderColor #000000
skinparam SequenceLifeLineBackgroundColor #F7F7F7
skinparam ParticipantBorderColor #000000
skinparam ParticipantBackgroundColor #FFE8CC
skinparam NoteBackgroundColor #FFF4D6
skinparam NoteBorderColor #000000

actor "Tenant Admin" as Admin
participant "AdminPlugin\n/email/create\n/email-failure/create" as Plugin
participant "Admin handlers" as Handlers
participant "DatabaseAdapter" as Adapter
database "emails / email_send_failures" as Tables
database "admin_audit_logs" as Audit

Admin -> Plugin: POST create request
Plugin -> Handlers: validate + normalize
Handlers -> Adapter: create_*() -> success bool
Adapter -> Tables: INSERT row
Tables --> Adapter: persisted
Adapter --> Handlers: ()
Handlers --> Plugin: { success: true }
Plugin -> Audit: write_audit(target_id = none or indirect)
Plugin --> Admin: 200

note right of Plugin
Audit target_id for create actions is not guaranteed\nto be the actual created row ID.
end note

@enduml
