> ## Documentation Index
> Fetch the complete documentation index at: https://docs.megaport.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Managing BMP Export Targets with the API

> This help topic describes how to use the Megaport API to manage BMP export targets on MCRs and NAT Gateways.

This topic describes the API procedure to manage BMP export targets on Megaport Cloud Router (MCR) and Megaport NAT Gateway (NAT Gateway) services.

BMP Glossary BMP BMP (BGP Monitoring Protocol) is an IETF standard protocol (RFC 7854) used to monitor BGP sessions. It provides a way for a router to send BGP routing information to a monitoring station known as a collector. This can include the contents of its Adj-RIB-In (the routes received from BGP peers) and BGP peer session state. BMP is commonly used for route monitoring, troubleshooting, and analysis of BGP routing behavior. export streams BGP session state and statistics from the MCR or NAT Gateway to an external BMP collector over a persistent TCP connection. Optionally, it also exports routing information (post-policy Adj-RIB-In for the IPv4 unicast and IPv6 unicast address families).

Each MCR or NAT Gateway supports up to 3 BMP export targets.

Before you begin, obtain a valid access token. For more information, see [Creating an API Key](https://docs.megaport.com/api/api-key.md).

## MCR BMP export target endpoints

Each MCR BMP export target description must be unique on the service.

### Creating a BMP export target

To create a BMP export target on an MCR, send a POST request with the target configuration.

**Endpoint**

```http theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
POST {baseUrl}/v2/product/mcr2/{productUid}/bmpExport
```

**Path Parameters**

| Parameter | Description |
| :- | :- |
| productUid | The unique identifier (UUID) of the MCR. |

**Request Body**

| Field | Required | Description |
| :- | :- | :- |
| description | Yes | A human-readable label for this BMP export target. 1-100 characters. |
| targetIpAddress | Yes | The IPv4 or IPv6 address of the BMP collector. Must be a valid IP address literal; DNS hostnames are not supported. Cannot be a loopback, multicast, or unspecified address. |
| targetPort | Yes | The TCP port of the BMP collector. Valid range: 1-65535. |
| exportRib | No | When `true`, the MCR exports the post-policy `Adj-RIB-In` state for the IPv4 unicast and IPv6 unicast address families in addition to BGP session state. When `false`, only BGP session state and statistics are exported. Default: `false`. |
| statsInterval | No | The interval in seconds at which BGP statistics are exported (the **Export Interval** field in the Portal). Valid range: 60-900. Default: `300`. |
| sourceIpAddress | No | The source IP address on the MCR for the BMP TCP connection. This is the **Local IP Address** field in the Portal BMP Export configuration. Must be an IPv4 or IPv6 address configured on the MCR, in the same address family as `targetIpAddress`. If omitted, the MCR uses its default source address. |

**Example Request**

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
    "description": "primary-collector",
    "targetIpAddress": "192.0.2.1",
    "targetPort": 5000,
    "exportRib": false,
    "statsInterval": 300,
    "sourceIpAddress": "10.1.1.1"
}
```

**Example Response**

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
    "message": "Created a new BMP export target for MCR",
    "terms": "This data is subject to the Acceptable Use Policy https://www.megaport.com/legal/acceptable-use-policy",
    "data": {
        "id": 67890,
        "description": "primary-collector",
        "targetIpAddress": "192.0.2.1",
        "targetPort": 5000,
        "exportRib": false,
        "statsInterval": 300,
        "sourceIpAddress": "10.1.1.1"
    }
}
```

### Getting a BMP export target

Retrieve a specific BMP export target by its ID.

**Endpoint**

```http theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
GET {baseUrl}/v2/product/mcr2/{productUid}/bmpExport/{bmpExportId}
```

**Path Parameters**

| Parameter | Description |
| :- | :- |
| productUid | The unique identifier (UUID) of the MCR. |
| bmpExportId | The unique identifier (integer) of the BMP export target. |

**Example Request**

```http theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
GET {baseUrl}/v2/product/mcr2/232a6022-79ad-4d41-a9e7-6e9930fa3feb/bmpExport/67890
```

**Example Response**

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
    "message": "BMP export target details",
    "terms": "This data is subject to the Acceptable Use Policy https://www.megaport.com/legal/acceptable-use-policy",
    "data": {
        "id": 67890,
        "description": "primary-collector",
        "targetIpAddress": "192.0.2.1",
        "targetPort": 5000,
        "exportRib": false,
        "statsInterval": 300,
        "sourceIpAddress": "10.1.1.1"
    }
}
```

### Updating a BMP export target

Update an existing BMP export target configuration.

**Endpoint**

```http theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
PUT {baseUrl}/v2/product/mcr2/{productUid}/bmpExport/{bmpExportId}
```

**Path Parameters**

| Parameter | Description |
| :- | :- |
| productUid | The unique identifier (UUID) of the MCR. |
| bmpExportId | The unique identifier (integer) of the BMP export target to update. |

**Request Body**

The request body uses the same fields as the create request.

| Field | Required | Description |
| :- | :- | :- |
| description | Yes | A human-readable label for this BMP export target. 1-100 characters. |
| targetIpAddress | Yes | The IPv4 or IPv6 address of the BMP collector. Must be a valid IP address literal; DNS hostnames are not supported. Cannot be a loopback, multicast, or unspecified address. |
| targetPort | Yes | The TCP port of the BMP collector. Valid range: 1-65535. |
| exportRib | No | When `true`, the MCR exports the post-policy `Adj-RIB-In` state for the IPv4 unicast and IPv6 unicast address families in addition to BGP session state. When `false`, only BGP session state and statistics are exported. Default: `false`. |
| statsInterval | No | The interval in seconds at which BGP statistics are exported (the **Export Interval** field in the Portal). Valid range: 60-900. Default: `300`. |
| sourceIpAddress | No | The source IP address on the MCR for the BMP TCP connection. This is the **Local IP Address** field in the Portal BMP Export configuration. Must be an IPv4 or IPv6 address configured on the MCR, in the same address family as `targetIpAddress`. If omitted, the MCR uses its default source address. |

> [!NOTE]
>
> The update request fully replaces the target's configuration. Omitted optional fields revert to their default values, and omitting `sourceIpAddress` clears a previously set source address.

**Example Request**

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
    "description": "primary-collector",
    "targetIpAddress": "192.0.2.1",
    "targetPort": 5000,
    "exportRib": true,
    "statsInterval": 600,
    "sourceIpAddress": "10.1.1.1"
}
```

**Example Response**

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
    "message": "Updated BMP export target",
    "terms": "This data is subject to the Acceptable Use Policy https://www.megaport.com/legal/acceptable-use-policy",
    "data": {
        "id": 67890,
        "description": "primary-collector",
        "targetIpAddress": "192.0.2.1",
        "targetPort": 5000,
        "exportRib": true,
        "statsInterval": 600,
        "sourceIpAddress": "10.1.1.1"
    }
}
```

### Deleting a BMP export target

Delete a specific BMP export target from an MCR.

> [!NOTE]
>
> A BMP export target can be deleted even if it is still in use by the MCR.

**Endpoint**

```http theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
DELETE {baseUrl}/v2/product/mcr2/{productUid}/bmpExport/{bmpExportId}
```

**Path Parameters**

| Parameter | Description |
| :- | :- |
| productUid | The unique identifier (UUID) of the MCR. |
| bmpExportId | The unique identifier (integer) of the BMP export target to delete. |

**Example Request**

```http theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
DELETE {baseUrl}/v2/product/mcr2/232a6022-79ad-4d41-a9e7-6e9930fa3feb/bmpExport/67890
```

**Example Response**

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
    "message": "BMP export target '67890' deleted successfully",
    "terms": "This data is subject to the Acceptable Use Policy https://www.megaport.com/legal/acceptable-use-policy"
}
```

### Listing BMP export targets

Retrieve all BMP export targets configured on an MCR.

**Endpoint**

```http theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
GET {baseUrl}/v2/product/mcr2/{productUid}/bmpExports
```

**Path Parameters**

| Parameter | Description |
| :- | :- |
| productUid | The unique identifier (UUID) of the MCR. |

**Example Request**

```http theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
GET {baseUrl}/v2/product/mcr2/232a6022-79ad-4d41-a9e7-6e9930fa3feb/bmpExports
```

