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 DB

The first word sets the kind:

KeywordDrawn asUse it for
participantA boxA system, service or role
actorA stick figureA person
databaseA cylinderA data store
queueA cylinder on its sideA queue or topic
collectionsStacked boxesSeveral of the same thing
boundaryA UML circleA screen or an API, where the system meets the outside
controlA UML circleThe logic that coordinates
entityA UML circleStored 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 box

A 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, note or database.
"Users DB"->API: Query
"Billing: EU"->Ledger: Post entry
participant "Orders \"main\" DB" as Orders

Inside 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.

On this page