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

# Restore a record version

POST https://api.pensar.dev/topology/records/{recordId}/versions/{version}/restore

Makes an earlier version the record again, as a new version, so the history stays complete. Undoes an edit or an exclusion.

Requires the `inventory:write` API key scope.

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

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

### Path parameters

- `recordId` (string, required) — Topology record id, e.g. `cmp_8f2a1c0d33`.
- `version` (string, required) — Version number from List record versions, starting at 1.

## Response

### 200

The restored record and the version that restored it.

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

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

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

### 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
{
  "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/recordId/versions/version/restore"

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

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

print(response.json())
```

```javascript
const url = 'https://api.pensar.dev/topology/records/recordId/versions/version/restore';
const options = {method: 'POST', 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/records/recordId/versions/version/restore"

	req, _ := http.NewRequest("POST", 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/records/recordId/versions/version/restore")

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

request = Net::HTTP::Post.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.post("https://api.pensar.dev/topology/records/recordId/versions/version/restore")
  .header("Authorization", "Bearer <token>")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.pensar.dev/topology/records/recordId/versions/version/restore', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.pensar.dev/topology/records/recordId/versions/version/restore");
var request = new RestRequest(Method.POST);
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/records/recordId/versions/version/restore")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
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()
```