Skip to content
Beginner - Solutions Architect - Sales 10 minutes

First Commands

Run your first Megaport CLI commands — list locations, explore resources, and understand output formats

Prerequisites

  • Megaport CLI installed
  • Credentials configured (env vars or config profile)

With the CLI installed and authenticated, let's explore what you can do. We'll start with commands that work against public data so you can try them without a Megaport account.

Check your setup

bash
# Confirm the CLI is installed and which version
megaport-cli version

# Show your current config (active profile, defaults)
megaport-cli config view

List locations

Locations are the 700+ data centres on the Megaport fabric. This is a great first command — it works without credentials and shows the breadth of the network.

bash
megaport-cli locations list

Example output:

text
┌──────────────────────────────┬────────────┬──────────────┬────────┬───────────────┐
│ NAME                         │ COUNTRY    │ METRO        │ STATUS │ MCR AVAILABLE │
├──────────────────────────────┼────────────┼──────────────┼────────┼───────────────┤
│ NextDC S1 Sydney             │ Australia  │ Sydney       │ ACTIVE │ true          │
│ Equinix SY3 Sydney           │ Australia  │ Sydney       │ ACTIVE │ true          │
│ NextDC M1 Melbourne          │ Australia  │ Melbourne    │ ACTIVE │ true          │
│ Equinix ME1 Melbourne        │ Australia  │ Melbourne    │ ACTIVE │ true          │
│ NextDC B1 Brisbane           │ Australia  │ Brisbane     │ ACTIVE │ false         │
└──────────────────────────────┴────────────┴──────────────┴────────┴───────────────┘

Filter locations

bash
# By country
megaport-cli locations list --country AU

# By metro area
megaport-cli locations list --metro Singapore

# Only locations that support MCR (Cloud Router)
megaport-cli locations list --mcr-available

# By data centre name
megaport-cli locations list --name "Equinix"

# Fuzzy search — quick way to find a location
megaport-cli locations search "Equinix Sydney"

Output formats

Every list and get command supports four output formats via the --output flag (short: -o).

Table (default)

Human-readable — great for interactive use:

bash
megaport-cli locations list --metro Sydney --output table

JSON

Structured output — ideal for scripting, jq filtering, and automation:

bash
megaport-cli locations list --metro Sydney --output json
json
[
  {
    "id": 3,
    "name": "NextDC S1 Sydney",
    "country": "Australia",
    "metro": "Sydney",
    "market": "AU",
    "status": "ACTIVE",
    "mcr_available": true,
    "mve_available": true
  }
]

CSV

Spreadsheet-friendly — pipe into files or tools:

bash
megaport-cli locations list --output csv > locations.csv

XML

bash
megaport-cli locations list --output xml

Set a default format

If you prefer JSON for all commands:

bash
megaport-cli config set-default output json

Explore your resources

These commands require authentication (active credentials in your profile or env vars).

Ports

bash
# List all your ports
megaport-cli ports list

# Filter by name
megaport-cli ports list --port-name "Sydney"

# Filter by location
megaport-cli ports list --location-id 3

# Include cancelled/decommissioned ports
megaport-cli ports list --include-inactive

# Get full details on a specific port
megaport-cli ports get <PORT-UID>

VXCs

bash
# List all Virtual Cross Connects
megaport-cli vxc list

MCRs

bash
# List all Megaport Cloud Routers
megaport-cli mcr list

# Get details on a specific MCR
megaport-cli mcr get <MCR-UID>

Dashboard

Get an overview of all your resources at a glance:

bash
# Combined status dashboard — shows all ports, MCRs, MVEs, VXCs, and IXs
megaport-cli status

# Or list individual resource types
megaport-cli ports list
megaport-cli vxc list
megaport-cli mcr list

# See resource relationships as a tree
megaport-cli topology

Get details on a resource

bash
# Port details
megaport-cli ports get abc-1234-5678-def

# Location details
megaport-cli locations get 3

# MCR details
megaport-cli mcr get abc-1234-5678-def

Getting help

Built-in help is always available for any command or subcommand:

bash
# Top-level help — lists all command groups
megaport-cli --help

# Help for a command group
megaport-cli ports --help

# Help for a specific subcommand — shows all flags
megaport-cli ports buy --help
megaport-cli vxc buy --interactive
megaport-cli locations list --help
💡

Try it live in your browser

All of these commands work in the browser-based terminal — no install needed. Enter your API credentials and start running commands right now.

→ Open the Live Demo


What's next?

You've got the fundamentals. Pick a path: