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

> This help topic describes how to use the Megaport API to create a Megaport Cloud Router (MCR).

export const Image = ({src, alt = '', caption, width, height, shadow}) => {
  const errorPrefix = '\x1b[31;1;4mERROR\x1b[0m: Image -';
  if (typeof src !== 'string') {
    src = String(src);
  }
  if (!src || src === 'undefined') {
    console.error(`${errorPrefix} \`src\` is required — rendering an empty string instead`);
    return <></>;
  }
  const img = <img className={['mega-image-style', shadow ? 'shadow' : ''].join(' ')} src={src} alt={alt} width={width} height={height} style={{
    display: 'block'
  }} />;
  return caption ? <figure>
      {img}
      <figcaption style={{
    textAlign: 'center',
    width
  }}>{caption}</figcaption>
    </figure> : img;
};

This topic describes the API procedure to create an MCR, including how to look up locations for the MCR, and how to validate and complete the order.

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

**To look up MCR location details in the Postman collection**

1. Expand the **Locations** folder in the left navigation and click **GET Locations (v3)**.\
   This request is not expecting Parameters or Body information.

2. Click **Send** to make a GET request.

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

   <Image src="/images/api/get-locations.png" alt="Get locations" shadow={true} width={800} />

   Ensure the request was successful by looking for Status: 200 OK and display the response in the Body section in the Pretty format.

   The request returns hundreds of Megaport locations.

3. Click the magnifying glass and search the response for a site that includes `mcrSpeedMbps` in the `diversityZones` object and is in the US market.

   To provision an MCR at a location, the port speed must be available in the `diversityZones` object. Check that the location has the available speed and diversity zone for the MCR.

```json {2,17,22,24,39} theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
            "id": 60,
            "name": "CoreSite LA1",
            "address": {
                "street": "624 South Grand Avenue",
                "suburb": null,
                "city": "Los Angeles",
                "state": "CA",
                "postcode": "90017",
                "country": "USA"
            },
            "dataCentre": {
                "id": 18,
                "name": "CoreSite"
            },
            "metro": "Los Angeles",
            "market": "US",
            "status": "Active",
            "longitude": -118.25554,
            "latitude": 34.04791,
            "orderingMessage": null,
            "diversityZones": {
                "red": {
                    "mcrSpeedMbps": [
                        2500,
                        5000,
                        10000,
                        1000
                    ],
                    "megaportSpeedMbps": [
                        1000,
                        10000,
                        100000
                    ],
                    "mveMaxCpuCoreCount": null,
                    "mveAvailable": true
                },
                "blue": {
                    "mcrSpeedMbps": [
                        5000,
                        1000,
                        2500,
                        10000
                    ],
                    "megaportSpeedMbps": [
                        1000,
                        100000,
                        10000
                    ],
                    "mveMaxCpuCoreCount": null,
                    "mveAvailable": true
                }
            },
            "productAddOns": {
                "crossConnect": {
                    "available": true,
                    "type": "STANDARD"
                }
            }
        }
```

To create an MCR, you need the `id` value. In this example, the location ID is 60.

**To test and validate the MCR order**

1. In Postman, expand **Megaport Cloud Router (MCR)** in the left navigation and select **Validate MCR Order (v3)**.

2. Update the Body with the `locationId` (60), `productName` (whatever name you want for your MCR), `term` (the minimum number of months in the committed term: 1, 12, 24, 36, 48, or 60), and `portSpeed` (1000, 2500, 5000, or 10000 Mbps) and click **Send**.\
   An ASN value is only required if you don’t want to use the Megaport default ASN of 133937.\
   Add a diversity zone. Check the location results to see which diversity zones are available for your MCR location under `diversityZones`.\
   If the diversity zone is not explicitly selected, one will be automatically allocated when the MCR is created.

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

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
[
    {
        "locationId":60,
        "term": 12,
        "promoCode": "promox3mnthfree2",
        "productName":"Test MCR",
        "productType":"MCR2",
        "portSpeed":2500,
        "config": {
          "mcrAsn": 133937,
          "diversityZone":"blue"
        }
    }
]
```

A successful response passes validation and has a 200 OK status. The response also includes pricing details of the service.

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
    "message": "Validation passed",
    "terms": "This data is subject to the Acceptable Use Policy https://www.megaport.com/legal/acceptable-use-policy",
    "data": [
        {
            "price": {
                "hourlySetup": 0,
                "dailySetup": 0,
                "monthlySetup": 0,
                "hourlyRate": 0,
                "dailyRate": 0,
                "monthlyRate": 1440.00,
                "fixedRecurringCharge": 0,
                "postPaidBaseRate": "no base rate",
                "longHaulMbpsRate": 0,
                "mbpsRate": 6.000000000000000,
                "currency": "USD",
                "key": "no key",
                "productType": "MCR2",
                "empty": false
            },
            "serviceName": "API Test MCR",
            "productType": "MCR2",
            "productUid": "78aebd6b-7601-4331-82bc-dcd07f9f21a6",
            "string": "Los Angeles"
        }
    ]
}
```

