> ## 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 a VXC to AWS with the API

> This help topic describes how to use the Megaport API to create a VXC for a Hosted VIF connection to AWS.

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 a VXC from a Port to AWS, including how to look up cloud interconnect locations, validate the connection, and order the VXC.

The example in this topic creates a Hosted VIF connection to AWS with a data rate of 500 Mbps. To step through this example, use the staging environment URL, which lets you configure the connections but does not deploy or charge for the services.

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

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

## Look up AWS port location details

To create a VXC to AWS, you need to know the AWS port details. Use the API to return the interfaces Megaport has with cloud service providers, to identify the required AWS port details.

**To look up AWS port location details in the Postman collection**

1. Expand the **Locations** folder in the left navigation and click **GET Partner Megaports**.

2. Click **Send** to make a GET request to the API server.

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

   This request returns all the interfaces Megaport has with Cloud Service Providers. You can search by clicking the magnifying glass and entering a location, data center, or other parameter in the search field.

   The connectType indicates the Cloud Service Provider. AWS includes "AWS" for Hosted VIFs and "AWSHC" for Hosted Connections.

   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=AWS&vxcPermitted=true
   ```

   This example uses a port in Interxion DUB2 that is accepting VXCs (`"vxcPermitted": true`) and is in the region eu-west-1.

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
      {
            "connectType": "AWS",
            "productUid": "6cc21ccb-5ecc-4869-ab0e-b3fa17f5110f",
            "vxcPermitted": true,
            "companyUid": "623cb950-abb4-4b07-b372-8cf55756c322",
            "companyName": "AWS",
            "title": "EU (Ireland) (eu-west-1)",
            "locationId": 96,
            "speed": 10000,
            "rank": 61,
            "lag_id": 2,
            "lag_primary": true,
            "aggregation_id": 54188
        },
```

## Create and deploy a VXC

With the AWS port details from the **GET Partner Megaports** API, you can validate and then create a VXC.

**To test and validate the order**

1. In Postman, expand **Cloud Connectivity > Port > AWS Direct Connect** in the left navigation and select **POST Validate AWS - Hosted VIF (v3)**.

2. Update the Body of the request with the `productUid` of the Port, the `productUid` of the AWS port, and the AWS account ID.\
   You can also change additional values, such as name, rate limit, contract term, VLAN ID, ASN values, authKey, and IP addressing.

3. Click **Send** to POST the request.

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

```json {3,15,22} theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
[
    {
        "productUid": "a49cf3f1-20a1-4390-93aa-5005bdafe3d7", 
        "associatedVxcs": [
            {
                "productName": "My Amazon Direct Connect",
                "rateLimit": "500",
                "term": 12,
                "shutdown": false,
                "promoCode": "promox3mnthfree2",
                "aEnd": {
                    "vlan": 777
                },
                "bEnd": {
                    "productUid": "6cc21ccb-5ecc-4869-ab0e-b3fa17f5110f", 
                    "partnerConfig": {
                        "connectType": "AWS",
                        "name": "Amazon name for service",
                        "type": "private",
                        "asn": 65105,
                        "amazonAsn": 64555,
                        "ownerAccount": "XXXXXXXXXXXX",
                        "authKey": "123456",
                        "prefixes": "10.0.1.0/24",
                        "customerIpAddress": null,
                        "amazonIpAddress": null
                    }
                }
            }
        ]
    }
]
```

When validated, you are ready to place the VXC order.

**To create a VXC**

1. Copy the validated Body from **POST Validate AWS - Hosted VIF (v3)** and paste into the Body of **POST Buy AWS - Hosted VIF (v3)**.

2. Click **Send** to post the request.

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

Here is an example of a successful response.

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
    "message": "VXC [47d6cc4d-6a1a-4301-b06c-cebb5f9b8f3e] created. ",
    "terms": "This data is subject to the Acceptable Use Policy https://www.megaport.com/legal/acceptable-use-policy",
    "data": [
        {
            "createDate": 1588868593704,
            "vxcOrderId": 42328,
            "payerMegaPortId": 68124,
            "nonPayerMegaPortId": 52786,
            "payerMegaPortName": "API Port",
            "nonPayerMegaPortName": "EU (Ireland) (eu-west-1)",
            "payerCompanyId": 2278,
            "nonPayerCompanyId": 117,
            "payerLocationId": 89,
            "nonPayerLocationId": 96,
            "salesId": null,
            "payerCompanyName": "Megaport Lab",
            "nonPayerCompanyName": "AWS",
            "payerMegaPortNsId": 138231,
            "nonPayerMegaPortNsId": 221182,
            "payerVlanId": 777,
            "nonPayerVlanId": 0,
            "payerApproverName": "Paul McGuinness",
            "payerApproverId": 12695,
            "nonPayerApproverName": "Paul McGuinness",
            "nonPayerApproverId": 12684,
            "payerApproval": 1582268553574,
            "nonPayerApproval": 1228868693614,
            "fixedTerm": true,
            "duration": 1,
            "rollover": true,
            "serviceName": "from API Port to EU (Ireland) (eu-west-1)",
            "payerStatus": "APPROVED",
            "nonPayerStatus": "APPROVED",
            "speed": 500,
            "distanceBand": "ZONE",
            "intercapPath": "",
            "awsId": null,
            "promoCode": null,
            "rateType": "MONTHLY",
            "vxcJTechnicalServiceId": 57115,
            "vxcJTechnicalServiceUid": "47d6cc4d-6a1a-4301-b06c-cebb5f9b8f3e",
            "provisionDate": 1588868593517,
            "orderType": "NEW",
            "monthlyDiscountAmount": null,
            "discountMonths": null,
            "amazonDirectConnectConfigDto": {
                "type": "private",
                "asn": 65105,
                "ownerAccount": "XXXXXXXXXXXX",
                "authKey": "123456",
                "customerIpAddress": null,
                "amazonIpAddress": null,
                "prefixes": "10.0.1.0/24",
                "name": "Amazon name for service"
            },
            "amsixConnectConfigDto": null,
            "webAirProvItem": null,
            "sdrcProvItem": null,
            "rate": null,
            "setup": null,
            "asn": null,
            "bgpPassword": null,
            "usageAlgorithm": "POST_PAID_HOURLY_SPEED_LONG_HAUL_VXC",
            "costCentre": null,
            "azureServiceKey": null,
            "oracleVirtualCircuitId": null,
            "serviceKey": null,
            "connectType": "AWS",
            "payerConfig": {},
            "nonPayerConfig": {},
            "attributeTags": {},
            "fullyApproved": true
        }
    ]
}
```

The Port and VXC now appear in the Megaport Portal.

<Image src="/images/api/api-csp-port-vxc.png" alt="Portal view of API port and VXC" shadow={true} width={800} />

For this example, the AWS Hosted VIF will appear in the AWS portal account under Direct Connect - Virtual Interfaces. The account holder can accept the Virtual Interface and connect it to a Virtual Private Gateway or a Direct Connect Gateway and then to their VPCs.
