API Documentation Diagrams

Document your APIs visually with Mermaid. Sequence diagrams show request/response flows between clients and services. Flowcharts illustrate authentication flows and error handling. ER diagrams define your data models. All rendered directly in your GitHub or GitLab docs.

Why Use Mermaid

  • Sequence diagrams — Show exact request/response flow between services
  • Auth flow documentation — Visualize OAuth, JWT, and session flows
  • Error handling — Document error paths and retry logic visually
  • Data model docs — ER diagrams alongside your API endpoints
  • Stays in sync — Update diagrams in the same PR as API changes

Example Diagram

sequenceDiagram
    participant C as Client
    participant GW as API Gateway
    participant Auth as Auth Service
    participant API as REST API
    participant DB as Database
    participant Cache as Redis

    C->>GW: POST /api/orders
    GW->>Auth: Validate JWT
    Auth-->>GW: Token valid

    GW->>API: Forward request
    API->>Cache: Check inventory
    Cache-->>API: Cache miss

    API->>DB: Query products
    DB-->>API: Product data
    API->>Cache: Update cache

    API->>DB: Create order
    DB-->>API: Order created

    API-->>GW: 201 Created
    GW-->>C: Order response

Copy this code and paste it into the editor to see it rendered live.

Try This Diagram Now

Open the editor with live preview, autocomplete, and export to PNG, SVG, or PDF.

Open Editor

Frequently Asked Questions

More Use Cases