**Example Response**

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
    "message": "List BMP export targets for MCR",
    "terms": "This data is subject to the Acceptable Use Policy https://www.megaport.com/legal/acceptable-use-policy",
    "data": [
        {
            "id": 67890,
            "description": "primary-collector",
            "targetIpAddress": "192.0.2.1",
            "targetPort": 5000,
            "exportRib": true,
            "statsInterval": 600,
            "sourceIpAddress": "10.1.1.1"
        },
        {
            "id": 67891,
            "description": "secondary-collector",
            "targetIpAddress": "192.0.2.2",
            "targetPort": 5000,
            "exportRib": false,
            "statsInterval": 300,
            "sourceIpAddress": "10.1.1.2"
        }
    ]
}
```

## NAT Gateway BMP export target endpoints

Each NAT Gateway target's description must be unique on the service.

### Creating a BMP export target

To create a BMP export target on a NAT Gateway, send a POST request with the target configuration.

**Endpoint**

```http theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
POST {baseUrl}/v3/products/nat_gateways/{productUid}/bmp_exports
```

**Path Parameters**

| Parameter | Description |
| :- | :- |
| productUid | The unique identifier (UUID) of the NAT Gateway. |

**Request Body**

| Field | Required | Description |
| :- | :- | :- |
| description | Yes | A human-readable label for this BMP export target. 1-100 characters. |
| targetIpAddress | Yes | The IPv4 or IPv6 address of the BMP collector. Must be a valid IP address literal; DNS hostnames are not supported. Cannot be a loopback, multicast, or unspecified address. |
| targetPort | Yes | The TCP port of the BMP collector. Valid range: 1-65535. |
| exportRib | No | When `true`, the NAT Gateway exports post-policy Adj-RIB-In state for the IPv4 unicast and IPv6 unicast address families in addition to BGP session state. When `false`, only BGP session state and statistics are exported. Default: `false`. |
| statsInterval | No | The interval in seconds at which BGP statistics are exported (the **Export Interval** field in the Portal). Valid range: 60-900. Default: `300`. |
| sourceIpAddress | No | The source IP address on the NAT Gateway for the BMP TCP connection. This is the **Local IP Address** field in the Portal BMP Export configuration. Must be an IPv4 or IPv6 address configured on the NAT Gateway, in the same address family as `targetIpAddress`. If omitted, the NAT Gateway uses its default source address. |

**Example Request**

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
    "description": "primary-collector",
    "targetIpAddress": "192.0.2.1",
    "targetPort": 5000,
    "exportRib": false,
    "statsInterval": 300,
    "sourceIpAddress": "10.1.1.1"
}
```

**Example Response**

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
    "message": "Created a new BMP export target for NAT Gateway",
    "terms": "This data is subject to the Acceptable Use Policy https://www.megaport.com/legal/acceptable-use-policy",
    "data": {
        "id": 67890,
        "description": "primary-collector",
        "targetIpAddress": "192.0.2.1",
        "targetPort": 5000,
        "exportRib": false,
        "statsInterval": 300,
        "sourceIpAddress": "10.1.1.1"
    }
}
```

### Getting a BMP export target

Retrieve a specific BMP export target by its ID.

**Endpoint**

```http theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
GET {baseUrl}/v3/products/nat_gateways/{productUid}/bmp_exports/{bmpExportId}
```

**Path Parameters**

| Parameter | Description |
| :- | :- |
| productUid | The unique identifier (UUID) of the NAT Gateway. |
| bmpExportId | The unique identifier (integer) of the BMP export target. |

**Example Request**

```http theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
GET {baseUrl}/v3/products/nat_gateways/7f5f9574-315e-4527-af44-122605a411ef/bmp_exports/67890
```

**Example Response**

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
    "message": "BMP export target details",
    "terms": "This data is subject to the Acceptable Use Policy https://www.megaport.com/legal/acceptable-use-policy",
    "data": {
        "id": 67890,
        "description": "primary-collector",
        "targetIpAddress": "192.0.2.1",
        "targetPort": 5000,
        "exportRib": false,
        "statsInterval": 300,
        "sourceIpAddress": "10.1.1.1"
    }
}
```

### Updating a BMP export target

Update an existing BMP export target configuration.

**Endpoint**

```http theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
PUT {baseUrl}/v3/products/nat_gateways/{productUid}/bmp_exports/{bmpExportId}
```

**Path Parameters**

| Parameter | Description |
| :- | :- |
| productUid | The unique identifier (UUID) of the NAT Gateway. |
| bmpExportId | The unique identifier (integer) of the BMP export target to update. |

**Request Body**

The request body uses the same fields as the create request.

| Field | Required | Description |
| :- | :- | :- |
| description | Yes | A human-readable label for this BMP export target. 1-100 characters. |
| targetIpAddress | Yes | The IPv4 or IPv6 address of the BMP collector. Must be a valid IP address literal; DNS hostnames are not supported. Cannot be a loopback, multicast, or unspecified address. |
| targetPort | Yes | The TCP port of the BMP collector. Valid range: 1-65535. |
| exportRib | No | When `true`, the NAT Gateway exports post-policy Adj-RIB-In state for the IPv4 unicast and IPv6 unicast address families in addition to BGP session state. When `false`, only BGP session state and statistics are exported. Default: `false`. |
| statsInterval | No | The interval in seconds at which BGP statistics are exported (the **Export Interval** field in the Portal). Valid range: 60-900. Default: `300`. |
| sourceIpAddress | No | The source IP address on the NAT Gateway for the BMP TCP connection. This is the **Local IP Address** field in the Portal BMP Export configuration. Must be an IPv4 or IPv6 address configured on the NAT Gateway, in the same address family as `targetIpAddress`. If omitted, the NAT Gateway uses its default source address. |

