Skip to content

Installation

Interact with Mayhem from your command line by installing the Mayhem CLI and connecting your account credentials. Let's quickly walk you through how to install the Mayhem CLI on your machine.

The Mayhem CLI for testing APIs is available to download for common platforms, such as:

  • macOS
  • Linux (64-bit)
  • Windows (64-bit)

Downloading and Installing the Mayhem CLI

Navigate to the Mayhem CLI Installation page and download the Mayhem CLI for API testing for your corresponding operating system:

api-testing-cli-installation

Test it out!

Make sure the API testing CLI works by running:

mapi --help

Authentication

The mapi CLI communicates with our API using OAuth 2.0 Bearer Tokens. The token will be read by the environment variable, MAPI_TOKEN, if available.

To get a new token, visit the Manage API Tokens page page to create a new token, <NEW_TOKEN>, and login:

$ mapi --mayhem-url https://app.mayhem.security login <API_TOKEN>
Login successful -- Welcome to Mayhem!

We have saved your API token in local settings at '/Users/andrewyang/.config/mayhem/mayhem'.

Setting the displayed API Token to the environment variable, MAPI_TOKEN, will allow you to run the CLI on other computers, such as part of your Continuous Integration build.

Now you can try contacting the API. Let's get the list of targets to which you have access:

mapi target list

You should see an (empty) list of API targets. Let's add our first target so that list won't stay empty for long.