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

# Creating an MCR VXC with the API

> This help topic describes how to use the Megaport API to create an MCR VXC.

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 create an MCR VXC. The first example creates an AWS Hosted Connection in the US market - one of the more involved configurations. Templates for other CSPs appear later in the topic.

For more information, see [POST Validate MCR VXC Order (v3)](https://dev.megaport.com/#88537ea2-f3de-49c1-907d-d4037a2082e9) in the API reference.

## Creating a VXC between an MCR and AWS with a Hosted Connection

This example creates an AWS Hosted Connection in the US market. The steps include how to:

* get the MCR product ID
* find the location ID for an available US market
* validate and order the VXC
* configure two static routes
* configure <Gloss term="BGP" anchor="bgp" /> connections -- one connection with <Gloss term="MED" anchor="med" /> details and one without.

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

To create the VXC, we need the `productUid` for the MCR.

**To get the productUid for the MCR**

1. Get the product list.

   ```http theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
   GET {baseUrl}/v2/products/
   ```

2. From the returned product details, locate the `productUid` value for the MCR you want to connect.

   This example uses this value: fee85cc0-f06f-4ad7-bce7-36aef7dbe0d0

Next, find the location ID for the US market you want with support for AWS Hosted Connections.

**To find the locationId in US market where AWS Hosted Connections are available**

1. Get the list for all interfaces Megaport has with Cloud Service Providers.

   ```http theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
   GET {baseUrl}/v2/dropdowns/partner/megaports
   ```

   You can filter the results by `connectType` and `vxcPermitted`.

   ```http theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
   GET {baseUrl}/v2/dropdowns/partner/megaports?connectType=AWSHC&vxcPermitted=true
   ```

2. Click the magnifying glass and search through the response for a site matching your location criteria.

   For this example, select "US West (Oregon) (us-west-2) \[DZ-RED]" with "locationId": 57.

```json {2,4,7,8} theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
            "connectType": "AWSHC",
            "productUid": "f274bd09-1796-43af-8837-28fa4fa2a1ab",
            "vxcPermitted": true,
            "companyUid": "605cb850-dfb4-4a05-a171-8bf17757b3a2",
            "companyName": "AWS",
            "title": "US West (Oregon) (us-west-2) [DZ-RED]",
            "locationId": 57,
            "speed": 10000,
            "rank": 275,
            "lag_id": 5,
            "lag_primary": true,
            "aggregation_id": 106462
        },
```

<Note>
  \[DZ-RED] means Red diversity zone. Each AWS Hosted Connection site provides two diversity zones to provide redundancy: DZ-Red and DZ-Blue.
</Note>

With the MCR ID and the AWS location ID, you can create a VXC.

**To create the VXC**

1. Create a request with this URL:

   ```http theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
   POST {baseUrl}/v3/networkdesign/buy
   ```

   <Tip>
     To test your request before you order, you can use:
     `POST {baseUrl}/v3/networkdesign/validate`
   </Tip>

2. Add these headers to the request:
   * Content-Type: application/json
   * Authorization: Bearer \{your accessToken}

3. Create the Body of the request with the configuration details.

   This example uses MCR product ID, the AWS location ID for the B-End, creates two static routes, and configures BGP connections – one connection with MED details and one without. The following sections provide details about the static routes and BGP connections.

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
[
  {
    "productUid": "fee85cc0-f06f-4ad7-bce7-36aef7dbe0d0",
    "associatedVxcs": [
      {
        "rateLimit": 100,
        "productName": "awshc",
        "term": 12,
        "shutdown": false,
        "promoCode": "promox3mnthfree2",
        "aEnd": {
          "locationId": 320,
          "vlan": 0,
          "partnerConfig": {
            "connectType": "VROUTER",
            "interfaces": [
              {
                "vlan": null,
                "ipMtu": 5000,
                "ipAddresses": [
                  "10.191.0.25/29",
                ],
                "bgpConnections": [
                  {
                    "peerAsn": 62512,
                    "localIpAddress": "10.191.0.25",
                    "peerIpAddress": "10.191.0.26",
                    "password": "cnn6eaeaETSjvjvjvjv",
                    "importWhitelist": null,
                    "importBlacklist": null,
                    "exportWhitelist": null,
                    "exportBlacklist": null,
                    "shutdown": false,
                    "description": "BGP with MED and BFD enabled",
                    "medIn": 100,
                    "medOut": 100,
                    "bfdEnabled": true
                  },
                  {
                    "peerAsn": 62511,
                    "localIpAddress": "10.191.0.27",
                    "peerIpAddress": "10.191.0.28",
                    "password": "cnn23049asdkfj",
                    "importWhitelist": null,
                    "importBlacklist": null,
                    "exportWhitelist": null,
                    "exportBlacklist": null,
                    "shutdown": false,
                    "description": "BGP without MED or BFD",
                    "medIn": null,
                    "medOut": null,
                    "bfdEnabled": false
                  }
                ],
                "ipRoutes": [
                  {
                    "prefix": "10.0.0.0/24",
                    "nextHop": "10.191.0.26",
                    "description": "test static route 1"
                  },
                  {
                    "prefix": "10.0.1.9/24",
                    "nextHop": "10.191.0.27",
                    "description": "test static route 2"
                  }
                ],
                "natIpAddresses": []
              }
            ]
          }
        },
        "bEnd": {
          "locationId": 57,
          "ownerUid": "605cb850-dfb4-4a05-a171-8bf17757b3a2",
          "productUid": "d5518ee1-e915-4e3d-a4e1-a2c7e04f2fdd",
          "vlan": 0,
          "partnerConfig": {
            "name": "awshc",
            "ownerAccount": "XXXXXXXXXXXX",
            "connectType": "AWSHC"
          }
        },
        "productType": "VXC",
        "connectType": "AWSHC"
      }
    ]
  }
]
```

## Static routes

You can create multiple static routes per interface by adding an `ipRoutes` array to the interfaces array of the A-End partner configuration object:

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
"ipRoutes": [
  {
    "prefix": "10.0.0.0/24",
    "nextHop": "10.191.0.26",
    "description": "test static route 1"
  },
  {
    "prefix": "10.0.1.9/24",
    "nextHop": "10.191.0.27",
    "description": "test static route 2"
 }
],
```

An empty ipRoutes array indicates there are no static routes.

| **Parameter** | **Description**                          | **Required** | **Valid Input**                                                                         |
| ------------- | ---------------------------------------- | ------------ | --------------------------------------------------------------------------------------- |
| prefix        | IP prefix (V4 & V6) to route to nextHop  | Yes          | IP prefix v4/v6 - If no mask is presented address is treated as a host address (/32)    |
| nextHop       | Next Hop address                         | Yes          | IP Address v4/v6 - Must be in the same subnet as the interface but not the interface IP |
| description   | Optional description of the static route | No           | String - Max length 100 characters                                                      |

## BGP connections

You can create multiple BGP connections per interface by adding a bgpConnections array to the interfaces array of the A-End partner configuration object:

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
"bgpConnections": [
  {
    "peerAsn": 62512,
    "localIpAddress": "10.191.0.25",
    "peerIpAddress": "10.191.0.26",
    "password": "cnn6eaeaETSjvjvjvjv",
    "importWhitelist": null,
    "importBlacklist": null,
    "exportWhitelist": null,
    "exportBlacklist": null,
    "shutdown": false,
    "description": "BGP with MED and BFD enabled",
    "medIn": 100,
    "medOut": 100,
    "bfdEnabled": true,
    "asOverride": true
  },
  {
    "peerAsn": 62511,
    "localIpAddress": "10.191.0.27",
    "peerIpAddress": "10.191.0.28",
    "password": "cnn23049asdkfj",
    "importWhitelist": null,
    "importBlacklist": null,
    "exportWhitelist": null,
    "exportBlacklist": null,
    "shutdown": false,
    "description": "BGP without MED or BFD",
    "asPathPrependCount": "3",
    "bfdEnabled": false,
    "asOverride": false
  }
],
```

| **Parameter**      | **Description**                                                                                                                                                                                                                                                                | **Required** | **Valid Input**                                                                                                                                                     |
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| peerAsn            | The ASN of the remote BGP peer.                                                                                                                                                                                                                                                | Yes          | Valid ASN - Integers between 1 - 4294967294                                                                                                                         |
| localAsn           | Local ASN can override the ASN of the MCR for this BGP peer. In most cases it should be left default.                                                                                                                                                                          | No           | Valid ASN - Integers between 1 - 4294967294  <br /><br />localAsn cannot be set if peerAsn == mcrAsn <br /><br />localAsn cannot match peerAsn if peerAsn != mcrAsn |
| localIpAddress     | The IPv4 or IPv6 address on this interface to use for communication with the BGP peer.                                                                                                                                                                                         | Yes          | Valid IP address v4/v6. Must be an IP address of the interface                                                                                                      |
| peerIpAddress      | The IP address of the BGP peer.                                                                                                                                                                                                                                                | Yes          | Valid IP address v4/v6                                                                                                                                              |
| password           | A shared key used to authenticate the BGP peer, up to 32 characters.                                                                                                                                                                                                           | No           | 0-32 characters                                                                                                                                                     |
| importWhitelist    | Inbound prefix filtering using a permit action. MCR applies the prefix filter to inbound BGP route advertisements from the neighbor. Routes not matching the prefixes on this list are denied at the earliest possible point and are never used by the MCR.                    | No           | 1-100 characters                                                                                                                                                    |
| importBlacklist    | Inbound prefix filtering using a deny action. MCR applies the prefix filter to inbound BGP route advertisements from the neighbor. Routes matching the prefixes on this list are blocked. All other prefixes are allowed to enter the MCR routing table.                       | No           | 1-100 characters                                                                                                                                                    |
| exportWhitelist    | Outbound prefix filtering using a permit action. MCR applies the prefix filter to outbound routes. Routes matching the prefix list are advertised to the BGP neighbor and all other routes are filtered.                                                                       | No           | 1-100 characters                                                                                                                                                    |
| exportBlacklist    | Outbound prefix filtering using a deny action. MCR applies the prefix filter to outbound routes. Routes matching the prefix list are blocked from the BGP neighbor and all other routes are advertised.                                                                        | No           | 1-100 characters                                                                                                                                                    |
| shutdown           | By default, BGP connections are enabled and will actively attempt to connect to the peer. Select shutdown to temporarily disable the BGP session without removing it. This can be useful for troubleshooting or testing failover scenarios.                                    | No           | true/false - Defaults to false                                                                                                                                      |
| description        | Optional description of the BGP connection                                                                                                                                                                                                                                     | No           | 0-100 characters                                                                                                                                                    |
| medIn              | The MED will be applied to all routes received on this BGP connection. Leave blank to use the value received from the BGP peer. The route with the lowest value will be preferred.                                                                                             | No           | Supports values between 0 and 4,294,967,295                                                                                                                         |
| medOut             | The MED will be applied to all routes transmitted on this BGP connection. The neighboring autonomous system might prefer the lowest value at their discretion.                                                                                                                 | No           | Supports values between 0 and 4,294,967,295                                                                                                                         |
| asPathPrependCount | asPathPrependCount is an integer representing the number of times that the local AS number will be prepended on outgoing BGP announcements to the peer.                                                                                                                        | No           | Acceptable values are in the range 1-10                                                                                                                             |
| bfdEnabled         | Bidirectional Forwarding Detection allows for rapid fault detection on this BGP connection. When connectivity is disrupted the BGP session is torn down without waiting for the BGP hold timer to expire. BFD might improve fail over time when multiple routes are available. | No           | true/false - <br />Defaults to false <br />Optional                                                                                                                 |
| asOverride         | Enables AS Override for eBGP peering. When enabled, replaces the peer's ASN with the local ASN in the AS path. This is useful when connecting sites that share the same ASN. Only valid for eBGP connections.                                                                  | No           | true/false - <br />Defaults to false <br />Optional                                                                                                                 |

## Bidirectional Forwarding Detection (BFD)

The `bfd` configuration object applies to all BGP connections on the interface that have `bfdEnabled = true`.

The BFD settings are not editable. The default values configured when BFD is enabled are:

* <Gloss term="Transmit Interval" anchor="bfd-transmit" />: 300 milliseconds
* <Gloss term="Receive Interval" anchor="bfd-receive" />: 300 milliseconds
* <Gloss term="Multiplier" anchor="bfd-multiplier" />: 3

<Note>
  These settings will be used for all BGP connections on the VXC where BFD is enabled.
</Note>

## DHCP pools

You can configure a DHCP server pool on an MCR VXC interface. A DHCP pool enables the MCR to act as a DHCP server, assigning IP addresses to devices connected through the interface.

Add a `dhcpPools` array to the interfaces array of the A-End or B-End partner configuration object:

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
"dhcpPools": [
  {
    "network": "192.168.1.0/24",
    "startIpAddress": "192.168.1.10",
    "endIpAddress": "192.168.1.100",
    "defaultGateway": "192.168.1.1",
    "description": "Office LAN DHCP pool",
    "dnsServers": ["8.8.8.8", "8.8.4.4"]
  }
]
```

| **Parameter**  | **Description**                                                              | **Required** | **Valid Input**                          |
| -------------- | ---------------------------------------------------------------------------- | ------------ | ---------------------------------------- |
| network        | The IPv4 network in CIDR notation for the DHCP pool.                         | Yes          | IPv4 CIDR, for example `192.168.1.0/24`. |
| startIpAddress | The first IP address in the range of IP addresses to assign to DHCP clients. | Yes          | IPv4 address within the network.         |
| endIpAddress   | The last IP address in the range of IP addresses to assign to DHCP clients.  | Yes          | IPv4 address within the network.         |
| defaultGateway | The IP address of the default gateway to provide to DHCP clients.            | No           | IPv4 address.                            |
| description    | A description for the DHCP pool.                                             | No           | 0-100 characters.                        |
| dnsServers     | A list of DNS resolver IP addresses to provide to DHCP clients.              | No           | Array of up to 5 IPv4 addresses.         |

<Note>
  * DHCP pools are supported only on MCR products.
  * DHCP pools are not supported when the opposite end of the VXC is a Transit or IX connection.
  * DHCP pools are not supported on IPsec tunnel interfaces.
  * Each interface supports a maximum of one DHCP pool.
</Note>

## Autoconfiguration with AWS, Azure, and Google

For Azure, AWS Hosted VIF, and Google, Megaport can set up the IP addressing and BGP details on both the MCR and the CSP side ensuring a working BGP setup. This also minimizes the amount of switching between the CSP and Megaport portals.

While the Portal handles the autoconfiguration by default, you can also use the API to trigger the BGP autoconfiguration.

The functionality is triggered when the interfaces key in partnerConfig does not exist or is null.

**To configure BGP peering for CSPs**

1. Create a request with this URL:

   ```http theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
   POST {baseUrl}/v3/networkdesign/buy
   ```

2. Add these headers to the request:
   * Content-Type: application/json
   * Authorization: Bearer \{your accessToken}

3. Create the Body of the request with the configuration details.

   Different templates are available here for the most popular CSPs.

#### AWS Hosted VIF

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
"productUid": "{{ mcrid }}",
"associatedVxcs": [
 {
   "productName": "Test AWS VIF VXC",
   "rateLimit": 100,
   "term": 12,
   "aEnd": {
     "vlan": 0
   },
   "bEnd": {
     "productUid": "{{ awsPortUid }}",
     "partnerConfig": {
       "connectType": "AWS",
       "type": "private",
       "ownerAccount": "{{ yourAWSAccountNumber }}"
     }
   }
 }
]
}
```

For more information about creating a Hosted VIF, see [Creating a VXC between an MCR and AWS with the API](/api/api-mcr-vxc-aws).

#### Google Cloud

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
   "productUid": "{{ mcrid }}",
   "associatedVxcs": [
    {
     "productName": "Test Google VXC",
     "rateLimit": 100,
     "term": 12,
     "aEnd": {
       "vlan": 0
     },
     "bEnd": {
       "productUid": "{{ googlePortUid }}",
       "partnerConfig": {
         "connectType": "GOOGLE",
         "pairingKey": "{{ googlekey }}"
       }
     },
     "productType": "VXC"
    }
   ]
}
```

#### Microsoft Azure

For Azure configuration details, see [Creating a VXC between an MCR and Microsoft Azure with the API](/api/api-mcr-vxc-azure).