> [!NOTE]
>
> The update request fully replaces the target's configuration. Omitted optional fields revert to their default values, and omitting `sourceIpAddress` clears a previously set source address.

**Example Request**

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
    "description": "primary-collector",
    "targetIpAddress": "192.0.2.1",
    "targetPort": 5000,
    "exportRib": true,
    "statsInterval": 600,
    "sourceIpAddress": "10.1.1.1"
}
```

**Example Response**

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
    "message": "Updated BMP export target",
    "terms": "This data is subject to the Acceptable Use Policy https://www.megaport.com/legal/acceptable-use-policy",
    "data": {
        "id": 67890,
        "description": "primary-collector",
        "targetIpAddress": "192.0.2.1",
        "targetPort": 5000,
        "exportRib": true,
        "statsInterval": 600,
        "sourceIpAddress": "10.1.1.1"
    }
}
```

### Deleting a BMP export target

Delete a specific BMP export target from a NAT Gateway.

> [!NOTE]
>
> A BMP export target can be deleted even if it is still in use by the NAT Gateway.

**Endpoint**

```http theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
DELETE {baseUrl}/v3/products/nat_gateways/{productUid}/bmp_exports/{bmpExportId}
```

**Path Parameters**

| Parameter | Description |
| :- | :- |
| productUid | The unique identifier (UUID) of the NAT Gateway. |
| bmpExportId | The unique identifier (integer) of the BMP export target to delete. |

**Example Request**

```http theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
DELETE {baseUrl}/v3/products/nat_gateways/7f5f9574-315e-4527-af44-122605a411ef/bmp_exports/67890
```

**Example Response**

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
    "message": "BMP export target '67890' deleted successfully",
    "terms": "This data is subject to the Acceptable Use Policy https://www.megaport.com/legal/acceptable-use-policy"
}
```

### Listing BMP export targets

Retrieve all BMP export targets configured on a NAT Gateway.

**Endpoint**

```http theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
GET {baseUrl}/v3/products/nat_gateways/{productUid}/bmp_exports
```

**Path Parameters**

| Parameter | Description |
| :- | :- |
| productUid | The unique identifier (UUID) of the NAT Gateway. |

**Example Request**

```http theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
GET {baseUrl}/v3/products/nat_gateways/7f5f9574-315e-4527-af44-122605a411ef/bmp_exports
```

**Example Response**

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
    "message": "List BMP export targets for NAT Gateway",
    "terms": "This data is subject to the Acceptable Use Policy https://www.megaport.com/legal/acceptable-use-policy",
    "data": [
        {
            "id": 67890,
            "description": "primary-collector",
            "targetIpAddress": "192.0.2.1",
            "targetPort": 5000,
            "exportRib": true,
            "statsInterval": 600,
            "sourceIpAddress": "10.1.1.1"
        },
        {
            "id": 67891,
            "description": "secondary-collector",
            "targetIpAddress": "192.0.2.2",
            "targetPort": 5000,
            "exportRib": false,
            "statsInterval": 300,
            "sourceIpAddress": "10.1.1.2"
        }
    ]
}
```

## Error responses

When a request fails, the API returns an error response with details about the issue.

| HTTP Status | Description |
| :- | :- |
| 400 | Bad request. The request body is invalid or missing required fields. |
| 401 | Unauthorized. The access token is missing or invalid. |
| 403 | Forbidden. You do not have permission to access this resource. |
| 404 | Not found. The specified MCR, NAT Gateway, or BMP export target does not exist. |
| 409 | Conflict. A BMP export target with the same description already exists on the service, or the maximum number of targets (3) has been reached. |

## Helpful references

* [Configuring an MCR](https://docs.megaport.com/mcr/configuring-mcr.md)
* [Creating an MCR](https://docs.megaport.com/mcr/creating-mcr.md)
* [Creating a NAT Gateway](https://docs.megaport.com/nat/creating-nat-gateway.md)
* [Megaport API Overview](https://docs.megaport.com/api.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.