> ## 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 IPFIX Targets with the API

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

export const Gloss = ({term, anchor, langDir = 'en'}) => {
  const errorPrefix = '\x1b[31;1;4mERROR\x1b[0m: Gloss -';
  if (typeof term !== 'string') {
    term = String(term);
  }
  if (typeof anchor !== 'string') {
    anchor = String(anchor);
  }
  if (!term || term === 'undefined') {
    console.error(`${errorPrefix} the \`term\` property is required — rendering an empty string instead`);
    return <></>;
  }
  if (!anchor || anchor === 'undefined') {
    console.error(`${errorPrefix} the \`anchor\` property is required — rendering an empty string instead`);
    return <></>;
  }
  const lang = langDir === 'en' ? '/' : '/' + langDir + '/';
  const glossaryPage = lang + 'glossary/#' + anchor;
  return <a href={glossaryPage}>{term}</a>;
};

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

<Gloss term="IPFIX" anchor="ipfix" /> (IP Flow Information Export) is a standard protocol for exporting network flow information to monitoring systems. You can configure IPFIX targets on your MCR or NAT Gateway to send flow records to external collectors for traffic analysis, capacity planning, and security monitoring.

Each MCR or NAT Gateway supports up to 3 IPFIX targets. Flow records are exported to the configured collector using either UDP or TCP transport.

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

## MCR IPFIX target endpoints

### Creating an IPFIX target

To create an IPFIX 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}/flowExport
```

**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 IPFIX target. Must be unique per service.                                                                                                                                             |
| localIpAddress  | No       | The source IP address on the MCR for the flow export stream. Must be an address configured on the service.<br />The `localIpAddress` and `targetCollector` IP address must be the same address family (IPv4 or IPv6). |
| protocol        | Yes      | The transport protocol: `udp` or `tcp`.                                                                                                                                                                               |
| targetCollector | Yes      | The IPv4 or IPv6 address of the flow collector.<br />The `localIpAddress` and `targetCollector` IP address must be the same address family (IPv4 or IPv6).                                                            |
| targetPort      | Yes      | The port of the flow collector. Valid range: 1-65535.                                                                                                                                                                 |

**Example Request**

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
    "description": "Primary Collector",
    "localIpAddress": "10.1.1.1",
    "protocol": "udp",
    "targetCollector": "192.168.0.1",
    "targetPort": 2055
}
```

**Example Response**

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
    "message": "IPFIX target created successfully",
    "terms": "This data is subject to the Acceptable Use Policy https://www.megaport.com/legal/acceptable-use-policy",
    "data": {
        "id": 159,
        "description": "Primary Collector",
        "localIpAddress": "10.1.1.1",
        "protocol": "udp",
        "targetCollector": "192.168.0.1",
        "targetPort": 2055
    }
}
```

### Getting an IPFIX target

Retrieve a specific IPFIX target by its ID.

**Endpoint**

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

**Path Parameters**

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

**Example Request**

```http theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
GET {baseUrl}/v2/product/mcr2/7f5f9574-315e-4527-af44-122605a411de/flowExport/159
```

**Example Response**

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
    "message": "IPFIX target retrieved successfully",
    "terms": "This data is subject to the Acceptable Use Policy https://www.megaport.com/legal/acceptable-use-policy",
    "data": {
        "id": 159,
        "description": "Primary Collector",
        "localIpAddress": "10.1.1.1",
        "protocol": "udp",
        "targetCollector": "192.168.0.1",
        "targetPort": 2055
    }
}
```

### Updating an IPFIX target

Update an existing IPFIX target configuration.

**Endpoint**

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

**Path Parameters**

| Parameter    | Description                                                          |
| :----------- | :------------------------------------------------------------------- |
| productUid   | The unique identifier (UUID) of the MCR.                             |
| flowExportId | The unique identifier (integer) of the flow 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 IPFIX target. Must be unique per service.                                                                                                                                             |
| localIpAddress  | No       | The source IP address on the MCR for the flow export stream. Must be an address configured on the service.<br />The `localIpAddress` and `targetCollector` IP address must be the same address family (IPv4 or IPv6). |
| protocol        | Yes      | The transport protocol: `udp` or `tcp`.                                                                                                                                                                               |
| targetCollector | Yes      | The IPv4 or IPv6 address of the flow collector.<br />The `localIpAddress` and `targetCollector` IP address must be the same address family (IPv4 or IPv6).                                                            |
| targetPort      | Yes      | The port of the flow collector. Valid range: 1-65535.                                                                                                                                                                 |

**Example Request**

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
    "description": "Primary Collector - Updated",
    "localIpAddress": "10.1.1.2",
    "protocol": "tcp",
    "targetCollector": "192.168.0.2",
    "targetPort": 4739
}
```

### Deleting an IPFIX target

Delete a specific IPFIX target from an MCR.

<Note>
  A target cannot be deleted if it is still assigned to an interface.
</Note>

**Endpoint**

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

**Path Parameters**

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

**Example Request**

```http theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
DELETE {baseUrl}/v2/product/mcr2/7f5f9574-315e-4527-af44-122605a411de/flowExport/159
```

**Example Response**

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

### Listing IPFIX targets

Retrieve all IPFIX 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}/flowExports
```

