> 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.

# Create a topology record

POST https://api.pensar.dev/topology/records
Content-Type: application/json

Add a boundary, component, flow, control or threat the map is missing. The body is keyed on `recordType`. References to other records are record ids, and each must exist and not be excluded, or the request is refused with `422` and `error: "unknown_reference"`.

The record is stored as asserted, attributed to the user or API key that made the request, and testing takes it into account from the next pentest.

Requires the `inventory:add` API key scope.

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

## 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

### Body (application/json)

This endpoint expects a CreateTopologyRecordRequest.

- `CreateTopologyRecordRequest`
  - CreateTopologyRecordRequest0
  - CreateTopologyRecordRequest1
  - CreateTopologyRecordRequest2
  - CreateTopologyRecordRequest3
  - CreateTopologyRecordRequest4

## Response

### 201

The created record and its first version.

- `record` (TopologyRecord, required) — 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.
- `version` (integer, required) — The version this write created.

## 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.

### 409 Conflict Error

The request conflicts with the current state of the resource.

- `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.

### 422 Unprocessable Entity Error

The request is well formed but refers to something that does not exist or is excluded. `error` is a stable code and `detail` explains it.

- `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

### CreateTopologyRecordRequest0

- `recordType` (enum, required)
  - Allowed values: `boundary`
- `kind` (enum, required)
  - Allowed values: `edge-network`, `cloud-account`, `region`, `vpc`, `subnet`, `third-party`, `user-device`
- `name` (string, required) — Unique boundary name, e.g. 'AWS production account', 'Console VPC', 'Private subnets'.
- `provider` (string, optional) — e.g. 'aws', 'cloudflare', 'gcp'.
- `description` (string, optional)
- `parent` (string, optional) — Id of the boundary this one sits inside, e.g. from GET /topology.
- `evidence` (list of CreateTopologyRecordRequestOneOf0EvidenceItems, optional) — Why the change is true. Kept on the record as asserted evidence.

### CreateTopologyRecordRequest1

- `recordType` (enum, required)
  - Allowed values: `component`
- `kind` (enum, required)
  - Allowed values: `application`, `client`, `entrypoint`, `compute`, `database`, `cache`, `queue`, `object-store`, `message-broker`, `proxy`, `identity-provider`, `llm-provider`, `saas`
- `name` (string, required) — Unique component name, e.g. 'Pensar Console (web)', 'Aurora PostgreSQL', 'api.example.com'.
- `tech` (string, optional) — Technology, e.g. 'Next.js 16 on Lambda', 'Aurora PostgreSQL 16 behind RDS Proxy'.
- `exposure` (enum, optional) — public = reachable from the internet; private = only from inside its boundary.
  - Allowed values: `public`, `private`, `unknown`
- `endpoints` (list of string, optional) — Hostnames or URLs it answers on; for a client, the URL schemes and app links it handles (e.g. 'example://pay').
- `repository` (string, optional) — Connected repository whose source backs or defines this component, when confirmed by reading it.
- `description` (string, optional)
- `atStake` (string, optional) — What this component holds or does that is worth attacking — the data, credentials, privileges, money, or trust an attacker gains by compromising it. Concrete, not generic.
- `trustAssumptions` (list of string, optional) — What this component trusts without verifying: callers in a security group, a header set by a proxy, a token's claims, content it ingests, an upstream service. One assumption per entry; empty only when it truly trusts nothing.
- `businessLogic` (string, optional) — For applications: what it does, its actors, and its sensitive operations, fusing wire observations with source. Markdown.
- `members` (list of string, optional) — For a collapsed group (e.g. 12 queues), the member names.
- `boundary` (string, optional) — Id of the boundary it lives in, e.g. from GET /topology.
- `usedBy` (list of string, optional)
- `evidence` (list of CreateTopologyRecordRequestOneOf1EvidenceItems, optional) — Why the change is true. Kept on the record as asserted evidence.

### CreateTopologyRecordRequest2

- `recordType` (enum, required)
  - Allowed values: `flow`
- `from` (string, required) — Id of the component traffic originates from, e.g. from GET /topology.
- `to` (string, required) — Id of the component it reaches, e.g. from GET /topology.
- `label` (string, required) — Short protocol or purpose, e.g. 'HTTPS', 'RDS Proxy', 'enqueue jobs'.
- `evidence` (list of CreateTopologyRecordRequestOneOf2EvidenceItems, optional) — Why the change is true. Kept on the record as asserted evidence.

### CreateTopologyRecordRequest3

- `recordType` (enum, required)
  - Allowed values: `control`
- `kind` (enum, required)
  - Allowed values: `waf`, `ip-allowlist`, `geo-block`, `security-group`, `network-isolation`, `origin-secret`, `authentication`, `authorization`, `tenant-isolation`, `rate-limit`, `encryption`, `secret-management`, `iam-policy`, `input-validation`, `logging`
- `name` (string, required) — Unique control name, e.g. 'API WAF', 'Aurora security group', 'Workspace authorization in server actions'.
- `protects` (string, required) — What it is meant to stop or guarantee, concretely.
- `appliesTo` (list of string, required)
- `gaps` (string, optional) — Where it does not apply, what can route around it, what it trusts, or weaknesses observed. Omit only when you found none.
- `evidence` (list of CreateTopologyRecordRequestOneOf3EvidenceItems, optional) — Why the change is true. Kept on the record as asserted evidence.

