Sequence: Create/Destroy Participants

Mermaid's own create/destroy example: Carl and Donald appear at the message that creates them, and Carl and Bob's lifelines end with a cross at the message that destroys them — useful for showing a participant's actual lifetime instead of assuming every actor exists for the whole diagram.

sequence-create-destroy-participants.mmd
sequenceDiagram
  Alice->>Bob: Hello Bob, how are you ?
  Bob->>Alice: Fine, thank you. And you?
  create participant Carl
  Alice->>Carl: Hi Carl!
  create actor D as Donald
  Carl->>D: Hi!
  destroy Carl
  Alice-xCarl: We are too many
  destroy Bob
  Bob->>Alice: I agree
Output
Sequence diagram, Zombie Mermaid Hello Bob, how are you ? Fine, thank you. And you? Hi Carl! Hi! We are too many I agree Alice Bob Carl Donald

More Sequence diagram examples