---
url: /api/docs/bgp.md
---
# BGP monitoring

Manage the resources (ASes and prefixes) monitored by PacketVis for your organization.

## Getting started

1. [Generate an API key](https://packetvis.com/settings/apikeys) (see [Authentication](/docs/authentication)).
2. Build the request URL. Replace `YOUR_API_KEY` in the examples with your API key.

The `POST`, `PUT`, and `DELETE` endpoints require an API key with write access.

## List monitored resources

Returns all the ASes and prefixes monitored by your organization.

### Parameters

| Name  | Description  | Default |
|-------|--------------|---------|
| `key` | The API key. |         |

### Response

200 OK

```json
{
  "data": [
    {
      "asn": 64496,
      "excludeMonitors": [],
      "active": true,
      "monitorDownstreams": true,
      "monitorUpstreams": true,
      "downstreams": [],
      "upstreams": [],
      "suspensionReasons": [],
      "createdAt": "2025-01-10T09:12:41.981Z",
      "updatedAt": "2025-01-10T09:12:41.981Z"
    },
    {
      "prefix": "203.0.113.0/24",
      "asn": [64496],
      "description": "web service",
      "ignoreMorespecifics": false,
      "ignore": false,
      "excludeMonitors": [],
      "active": true,
      "suspensionReasons": [],
      "visible": true,
      "lastVisibilityCheck": "2025-01-10T10:00:00.000Z",
      "createdAt": "2025-01-10T09:12:42.101Z",
      "updatedAt": "2025-01-10T10:00:00.000Z"
    }
  ],
  "metadata": {}
}
```

Each item is either an AS or a prefix. Prefix items include the `prefix` field.

**Prefix fields**

| Field | Type | Description |
|-------|------|-------------|
| `prefix` | string | The monitored prefix (CIDR). |
| `asn` | integer\[] | The list of expected origin ASes. |
| `description` | string | A free-text description. |
| `ignore` | boolean | Whether the prefix is ignored (no alerts are generated). |
| `ignoreMorespecifics` | boolean | Whether more-specific prefixes are ignored. |
| `visible` | boolean | Whether the prefix is currently visible in the global routing table. |
| `lastVisibilityCheck` | string (ISO 8601) | When the visibility was last checked. |
| `excludeMonitors` | string\[] | The list of monitors excluded from the monitoring of this resource. See [List available monitors](#list-available-monitors). |
| `active` | boolean | Whether the monitoring is active. |
| `suspensionReasons` | string\[] | The reasons why the monitoring is suspended, if any. |
| `createdAt` | string (ISO 8601) | When the resource was created. |
| `updatedAt` | string (ISO 8601) | When the resource was last updated. |

**AS fields**

| Field | Type | Description |
|-------|------|-------------|
| `asn` | integer | The AS number. |
| `downstreams` | integer\[] | The expected downstream ASes. |
| `upstreams` | integer\[] | The expected upstream ASes. |
| `monitorDownstreams` | boolean | Whether the addition/removal of downstreams is monitored. |
| `monitorUpstreams` | boolean | Whether the addition/removal of upstreams is monitored.|
| `excludeMonitors` | string\[] | The list of monitors excluded from the monitoring of this resource. See [List available monitors](#list-available-monitors). |
| `active` | boolean | Whether the monitoring is active. |
| `suspensionReasons` | string\[] | The reasons why the monitoring is suspended, if any. |
| `createdAt` | string (ISO 8601) | When the resource was created. |
| `updatedAt` | string (ISO 8601) | When the resource was last updated. |

The response is cached for up to 30 seconds.

## Monitor a new Autonomous System

Starts monitoring a new AS.

### Parameters

| Name  | Description                             | Default |
|-------|-----------------------------------------|---------|
| `key` | The API key. It must have write access. |         |

### Request body

```json
{
  "asn": 64496,
  "name": "Example Network",
  "tag": "isp"
}
```

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `asn` | integer | yes | The AS number. |
| `name` | string | yes | A name for the AS. |
| `tag` | string | yes | A tag for the AS. Possible tags are: `tier1`, `tier2`, `isp`, `cdn`, `content`, `hosting`, `rir`, `nren`, `ixp`, `university`, `enterprise`, `government`, `personal` |

PacketVis schedules the monitoring of the AS and generates its prefixes asynchronously.

> The request fails if the AS is already monitored. To edit an already monitored AS, use [PUT](#edit-resources).

### Response

200 OK

The `data` object contains the saved resource, with the fields described in [List monitored resources](#list-monitored-resources).

## Edit resources

Edits an AS already monitored, and adds or edits prefixes. The request body describes a single resource. If the body contains `prefix`, the resource is a prefix, otherwise it is an AS. For existing resources, only the fields you send are changed.

### Parameters

| Name  | Description                             | Default |
|-------|-----------------------------------------|---------|
| `key` | The API key. It must have write access. |         |

### Request body

To add or edit a prefix:

```json
{
  "prefix": "203.0.113.0/24",
  "asn": [64496],
  "description": "web service",
  "ignoreMorespecifics": false,
  "ignore": false,
  "excludeMonitors": []
}
```

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `prefix` | string | yes | The prefix (CIDR). |
| `asn` | integer\[] | yes | The list of expected origin ASes. |
| `description` | string | no | A free-text description. |
| `ignore` | boolean | no | Whether the prefix is ignored (no alerts are generated). |
| `ignoreMorespecifics` | boolean | no | Whether more-specific prefixes are ignored. |
| `excludeMonitors` | string\[] | no | The list of monitors excluded from the monitoring of this prefix. Allowed values: the `prefix` monitors in [List available monitors](#list-available-monitors). |

To edit an AS:

```json
{
    "asn": 64496,
    "downstreams": [
        64500
    ],
    "upstreams": [
        64510
    ],
    "monitorDownstreams": true,
    "monitorUpstreams": true,
    "excludeMonitors": []
}
```

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `asn` | integer | yes | The AS number. |
| `downstreams` | integer\[] | no | The expected downstream ASes. |
| `upstreams` | integer\[] | no | The expected upstream ASes. |
| `monitorDownstreams` | boolean | no | Whether the downstreams are monitored. |
| `monitorUpstreams` | boolean | no | Whether the upstreams are monitored. |
| `excludeMonitors` | string\[] | no | The list of monitors excluded from the monitoring of this AS. Allowed values: the `asn` monitors in [List available monitors](#list-available-monitors). |

Notes:

* Fields that are managed by PacketVis (`active`, `suspensionReasons`, `visible`, `lastVisibilityCheck`, `createdAt`, `updatedAt`) are ignored if sent.
* Unknown fields, and fields of the wrong resource type (e.g., `ignore` on an AS), are rejected.
* Editing an AS fails if the AS is not already monitored: use [POST](#monitor-a-new-autonomous-system) to start monitoring it.

### Response

200 OK

```json
{
    "data": {
        "prefix": "203.0.113.0/24",
        "asn": [
            64496
        ],
        "description": "web service",
        "ignoreMorespecifics": false,
        "ignore": false,
        "excludeMonitors": [],
        "active": true,
        "suspensionReasons": [],
        "createdAt": "2025-01-10T09:12:42.101Z"
    },
    "metadata": {}
}
```

The `data` object contains the saved resource, with the fields described in [List monitored resources](#list-monitored-resources).

## Delete a resource

Stops monitoring an AS or a prefix. Deleting an AS also deletes all the prefixes associated with it.

### Parameters

| Name       | In    | Description                                                                                                          | Default |
|------------|-------|----------------------------------------------------------------------------------------------------------------------|---------|
| `key`      | query | The API key. It must have write access.                                                                              |         |

### Response

200 OK

```json
{
  "data": {
    "deleted": true
  },
  "metadata": {}
}
```

## List available monitors

Returns the monitors available for each resource type. The names returned are the ones that can be used in the `excludeMonitors` array of an AS or of a prefix.

### Parameters

| Name  | Description  | Default |
|-------|--------------|---------|
| `key` | The API key. |         |

### Response

200 OK

```json
{
  "data": {
    "asn": [
      "neighbors",
      "misconfiguration",
      "rpki-invalid",
      "rpki-unknown",
      "roa-diff",
      "roa-expire",
      "bogons",
      "upstreams-visibility",
      "upstreams-availability"
    ],
    "prefix": [
      "visibility",
      "hijack",
      "newprefix",
      "rpki-invalid",
      "rpki-unknown",
      "roa-expire"
    ]
  },
  "metadata": {}
}
```

| Field | Type | Description |
|-------|------|-------------|
| `asn` | string\[] | The monitors available for ASes. |
| `prefix` | string\[] | The monitors available for prefixes. |

## Get the alerts

PacketVis does not have a BGP-specific alerts endpoint. All the services, BGP monitoring included, deliver their alerts through the generic notifications endpoint:

To receive only the notifications produced by the BGP monitoring, filter by service using `services=bgp`:

You can further narrow the results with the `types` parameter (e.g., `types=hijack`). The BGP notification types, the other parameters, and the response format are described in the [Notifications](/docs/notifications.html) documentation.

Also, read about [interactive monitoring and integrations](https://packetvis.com/blog/interactive-monitoring/)
