> ## 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 Megaport Object Storage Connection with the API

> This help topic describes how to use the Megaport API to create a Megaport Object Storage connection.

export const Link = ({href, children}) => {
  const errorPrefix = '\x1b[31;1;4mERROR\x1b[0m: Link -';
  if (typeof href !== 'string') {
    href = String(href);
  }
  if (!href || href === 'undefined') {
    console.error(`${errorPrefix} the \`href\` property is required — rendering an empty string instead`);
    return <></>;
  }
  if (href.includes('{') || href.toUpperCase().includes('%7B')) {
    console.error(`${errorPrefix} could not resolve a variable in href "${href}" — rendering an empty string instead`);
    return <></>;
  }
  const isExternal = (/^https?:\/\//).test(href);
  return <a href={href} className="link" target={isExternal ? '_blank' : undefined} rel={isExternal ? 'noreferrer' : undefined}>
      {children ?? href}
      {isExternal && <span className="sr-only"> (opens in a new tab)</span>}
    </a>;
};

This topic describes the API procedure to create a Megaport Object Storage connection from a Port, MCR, MVE, or NAT Gateway that you own. A Megaport Object Storage connection is a Virtual Cross Connect (VXC) with your existing service as the A-End and a storage destination as the B-End.

The steps include how to:

* get the `productUid` for the service to use as the A-End
* find the storage destination to use as the B-End
* validate and order the VXC

## Prerequisites

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

You also need:

* Object Storage provisioned in the <Link href="https://www.latitude.sh/dashboard/storage/object/object-storage">Latitude.sh Portal</Link>. For more information, see [Megaport Object Storage Overview](/storage/object).
* A provisioned Port, MCR, MVE, or NAT Gateway to use as the A-End of the connection.

For the equivalent Megaport Portal procedure, see [Creating a Megaport Object Storage Connection](/storage/object/creating-storage-connection).

## Getting the productUid for the A-End service

To create the VXC, you need the `productUid` of the service to connect from.

**To get the productUid for the A-End service**

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 Port, MCR, MVE, or NAT Gateway you want to connect from.

   This example uses this value: `ef59ff80-7f50-11f1-b1ba-59b488c88b57`

## Finding the storage destination for the B-End

The storage destination is the B-End of the connection. Discover the available storage destinations by filtering the Megaport partner interfaces on the `STORAGE` connect type.

**To find the storage destination**

1. Get the list of interfaces Megaport has with partners, filtered on the `STORAGE` connect type.

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

2. From the response, select the storage destination that matches the location where you provisioned your storage.

   <Note>
     Connect to the location where you provisioned your storage. Connecting to a different location does not provide access to your buckets.
   </Note>

   To order the VXC, you need the following IDs for the B-End from the response:

   * `locationId` -- The ID of the storage location.
   * `productUid` -- The storage port to connect to.
   * `companyUid` -- The ID of the storage provider, used as the `ownerUid` on the B-End.

## Validating and ordering the connection

You set the storage configuration on the B-End `partnerConfig`, where you specify the BGP details for the connection. The A-End `partnerConfig` is empty.

A storage connection requires BGP. At a minimum, specify the `asn`. You can add the BGP `password` when you create the VXC or after it is provisioned.

Set the B-End `vlan` to `-1` so that the storage port assigns the VLAN rather than you choosing one. Set the A-End `vlan` to `0`.

<Note>
  The validate endpoint uses v3 of the API while the buy endpoint uses v4.
</Note>

**To validate the configuration**

1. Create a request with this URL:

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

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

3. Create the request Body with the configuration details.

   The validate request Body is an array of design objects. Each design object identifies the A-End service with `productUid` and carries the storage VXC in `associatedVxcs`.

   ```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
   [
     {
       "productUid": "ef59ff80-7f50-11f1-b1ba-59b488c88b57",
       "associatedVxcs": [
         {
           "productName": "Storage Test",
           "rateLimit": 1000,
           "term": 12,
           "shutdown": false,
           "aEnd": {
             "vlan": 0,
             "partnerConfig": {}
           },
           "bEnd": {
             "locationId": 85,
             "ownerUid": "2f83dc65-5d4c-4730-a66d-926db48a0326",
             "productUid": "41bbbdbe-8aa4-4af2-91b4-d1d56f1db4aa",
             "vlan": -1,
             "partnerConfig": {
               "asn": "65333",
               "password": "new-password",
               "prefixes": null,
               "route_table": null,
               "connectType": "STORAGE",
               "complete": true
             }
           },
           "productType": "VXC",
           "connectType": "STORAGE"
         }
       ]
     }
   ]
   ```

   A successful response returns `"message": "Validation passed"` and the pricing details for the connection.

**To order the connection**

1. After you validate the configuration, create a request with this URL:

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

2. Create the request Body.\
   The buy request wraps the design objects from the validate step in a `networkDesign` array, alongside a `discountCodes` array.

   ```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
   {
     "discountCodes": [],
     "networkDesign": [
       {
         "productUid": "ef59ff80-7f50-11f1-b1ba-59b488c88b57",
         "associatedVxcs": [
           {
             "productName": "Storage Test",
             "rateLimit": 1000,
             "term": 12,
             "shutdown": false,
             "aEnd": {
               "vlan": 0,
               "partnerConfig": {}
             },
             "bEnd": {
               "locationId": 85,
               "ownerUid": "2f83dc65-5d4c-4730-a66d-926db48a0326",
               "productUid": "41bbbdbe-8aa4-4af2-91b4-d1d56f1db4aa",
               "vlan": -1,
               "partnerConfig": {
                 "asn": "65333",
                 "password": "new-password",
                 "prefixes": null,
                 "route_table": null,
                 "connectType": "STORAGE",
                 "complete": true
               }
             },
             "productType": "VXC",
             "connectType": "STORAGE"
           }
         ]
       }
     ]
   }
   ```

3. Send the request.

   If the request is successful, the response confirms the created VXC, including its `technicalServiceUid`. The VXC then appears in the Megaport Portal.

   ```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
   {
     "message": "VXC [a10475cd-6ca3-4c1d-ae31-90af53efb945] created.",
     "terms": "This data is subject to the Acceptable Use Policy https://www.megaport.com/legal/acceptable-use-policy",
     "data": [
       {
         "serviceName": "Storage Test",
         "technicalServiceUid": "a10475cd-6ca3-4c1d-ae31-90af53efb945",
         "provisioningStatus": "DEPLOYABLE",
         "productType": "VXC",
         "connectType": "STORAGE"
       }
     ]
   }
   ```

## Storage connection parameters

The storage configuration is set on the B-End `partnerConfig`.

| Parameter    | Description                                                                                                                                                                                          | Required | Valid input        |
| ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | ------------------ |
| connectType  | Identifies the connection as a storage connection.                                                                                                                                                   | Yes      | `STORAGE`          |
| asn          | The ASN used for the BGP session to your storage. Specify a private or public ASN, or use the default Megaport ASN, `133937`.                                                                        | Yes      | String             |
| password     | The shared key used to authenticate the BGP peer. You can add it when you create the VXC or after it is provisioned.                                                                                 | No       | 1 -- 25 characters |
| prefixes     | Public IPv4 prefixes to announce to Latitude.sh. `null` in this example. For guidance on prefixes, see [Creating a Megaport Object Storage Connection](/storage/object/creating-storage-connection). | No       | String             |
| route\_table | Present in the payload; `null` in this example.                                                                                                                                                      | No       | String             |
| complete     | Indicates the storage configuration is complete.                                                                                                                                                     | No       | `true`             |

<Note>
  In this example, `prefixes` and `route_table` are set to `null`. The format for populated values for these parameters is not covered in this example.
</Note>

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

## Helpful references

* [Creating a Megaport Object Storage Connection](/storage/object/creating-storage-connection)
* [Megaport Object Storage Billing](/finance/storage-billing)
* [Megaport Object Storage Overview](/storage/object)
* [Megaport Object Storage Pricing and Contract Terms](/finance/storage-pricing)
* [Terminating a Megaport Object Storage Connection](/storage/object/terminating-connection)
