User Login Authentication Sequence Diagram Template
Login sequence diagram with user, web app, auth service and database: submit credentials, look up the user, verify the password, return a token or 401, with alt branches and a note. For API docs and system design; free PNG, Word and PowerPoint export.
Edit the text, pick a theme, export Word / PowerPoint / PDF
When to use it
API design documents, detailed design specs and the login section of a project report. autonumber numbers every message so the text can refer to "step 3"; alt / else shows the correct-password and wrong-password branches.
Making it yours
- For SMS or email code login, replace "Enter username and password" with "Enter phone number" and add a "verify code" exchange between the auth service and the database.
- Add social login by declaring
participant T as Identity providerand inserting the redirect and callback messages. - Solid arrows
->>are requests, dashed arrows-->>are responses; deleteautonumberif you do not want numbers. - Participant names live in
participant X as Name; message text is everything after the colon.
Mermaid code
sequenceDiagram
autonumber
participant U as User
participant W as Web app
participant S as Auth service
participant D as Database
U->>W: Enter username and password
W->>S: POST /login
S->>D: Look up user
D-->>S: Return password hash
alt Password correct
S-->>W: Return token
W-->>U: Signed in, go to home
else Password wrong
S-->>W: 401 Unauthorized
W-->>U: Show "wrong username or password"
end
Note over W,S: Every later request carries the token in a headerAsk an AI for one with this structure
Send the prompt below to ChatGPT or Claude, then paste the whole reply into the editor; the code inside is detected automatically.
Draw a user login sequence diagram in Mermaid sequenceDiagram syntax with participants User, Web app, Auth service and Database. The user enters credentials, the web app calls the login endpoint, the auth service looks up the user in the database and verifies the password hash; on success it returns a token and the app goes to the home screen, on failure it returns 401 and shows an error. Use alt/else for the two branches and enable autonumber. Output only the mermaid code block.
FAQ
- What are alt, opt and loop?
alt … else … endis an either/or branch,opt … endis an optional fragment andloop … endrepeats. They can be nested; indentation is only for readability.- Can message text contain a colon?
Everything after the first colon is the message text, so "401 Unauthorized" and similar are fine. Avoid semicolons inside the text.
- Can numbering start from a value other than 1?
autonumber 10starts at 10;autonumber 10 5starts at 10 and increments by 5.
More in this category
Online Payment Sequence Diagram TemplatePayment sequence diagram with user, merchant system, payment provider and bank: create the payment, checkout page, charge, synchronous result, asynchronous webhook and retry on failure. For payment integration docs; free PNG, Word and PowerPoint export.
Microservice Call Sequence Diagram TemplateOrder creation call chain across client, API gateway, order service, inventory service, message queue and notification service, with activation bars and an asynchronous event. For microservice design documents, exported as PNG, Word or PowerPoint for free.
Updated 2026-09-05