Participants
Declare participants in sequence code, set their kind and alias, group them in boxes and quote names that need it.
You don't have to declare participants: a message adds any name it mentions. Declare one when you want to fix its place, set its kind or give it an alias.
Declare a participant
participant Shop
actor Shopper
database "Orders DB" as DBThe first word sets the kind:
| Keyword | Drawn as | Use it for |
|---|---|---|
participant | A box | A system, service or role |
actor | A stick figure | A person |
database | A cylinder | A data store |
queue | A cylinder on its side | A queue or topic |
collections | Stacked boxes | Several of the same thing |
boundary | A UML circle | A screen or an API, where the system meets the outside |
control | A UML circle | The logic that coordinates |
entity | A UML circle | Stored data |
as gives the participant an alias. That's a short name that later lines use instead of its full name. Lines can still use the full name too.
In a quoted name, \n starts a new line, and the app draws the head with the name on two lines: participant "Order\nService" as OS.
Name participants as the reader knows them: "Shopper", "Payments API", "Orders DB".
Declare once
Each participant can be declared once. Declaring it after a message has already named it is fine. The line sets its kind or alias, and the column stays where the first mention put it.
Boxes
box Payments provider
participant Payments API
database Ledger
end boxA box draws a labelled outline round the participants declared inside it, such as a third party or one team's services. The participants in a box sit side by side.
Only participant lines go in a box, and a participant is in one box at most.
sequencediagram.org's participantgroup is a box too. It closes with end, and its colour comes first: participantgroup #lightgreen Payments provider. A group inside another adds its participants to the outer box, since a participant is in one box at most.
Quotes
Put a name in double quotes in two cases:
- It has characters the code would read otherwise, such as a colon, a comma, an arrow, a quote or
//. - It has several words and starts with a word that begins other lines, such as
end,noteordatabase.
"Users DB"->API: Query
"Billing: EU"->Ledger: Post entry
participant "Orders \"main\" DB" as OrdersInside quotes, write \" for a quote and \\ for a backslash. Spaces alone don't need quotes: Orders DB->API: Query works.
A name that ends in something that reads as a colour, such as Ticket #123, also goes in quotes. See Colour and styling.