**To order the validated MCR**

1. With a validated MCR request and reviewed cost information, copy the Body from **POST Validate MCR Order (v3)** and paste into the Body of **POST Buy MCR (v3)**.

   <Callout icon="triangle-exclamation" color="red">
     If you make this call on api.megaport.com, your account will be charged for the service. Alternatively, you can use the API in the staging (test) environment without charges, as in these examples.
   </Callout>

2. Send the request.

   This output shows a successful response.

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
    "message": "MCR2 [426fa830-4b66-41ad-95a1-197d55e074b1] created.",
    "terms": "This data is subject to the Acceptable Use Policy https://www.megaport.com/legal/acceptable-use-policy",
    "data": [
        {
            "serviceName": "Test MCR",
            "name": "Test MCR",
            "secondaryName": null,
            "technicalServiceId": 187964,
            "technicalServiceUid": "426fa830-4b66-41ad-95a1-197d55e074b1",
            "requestedDate": 1707800936928,
            "configuredDate": null,
            "currentEstimatedDelivery": null,
            "companyName": "Megaport Lab",
            "companyId": 1153,
            "billingContactName": null,
            "billingContactId": null,
            "adminContactName": null,
            "adminContactId": null,
            "technicalContactName": null,
            "technicalContactId": null,
            "salesName": null,
            "salesId": null,
            "billableId": 179527,
            "billableUsageAlgorithm": null,
            "productType": "MCR2",
            "provisioningStatus": "DEPLOYABLE",
            "failedReason": null,
            "inAdvanceBillingStatus": null,
            "provisioningItems": [],
            "tags": [],
            "vxcDistanceBand": null,
            "intercapPath": null,
            "marketplaceVisibility": false,
            "vxcPermitted": true,
            "vxcAutoApproval": false,
            "createDate": 1707800936928,
            "terminationDate": null,
            "contractStartDate": null,
            "contractTermMonths": 12,
            "rateType": "MONTHLY",
            "trialAgreement": false,
            "payerCompanyId": null,
            "nonPayerCompanyId": null,
            "minimumSpeed": null,
            "maximumSpeed": null,
            "rateLimit": 2500,
            "errorMessage": null,
            "lagId": null,
            "aggregationId": null,
            "lagPrimary": null,
            "market": "USA",
            "accountManager": null,
            "promptUid": null,
            "components": [],
            "attributes": [],
            "aLocation": "lax-cs1",
            "bLocation": null,
            "aMetro": "Los Angeles",
            "aCountry": "USA",
            "aLocationId": 60,
            "bLocationId": null,
            "bMetro": null,
            "bCountry": null,
            "attributeTags": {},
            "createdBy": "f39b8983-256e-4643-adec-9f0b5da09ab7",
            "buyoutPort": false,
            "virtual": true,
            "locked": false,
            "adminLocked": false,
            "bgpShutdownDefault": false
        }
    ]
}
```

The new MCR now appears in your working environment, either portal.megaport.com or portal-staging.megaport.com.

<Image src="/images/api/new-api-mcr.png" alt="New API MCR" shadow={true} width={700} />

<Tip>
  To see all options for the requests used in this example, see [https://dev.megaport.com](https://dev.megaport.com).
</Tip>

The next step is to create VXCs to this MCR.\
For more information, see:

* [Creating an MCR VXC with the API](/api/api-mcr-vxc-csp)
* [Creating a VXC between an MCR and Microsoft Azure with the API](/api/api-mcr-vxc-azure)