### CreateTopologyRecordRequest4

- `recordType` (enum, required)
  - Allowed values: `threat`
- `category` (enum, required)
  - Allowed values: `spoofing`, `tampering`, `repudiation`, `information-disclosure`, `denial-of-service`, `elevation-of-privilege`
- `severity` (enum, required) — How bad it is if it holds, from the impact: critical for cross-tenant data, account takeover, or code execution; high for one tenant's sensitive data or privileged actions; medium for limited data or abuse; low for minor disclosure.
  - Allowed values: `critical`, `high`, `medium`, `low`
- `component` (string, required) — Id of the component the threat targets, e.g. from GET /topology.
- `title` (string, required) — Short, specific title, unique within the component, e.g. 'Read any account through legacy v1 IDs'.
- `entryPoint` (string, required) — Where the attack starts, concretely enough to send a request to: a host plus method and route, and the parameter, header, cookie, or field involved — e.g. 'POST https://app.example.com/api/v1/orders, body.accountId'. For a non-HTTP surface: the queue, bucket, function URL, or API call.
- `scenario` (string, required) — Who does what, through which entry point and flow, exploiting which trust assumption or control gap, with what result — concrete to this system.
- `attackSteps` (list of string, required) — The attack in order, one action per step, as a tester would carry it out: what to request or do, with which values, and what each step yields for the next.
- `impact` (string, required) — What is lost and how widely: whose data, which privileges, how much money or availability.
- `preconditions` (list of string, optional) — What the attacker needs: network position, an account, a leaked key, a victim action. Empty when anyone on the internet can do it.
- `likelihood` (enum, optional)
  - Allowed values: `low`, `medium`, `high`
- `likelihoodRationale` (string, optional) — Why that likelihood: exposure, ease, what stands in the way, whether it was confirmed.
- `verification` (string, optional) — How a pentest confirms it without causing harm: the request(s) to send and the response, data, or side effect that proves the threat holds — and what result shows it does not.
- `controls` (list of string, optional)
- `evidence` (list of CreateTopologyRecordRequestOneOf4EvidenceItems, optional) — Why the change is true. Kept on the record as asserted evidence.

### 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.

### CreateTopologyRecordRequestOneOf0EvidenceItems

- `detail` (string, required) — What was asserted and why it can be trusted.
- `ref` (string, optional) — A file path, URL or ticket the claim comes from.

### CreateTopologyRecordRequestOneOf1EvidenceItems

- `detail` (string, required) — What was asserted and why it can be trusted.
- `ref` (string, optional) — A file path, URL or ticket the claim comes from.

### CreateTopologyRecordRequestOneOf2EvidenceItems

- `detail` (string, required) — What was asserted and why it can be trusted.
- `ref` (string, optional) — A file path, URL or ticket the claim comes from.

### CreateTopologyRecordRequestOneOf3EvidenceItems

- `detail` (string, required) — What was asserted and why it can be trusted.
- `ref` (string, optional) — A file path, URL or ticket the claim comes from.

### CreateTopologyRecordRequestOneOf4EvidenceItems

- `detail` (string, required) — What was asserted and why it can be trusted.
- `ref` (string, optional) — A file path, URL or ticket the claim comes from.

### 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

**Request**

```json
{
  "kind": "edge-network",
  "name": "string",
  "recordType": "boundary"
}
```

**Response**

```json
{
  "record": {
    "id": "cmp_8f2a1c0d33",
    "recordType": "boundary",
    "provenance": "agent",
    "updatedAt": "2024-01-15T09:30:00Z",
    "assertedBy": {
      "type": "user",
      "id": "string",
      "name": "string",
      "createdBy": "string"
    },
    "excluded": true,
    "excludedReason": "string",
    "applicationId": "string"
  },
  "version": 1
}
```

**SDK Code**

```python
import requests

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

payload = {
    "kind": "edge-network",
    "name": "string",
    "recordType": "boundary"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.pensar.dev/topology/records';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"kind":"edge-network","name":"string","recordType":"boundary"}'
};

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"
	"strings"
	"net/http"
	"io"
)

func main() {

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

	payload := strings.NewReader("{\n  \"kind\": \"edge-network\",\n  \"name\": \"string\",\n  \"recordType\": \"boundary\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	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/records")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"kind\": \"edge-network\",\n  \"name\": \"string\",\n  \"recordType\": \"boundary\"\n}"

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.post("https://api.pensar.dev/topology/records")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"kind\": \"edge-network\",\n  \"name\": \"string\",\n  \"recordType\": \"boundary\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.pensar.dev/topology/records', [
  'body' => '{
  "kind": "edge-network",
  "name": "string",
  "recordType": "boundary"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.pensar.dev/topology/records");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"kind\": \"edge-network\",\n  \"name\": \"string\",\n  \"recordType\": \"boundary\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "kind": "edge-network",
  "name": "string",
  "recordType": "boundary"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

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

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()
```