**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/7f5f9574-315e-4527-af44-122605a411de/flowExports
```

**Example Response**

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
    "message": "IPFIX targets retrieved successfully",
    "terms": "This data is subject to the Acceptable Use Policy https://www.megaport.com/legal/acceptable-use-policy",
    "data": [
        {
            "id": 159,
            "description": "Primary Collector"
        },
        {
            "id": 160,
            "description": "Secondary Collector"
        }
    ]
}
```

## NAT Gateway IPFIX target endpoints

### Creating an IPFIX target

To create an IPFIX 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}/flow_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 IPFIX target. Must be unique per service.                                                                                                                                                     |
| localIpAddress  | No       | The source IP address on the NAT Gateway for the flow export stream. Must be an address configured on the service.<br />The `localIpAddress` and `targetCollector` IP address must be the same address family (IPv4 or IPv6). |
| protocol        | Yes      | The transport protocol: `udp` or `tcp`.                                                                                                                                                                                       |
| targetCollector | Yes      | The IPv4 or IPv6 address of the flow collector.<br />The `localIpAddress` and `targetCollector` IP address must be the same address family (IPv4 or IPv6).                                                                    |
| targetPort      | Yes      | The port of the flow collector. Valid range: 1-65535.                                                                                                                                                                         |

**Example Request**

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
    "description": "Primary Collector",
    "localIpAddress": "10.1.1.1",
    "protocol": "udp",
    "targetCollector": "192.168.0.1",
    "targetPort": 2055
}
```

**Example Response**

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
    "message": "IPFIX target created successfully",
    "terms": "This data is subject to the Acceptable Use Policy https://www.megaport.com/legal/acceptable-use-policy",
    "data": {
        "id": 159,
        "description": "Primary Collector",
        "localIpAddress": "10.1.1.1",
        "protocol": "udp",
        "targetCollector": "192.168.0.1",
        "targetPort": 2055
    }
}
```

### Getting an IPFIX target

Retrieve a specific IPFIX 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}/flow_exports/{flowExportId}
```

**Path Parameters**

| Parameter    | Description                                                |
| :----------- | :--------------------------------------------------------- |
| productUid   | The unique identifier (UUID) of the NAT Gateway.           |
| flowExportId | The unique identifier (integer) of the flow 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/flow_exports/159
```

**Example Response**

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
    "message": "IPFIX target retrieved successfully",
    "terms": "This data is subject to the Acceptable Use Policy https://www.megaport.com/legal/acceptable-use-policy",
    "data": {
        "id": 159,
        "description": "Primary Collector",
        "localIpAddress": "10.1.1.1",
        "protocol": "udp",
        "targetCollector": "192.168.0.1",
        "targetPort": 2055
    }
}
```

### Updating an IPFIX target

Update an existing IPFIX target configuration.

**Endpoint**

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

**Path Parameters**

| Parameter    | Description                                                          |
| :----------- | :------------------------------------------------------------------- |
| productUid   | The unique identifier (UUID) of the NAT Gateway.                     |
| flowExportId | The unique identifier (integer) of the flow 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 IPFIX target. Must be unique per service.                                                                                                                                                     |
| localIpAddress  | No       | The source IP address on the NAT Gateway for the flow export stream. Must be an address configured on the service.<br />The `localIpAddress` and `targetCollector` IP address must be the same address family (IPv4 or IPv6). |
| protocol        | Yes      | The transport protocol: `udp` or `tcp`.                                                                                                                                                                                       |
| targetCollector | Yes      | The IPv4 or IPv6 address of the flow collector.<br />The `localIpAddress` and `targetCollector` IP address must be the same address family (IPv4 or IPv6).                                                                    |
| targetPort      | Yes      | The port of the flow collector. Valid range: 1-65535.                                                                                                                                                                         |

**Example Request**

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
    "description": "Primary Collector - Updated",
    "localIpAddress": "10.1.1.2",
    "protocol": "tcp",
    "targetCollector": "192.168.0.2",
    "targetPort": 4739
}
```

### Deleting an IPFIX target

Delete a specific IPFIX target from a NAT Gateway.

<Note>
  A target cannot be deleted if it is still assigned to an interface.
</Note>

**Endpoint**

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

**Path Parameters**

| Parameter    | Description                                                          |
| :----------- | :------------------------------------------------------------------- |
| productUid   | The unique identifier (UUID) of the NAT Gateway.                     |
| flowExportId | The unique identifier (integer) of the flow 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/flow_exports/159
```

**Example Response**

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

### Listing IPFIX target summaries

Retrieve summaries of all IPFIX 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}/flow_export_summaries
```

**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/flow_export_summaries
```

**Example Response**

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
    "message": "IPFIX target summaries retrieved successfully",
    "terms": "This data is subject to the Acceptable Use Policy https://www.megaport.com/legal/acceptable-use-policy",
    "data": [
        {
            "id": 159,
            "description": "Primary Collector"
        },
        {
            "id": 160,
            "description": "Secondary Collector"
        }
    ]
}
```

## 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 don't have permission to access this resource.                                                |
| 404         | Not found. The specified MCR, NAT Gateway, or IPFIX target doesn't exist.                                    |
| 409         | Conflict. The IPFIX target description is not unique, or the maximum number of targets (3) has been reached. |

## Helpful references

* [Configuring an MCR](/mcr/configuring-mcr)
* [Creating an MCR](/mcr/creating-mcr)
* [Creating a NAT Gateway](/nat/creating-nat-gateway)
* [Megaport API Overview](/api)
