fegura.ai

Diagrams

The Diagrams API lets you retrieve architecture diagrams generated from your infrastructure scans. Diagrams are returned as Mermaid code that can be rendered in your own applications or documentation.

GET/api/diagramsread

List all diagrams

GET/api/diagrams/{id}read

Get a specific diagram with Mermaid code


List Diagrams

GET/api/diagramsread

Returns a paginated list of all diagrams generated for your organization.

Query Parameters

ParameterTypeDescription
accountIdstringFilter by Fegura account connection ID
diagramTypestringFilter by diagram type (architecture, network, dataflow, boundary, organization)
limitintegerNumber of diagrams to return per page (1-100)Default: 20
cursorstringPagination cursor from previous response

Example Request

curl "https://api.fegura.ai/api/diagrams?diagramType=network&limit=10" \
  -H "Authorization: Bearer feg_live_your_api_key" \
  -H "Fegura-Version: 2026-02-01"

Response

{
  "success": true,
  "data": {
    "diagrams": [
      {
        "id": "770e8400-e29b-41d4-a716-446655440000",
        "scanJobId": "660e8400-e29b-41d4-a716-446655440000",
        "awsAccountId": "550e8400-e29b-41d4-a716-446655440000",
        "diagramType": "network",
        "title": "VPC Network Architecture",
        "status": "completed",
        "errorMessage": null,
        "createdAt": "2026-01-20T14:32:00.000Z",
        "updatedAt": "2026-01-20T14:32:15.000Z"
      }
    ],
    "meta": {
      "hasMore": false
    }
  }
}

Response Fields

ParameterTypeDescription
idstringUnique diagram identifier (UUID)
scanJobIdstringID of the scan that generated this diagram
awsAccountIdstringFegura account connection ID
diagramTypestringDiagram type (see table below)
titlestringHuman-readable diagram title
statusstringGeneration status: "pending", "generating", "completed", "failed"
createdAtstringISO 8601 timestamp
updatedAtstringISO 8601 timestamp

Get Diagram

GET/api/diagrams/{id}read

Retrieves a specific diagram including the Mermaid code and metadata.

Path Parameters

ParameterTypeDescription
idrequiredstringThe diagram ID (UUID)

Example Request

curl "https://api.fegura.ai/api/diagrams/770e8400-e29b-41d4-a716-446655440000" \
  -H "Authorization: Bearer feg_live_your_api_key" \
  -H "Fegura-Version: 2026-02-01"

Response

{
  "success": true,
  "data": {
    "id": "770e8400-e29b-41d4-a716-446655440000",
    "scanJobId": "660e8400-e29b-41d4-a716-446655440000",
    "awsAccountId": "550e8400-e29b-41d4-a716-446655440000",
    "diagramType": "network",
    "title": "VPC Network Architecture",
    "status": "completed",
    "mermaidCode": "graph TB\n  subgraph VPC[vpc-123abc]\n    subgraph PublicSubnet[Public Subnet]\n      ALB[Application Load Balancer]\n    end\n    subgraph PrivateSubnet[Private Subnet]\n      ECS[ECS Service]\n      RDS[(RDS PostgreSQL)]\n    end\n  end\n  Internet --> ALB\n  ALB --> ECS\n  ECS --> RDS",
    "metadata": {
      "modelUsed": "claude-sonnet-4-20250514",
      "tokensUsed": 3420,
      "generationTimeMs": 8500
    },
    "errorMessage": null,
    "createdAt": "2026-01-20T14:32:00.000Z",
    "updatedAt": "2026-01-20T14:32:15.000Z"
  }
}

Additional Response Fields

ParameterTypeDescription
mermaidCodestringMermaid diagram code ready for rendering
metadataobjectAdditional context about the diagram
metadata.modelUsedstringAI model used to generate the diagram
metadata.tokensUsedinteger | undefinedNumber of tokens consumed during generation
metadata.generationTimeMsinteger | undefinedTime taken to generate the diagram in milliseconds

Diagram Types

TypeDescription
architectureHigh-level architecture with all resource types
networkVPCs, subnets, security groups, and connectivity
dataflowData movement between services and resources
boundarySecurity boundaries and trust zones
organizationOrganizational grouping of resources by service or team

Rendering Mermaid Diagrams

The mermaidCode field contains Mermaid syntax that can be rendered using the official Mermaid library or various third-party tools.

Client-Side Rendering

import mermaid from 'mermaid';

// Initialize Mermaid
mermaid.initialize({ startOnLoad: true, theme: 'dark' });

// Render the diagram
const element = document.getElementById('diagram');
const { svg } = await mermaid.render('diagram-svg', diagramData.mermaidCode);
element.innerHTML = svg;

Server-Side Rendering

For server-side rendering, you can use @mermaid-js/mermaid-cli to generate static images:

# Install the CLI
npm install -g @mermaid-js/mermaid-cli

# Generate PNG from Mermaid code
mmdc -i diagram.mmd -o diagram.png -t dark