> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://en.megaport.ferndocs.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://en.megaport.ferndocs.com/_mcp/server.

# Create MCR Packet Filter List

POST https://api.megaport.com/v2/product/mcr2/{productUid}/packetFilter
Content-Type: application/json

Creates packet filter lists for the MCR specified by the `productUid`.

The MCR packet filter list is a named list of IP network addresses. Create a packet filter list to match and filter routes based on the routeâ€™s source address and ports, the destination address and ports, and the IP protocol.

- When no packet filter is configured, all traffic is permitted.
    
- When a packet filter is configured, any traffic not permitted by the filter is denied.
    
- Up to 20 packet filter lists can be configured on each MCR.
    
- Each list can contain up to 50 entries.
    
- A filter can be applied multiple times on the same MCR.
    

The parameters have these values:

- `Source IP Address` (required)
    
    - _Supports both IPv4 and IPv6 packets._
        
- `Destination IP Address` (required)
    
    - _Supports both IPv4 and IPv6 packet._
        
- `IP Protocol`
    
    - A decimal integer between 0 and 255 taken from the Industry standard list of protocols.
        
- `Source Port/Port Range` (for TCP and UDP protocols)
    
    - Range to be expressed as **nn-nn**. For example, 25-32.
        
- `Destination Port/Port Range` (for TCP and UDP protocols)
    
    - Range to be expressed as **nn-nn**. For example, 25-32.
        
- `Description` for each entry
    

