> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.pensar.dev/console/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.pensar.dev/console/_mcp/server.

# Get the topology

GET https://api.pensar.dev/topology

The system map: boundaries, components, flows, controls and threats, with what recon found and what people asserted. Excluded records are left out, as are flows and threats that hang off an excluded component.

Filter by `recordType`, by `boundary` (that boundary, what sits inside it, and what attaches to those), or by `applicationId` (its component and what attaches to it). Results are ordered and paged with `cursor`. With `format=mermaid` the selection comes back as one flowchart, with boundaries as subgraphs, components as nodes and flows as edges; paging is ignored.

Only available for workspaces using the topology view; others receive `404`.

Requires the `inventory:read` API key scope.

Reference: https://docs.pensar.dev/console/api/api-reference/topology/get-topology

## Authentication

- `Authorization` header (bearer token, required) — A workspace API key, sent as `Authorization: Bearer`.
- `x-api-key` header (required) — A workspace API key, sent as `x-api-key`.

## Request

### Query parameters

- `recordType` (enum, optional)
  - Allowed values: `boundary`, `component`, `flow`, `control`, `threat`
- `boundary` (string, optional) — A boundary record id.
- `applicationId` (string, optional)
- `cursor` (string, optional) — `nextCursor` from the previous page.
- `limit` (integer, optional) — Page size. Defaults to 100.
- `format` (enum, optional)
  - Allowed values: `json`, `mermaid`

## Response

### 200

A page of records, or a Mermaid flowchart.

- `TopologyResponse`
  - TopologyPage: TopologyPage
  - TopologyMermaid: TopologyMermaid

## Errors

### 400 Bad Request Error

The request is invalid. `error` describes the problem.

- `error` (string, required) — What went wrong, naming the offending value when useful.
- `detail` (string, optional) — On the topology routes, a refused request names a stable `error` code (`insufficient_scope` or `unknown_reference`) and explains it here.

### 401 Unauthorized Error

The API key is missing or invalid.

- `error` (string, required) — What went wrong, naming the offending value when useful.
- `detail` (string, optional) — On the topology routes, a refused request names a stable `error` code (`insufficient_scope` or `unknown_reference`) and explains it here.

### 403 Forbidden Error

The credential lacks the required scope or is not allowed this action.

- `error` (string, required) — What went wrong, naming the offending value when useful.
- `detail` (string, optional) — On the topology routes, a refused request names a stable `error` code (`insufficient_scope` or `unknown_reference`) and explains it here.

### 404 Not Found Error

The resource does not exist in this workspace.

- `error` (string, required) — What went wrong, naming the offending value when useful.
- `detail` (string, optional) — On the topology routes, a refused request names a stable `error` code (`insufficient_scope` or `unknown_reference`) and explains it here.

## Types

### TopologyPage

- `run` (TopologyRun, required, nullable) — The system recon run the map was last refreshed by.
- `records` (list of TopologyRecord, required)
- `nextCursor` (string, required, nullable) — Pass as `cursor` for the next page; null at the end.

### TopologyMermaid

- `run` (TopologyRun, required, nullable) — The system recon run the map was last refreshed by.
- `format` (enum, required)
  - Allowed values: `mermaid`
- `mermaid` (string, required) — A Mermaid flowchart.

### TopologyRun

The system recon run the map was last refreshed by.

- `id` (string, required)
- `completedAt` (datetime, required, nullable)
- `trigger` (string, required, nullable) — What started the run.

### TopologyRecord

A record of the map. Beyond these fields it carries those of its `recordType`: `name`, `kind` and, depending on the type, `boundary`, `exposure`, `endpoints`, `tech`, `from`, `to`, `label`, `appliesTo`, `gaps`, `component`, `title`, `severity` and so on. References to other records are record ids.

- `id` (string, required)
- `recordType` (enum, required)
  - Allowed values: `boundary`, `component`, `flow`, `control`, `threat`
- `provenance` (enum, required) — Whether recon found it or a person told us.
  - Allowed values: `agent`, `asserted`
- `updatedAt` (datetime, required)
- `assertedBy` (TopologyAssertedBy, optional)
- `excluded` (boolean, optional)
- `excludedReason` (string, optional)
- `applicationId` (string, optional) — For a component, the application that tests it.

### TopologyAssertedBy

- `type` (enum, required)
  - Allowed values: `user`, `apiKey`
- `id` (string, required)
- `name` (string, required)
- `createdBy` (string, optional) — For an API key, the user who created it.

## Examples

**Response**

```json
{
  "nextCursor": "string",
  "records": [
    {
      "applicationId": "string",
      "assertedBy": {
        "createdBy": "string",
        "id": "string",
        "name": "string",
        "type": "user"
      },
      "excluded": true,
      "excludedReason": "string",
      "id": "cmp_8f2a1c0d33",
      "provenance": "agent",
      "recordType": "boundary",
      "updatedAt": "2024-01-15T09:30:00Z"
    }
  ],
  "run": {
    "completedAt": "2024-01-15T09:30:00Z",
    "id": "string",
    "trigger": "schedule"
  }
}
```

**SDK Code**

```python
import requests

url = "https://api.pensar.dev/topology"

headers = {"Authorization": "Bearer <token>"}

response = requests.get(url, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.pensar.dev/topology';
const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api.pensar.dev/topology"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("Authorization", "Bearer <token>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.pensar.dev/topology")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://api.pensar.dev/topology")
  .header("Authorization", "Bearer <token>")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.pensar.dev/topology', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.pensar.dev/topology");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Authorization": "Bearer <token>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.pensar.dev/topology")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```