Sequence basics
What a sequence diagram shows, the parts it's made of, when to draw one and how to start one.
A sequence diagram shows one interaction between people and systems. It shows who takes part and the messages they send each other, in order, with time running down the page.
Use one for a sign-in, a payment, an API call or a webhook: anything where the order of messages matters more than who owns each step. Each element below comes with the sequence code that draws it.


Participants and lifelines
A participant is a person or a system that sends or receives messages. Each one is a column, with its head at the top and a dashed lifeline running down.
The head's shape says what kind of participant it is:
| Kind | 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, such as workers |
| Boundary | A UML circle | Where the system meets the outside, such as a screen or an API |
| Control | A UML circle | Logic that coordinates the others |
| Entity | A UML circle | Data the system keeps, such as an order |
A box round neighbouring participants labels them as a group, such as a third party.
actor Shopper
participant Shop
database Orders DB
Shopper->Shop: Place order
Shop->Orders DB: Save orderParticipants appear left to right in the order the code first names them. Put the one who starts the interaction first.
Messages: call, reply and async
A message is an arrow from one lifeline to another, labelled with what is sent. There are three kinds:
- A call (
->) is a solid line with a filled head. The sender waits for an answer. - A reply (
-->) is a dashed line back to the caller. It answers an earlier call. - An async message (
->>) is a solid line with an open head. Nobody waits, as with an event or a queue.
participant Client
participant API
participant Queue
Client->API: Create order
API-->Client: 201 Created
API->>Queue: Order createdA participant can send a message to itself, such as a step it does on its own.
A message's ends can say more:
- A head at both ends means the message goes both ways.
- A cross at the end means it fails.
- A filled circle at the end means it's lost on the way. At the start, it means the message comes from someone the diagram doesn't show.
- A message can come from outside the diagram, or go out of it.
- A message can create its receiver. The receiver's head is then drawn level with the message.
- A lifeline can end in a cross.
[->Shop: Refund requested
Shop<->Payments: Check order
Payments->x Bank: Refund card
Shop->Worker **: Archive order
destroy WorkerActivation bars
An activation bar is a narrow box on a lifeline. It shows that the participant is busy, usually handling a request while it waits on others.
Add ++ to the message that starts the bar and -- to the one that ends it.
participant Client
participant API
database DB
Client->API ++: GET /orders/42
API->DB: Load order 42
DB-->API: Order
API-->Client --: 200 OKAdd bars for the main service handling a request, not on every message.
Fragments
A fragment is a frame around some messages, with a tab naming its kind and a condition. Use one when messages only happen in some cases, or happen more than once.
| Kind | What it means |
|---|---|
alt | Alternatives: one branch is taken. Each branch after the first starts with else. |
opt | Optional: happens only if the condition holds. |
loop | Repeats while the condition holds. Say the limit, such as "up to 3 times". |
par | Parallel: the branches run at the same time. Each branch after the first starts with and. |
break | Leaves the enclosing block early, such as after the last failed retry. |
critical | Runs without interruption. Each other outcome starts with option. |
group | A labelled box, with no meaning of its own. |
participant Shop
participant Payments
Shop->Payments: Charge card
alt card accepted
Payments-->Shop: Payment confirmed
else card declined
Payments-->Shop: Declined
endOnly alt, par and critical have more than one branch. Write each condition as a short state, such as "cache hit" or "card declined".
UML has seven more operators, for diagrams that say exactly which orders of messages are allowed. Each has one branch and an optional label.
| Kind | What it means |
|---|---|
seq | Weak sequencing: messages on different lifelines may happen in any order. |
strict | Strict sequencing: the messages happen exactly in the order drawn. |
neg | Invalid: these messages must never happen. |
ignore | The messages named in its label may happen here and don't matter. |
consider | Only the messages named in its label matter here. |
assert | Assertion: this is the only valid continuation. |
region | Critical region: nothing else interleaves with these messages. |
The app draws the tab in the frame's top-left corner, in the gap left of the first lifeline inside. The tab ends at that lifeline, or at the activation bar on it. The first condition starts just right of the lifeline and its bars.
The frame leaves at least as much room right of its last lifeline as left of its first. The app draws it over the lifelines and bars it crosses, so its edges stay whole.
Notes, refs, dividers, delays and numbering
- A note holds a fact such as a timeout or a security rule. It sits over one or more participants, or to the left or right of one.
- A ref is a frame over some participants. It stands for an interaction drawn in another diagram.
- A divider splits a long interaction into phases, with a label across the whole diagram.
- A delay shows that time passes. The lifelines turn dotted for a row, with an optional label such as "2 days later".
- Numbering puts 1, 2, 3 in front of the messages, so you can refer to them. It can start at any number and count in steps, such as 10, 20, 30.
autonumber
participant App
participant Auth server
== Sign in ==
App->Auth server: Authorization request
Auth server-->App: Authorization code
note over App, Auth server: State checked on every requestWhen to use a sequence diagram
Draw a BPMN process when the question is "what work happens, who does it, and what comes next". Draw a sequence diagram when the question is "what do these systems say to each other, in what order, and what happens when one fails".
| A process | A sequence diagram | |
|---|---|---|
| Follows | The work, through decisions and hand-offs, often over days | The messages in one interaction, often over seconds |
| Columns or lanes | One lane per role | One column per person or system, with every request and answer between them |
| Good for | People agreeing how work runs | Developers agreeing how a feature or an integration behaves |
The two work well together. A service task in a process, such as "Charge card", can have a sequence diagram of its own that shows the calls behind it.
Keep each sequence diagram to one scenario, with about 3 to 8 participants and up to 30 messages. Draw a second diagram for a detailed part, or for a second scenario such as sign-up next to sign-in.
Make a sequence diagram
There are five ways to start one:
- In the Diagrams panel, select New diagram (the + button) and choose Sequence diagram.
- Press ⌘ K (Ctrl K on Windows and Linux) and run New sequence diagram.
- Select Templates in the rail. Under Sequence diagram are Sign in with Google and Checkout payment, and View all adds API with cache and Webhook delivery. Selecting one creates a new diagram from it.
- In New diagram, choose Import Mermaid, PlantUML or sequence code file…. See Import a file.
- Paste Mermaid, PlantUML or sequencediagram.org code into the Sequence code pane. See Code from other tools.
A new diagram is called "Untitled sequence". On its empty canvas, Describe it opens the assistant, Add participant adds the first column, and Use a template shows the sequence templates. You can also type the diagram in the Sequence code pane beside the canvas.
Next
Edit on the canvas, learn sequence code, or let the assistant draft a diagram for you.