For more information about packet filter lists, see [Using Packet Filters](https://docs.megaport.com/mcr/packet-filters/).

Reference: https://en.megaport.ferndocs.com/api-reference/megaport-cloud-router-mcr/create-mcr-packet-filter-list

## Servers

- `https://api.megaport.com` (Production environment, default)
- `https://api-staging.megaport.com` (Staging environment (test only, reset every 24 hours))

## Request

### Path parameters

- `productUid` (string, required)

### Body (application/json)

This endpoint expects an object.

- `description` (string, optional)
- `entries` (list of V2ProductMcr2ProductUidPacketFilterPostRequestBodyContentApplicationJsonSchemaEntriesItems, optional)

## Response

### 200

Create MCR Packet Filter List / Create MCR Packet Filter List

- `data` (V2ProductMcr2ProductUidPacketFilterPostResponsesContentApplicationJsonSchemaData, optional)
- `message` (string, optional)
- `terms` (string, optional)

## Types

### V2ProductMcr2ProductUidPacketFilterPostRequestBodyContentApplicationJsonSchemaEntriesItems

- `action` (string, optional)
- `description` (string, optional)
- `destinationAddress` (string, optional)
- `destinationPorts` (string, optional)
- `ipProtocol` (double, optional)
- `sourceAddress` (string, optional)
- `sourcePorts` (string, optional)

### V2ProductMcr2ProductUidPacketFilterPostResponsesContentApplicationJsonSchemaData

- `addressFamily` (string, optional)
- `description` (string, optional)
- `entries` (list of V2ProductMcr2ProductUidPacketFilterPostResponsesContentApplicationJsonSchemaDataEntriesItems, optional)
- `id` (double, optional)

### V2ProductMcr2ProductUidPacketFilterPostResponsesContentApplicationJsonSchemaDataEntriesItems

- `action` (string, optional)
- `ge` (string, optional)
- `le` (string, optional)
- `prefix` (string, optional)

## Examples

**Request**

```json
{
  "description": "an example packet filter",
  "entries": [
    {
      "action": "permit",
      "description": "permit things",
      "destinationAddress": "10.1.1.1",
      "destinationPorts": "80",
      "ipProtocol": 6,
      "sourceAddress": "10.1.1.2"
    },
    {
      "action": "deny",
      "description": "deny things",
      "destinationAddress": "10.1.1.1",
      "ipProtocol": 6,
      "sourceAddress": "10.1.1.2",
      "sourcePorts": "1-999"
    }
  ]
}
```

**Response**

```json
{
  "data": {
    "addressFamily": "IPv4",
    "description": "New Prefix Filter List",
    "entries": [
      {
        "action": "permit",
        "prefix": "10.0.0.0/24"
      },
      {
        "action": "deny",
        "prefix": "10.1.0.0/24"
      },
      {
        "action": "permit",
        "ge": "20",
        "le": "32",
        "prefix": "10.2.0.0/16"
      }
    ],
    "id": 2798
  },
  "message": "Created a new prefix list for MCR",
  "terms": "This data is subject to the Acceptable Use Policy https://www.megaport.com/legal/acceptable-use-policy"
}
```

**SDK Code**

```python
import requests

url = "https://api.megaport.com/v2/product/mcr2/productUid/packetFilter"

payload = {
    "description": "an example packet filter",
    "entries": [
        {
            "action": "permit",
            "description": "permit things",
            "destinationAddress": "10.1.1.1",
            "destinationPorts": "80",
            "ipProtocol": 6,
            "sourceAddress": "10.1.1.2"
        },
        {
            "action": "deny",
            "description": "deny things",
            "destinationAddress": "10.1.1.1",
            "ipProtocol": 6,
            "sourceAddress": "10.1.1.2",
            "sourcePorts": "1-999"
        }
    ]
}
headers = {"Content-Type": "application/json"}

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

print(response.json())
```

```javascript
const url = 'https://api.megaport.com/v2/product/mcr2/productUid/packetFilter';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: '{"description":"an example packet filter","entries":[{"action":"permit","description":"permit things","destinationAddress":"10.1.1.1","destinationPorts":"80","ipProtocol":6,"sourceAddress":"10.1.1.2"},{"action":"deny","description":"deny things","destinationAddress":"10.1.1.1","ipProtocol":6,"sourceAddress":"10.1.1.2","sourcePorts":"1-999"}]}'
};

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.megaport.com/v2/product/mcr2/productUid/packetFilter"

	payload := strings.NewReader("{\n  \"description\": \"an example packet filter\",\n  \"entries\": [\n    {\n      \"action\": \"permit\",\n      \"description\": \"permit things\",\n      \"destinationAddress\": \"10.1.1.1\",\n      \"destinationPorts\": \"80\",\n      \"ipProtocol\": 6,\n      \"sourceAddress\": \"10.1.1.2\"\n    },\n    {\n      \"action\": \"deny\",\n      \"description\": \"deny things\",\n      \"destinationAddress\": \"10.1.1.1\",\n      \"ipProtocol\": 6,\n      \"sourceAddress\": \"10.1.1.2\",\n      \"sourcePorts\": \"1-999\"\n    }\n  ]\n}")

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

	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.megaport.com/v2/product/mcr2/productUid/packetFilter")

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

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n  \"description\": \"an example packet filter\",\n  \"entries\": [\n    {\n      \"action\": \"permit\",\n      \"description\": \"permit things\",\n      \"destinationAddress\": \"10.1.1.1\",\n      \"destinationPorts\": \"80\",\n      \"ipProtocol\": 6,\n      \"sourceAddress\": \"10.1.1.2\"\n    },\n    {\n      \"action\": \"deny\",\n      \"description\": \"deny things\",\n      \"destinationAddress\": \"10.1.1.1\",\n      \"ipProtocol\": 6,\n      \"sourceAddress\": \"10.1.1.2\",\n      \"sourcePorts\": \"1-999\"\n    }\n  ]\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.megaport.com/v2/product/mcr2/productUid/packetFilter")
  .header("Content-Type", "application/json")
  .body("{\n  \"description\": \"an example packet filter\",\n  \"entries\": [\n    {\n      \"action\": \"permit\",\n      \"description\": \"permit things\",\n      \"destinationAddress\": \"10.1.1.1\",\n      \"destinationPorts\": \"80\",\n      \"ipProtocol\": 6,\n      \"sourceAddress\": \"10.1.1.2\"\n    },\n    {\n      \"action\": \"deny\",\n      \"description\": \"deny things\",\n      \"destinationAddress\": \"10.1.1.1\",\n      \"ipProtocol\": 6,\n      \"sourceAddress\": \"10.1.1.2\",\n      \"sourcePorts\": \"1-999\"\n    }\n  ]\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.megaport.com/v2/product/mcr2/productUid/packetFilter', [
  'body' => '{
  "description": "an example packet filter",
  "entries": [
    {
      "action": "permit",
      "description": "permit things",
      "destinationAddress": "10.1.1.1",
      "destinationPorts": "80",
      "ipProtocol": 6,
      "sourceAddress": "10.1.1.2"
    },
    {
      "action": "deny",
      "description": "deny things",
      "destinationAddress": "10.1.1.1",
      "ipProtocol": 6,
      "sourceAddress": "10.1.1.2",
      "sourcePorts": "1-999"
    }
  ]
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.megaport.com/v2/product/mcr2/productUid/packetFilter");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"description\": \"an example packet filter\",\n  \"entries\": [\n    {\n      \"action\": \"permit\",\n      \"description\": \"permit things\",\n      \"destinationAddress\": \"10.1.1.1\",\n      \"destinationPorts\": \"80\",\n      \"ipProtocol\": 6,\n      \"sourceAddress\": \"10.1.1.2\"\n    },\n    {\n      \"action\": \"deny\",\n      \"description\": \"deny things\",\n      \"destinationAddress\": \"10.1.1.1\",\n      \"ipProtocol\": 6,\n      \"sourceAddress\": \"10.1.1.2\",\n      \"sourcePorts\": \"1-999\"\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = [
  "description": "an example packet filter",
  "entries": [
    [
      "action": "permit",
      "description": "permit things",
      "destinationAddress": "10.1.1.1",
      "destinationPorts": "80",
      "ipProtocol": 6,
      "sourceAddress": "10.1.1.2"
    ],
    [
      "action": "deny",
      "description": "deny things",
      "destinationAddress": "10.1.1.1",
      "ipProtocol": 6,
      "sourceAddress": "10.1.1.2",
      "sourcePorts": "1-999"
    ]
  ]
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.megaport.com/v2/product/mcr2/productUid/packetFilter")! 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()
```