Fragments and notes
Write fragments, notes, refs, dividers and delays in sequence code.
Fragments frame messages that happen only in some cases, or more than once. Notes, refs, dividers and delays add what the arrows can't say.
Fragments
alt card accepted
Payments-->Shop: Payment confirmed
else card declined
Payments-->Shop: Declined
end
par
Shop->>Email: Send receipt
and
Shop->>Warehouse: Pick order
end
loop up to 3 times
Worker->Receiver: POST /webhooks
endA fragment starts with its kind and an optional condition, and closes with end. See Fragments for what each kind means.
The kinds are alt, opt, loop, par, break, critical and group. UML's other operators are seq, strict, neg, ignore, consider, assert and region. These have one branch and a label: consider login, logout. sequencediagram.org's expandable+ and expandable- read as group.
How branches start:
- In an
alt, each branch after the first starts withelseand its condition. - In a
par, each branch after the first starts withand, or sequencediagram.org'sthread. - In a
critical, each other outcome starts withoptionand its condition. - The other kinds have one branch.
Fragments can sit inside other fragments.
Notes
note over App: Token cached for 5 minutes
note over App, Auth server: PKCE checked on every request
note left of User: On a phone
note right of Receiver
Signed with HMAC-SHA256
Replays rejected after 5 minutes
end notenote overtakes one participant, or several separated by commas, and spans them.note left ofandnote right oftake one participant.- For a note of several lines, leave out the colon, write the lines below, and close them with
end note.\nin a note's text also starts a new line.
Some other tools' words are notes too. These are sequencediagram.org's box, abox, rbox and state, and PlantUML's hnote and rnote, followed by over, left of or right of: box over API: validates cart. One of several lines closes with its own word, such as end box.
Refs
ref over Shop, Payments: Take payment
ref over Shop
Notify customer
by email and SMS
end refA ref is a frame that stands for an interaction drawn in another diagram. It goes over one participant, or spans several separated by commas.
For text of several lines, leave out the colon and close the lines with end ref.
Dividers and delays
== Delivery ==
...2 days later...
...A divider is a label between two ==, across the whole diagram. Use one to split a long interaction into phases.
A delay is ..., with optional text and another ... after it. It shows that time passes: the lifelines turn dotted for a row.