Getting started with the Gremlin API
All requests to the Gremlin REST API require an access token provided in the Authorization Header. There are two ways to retrieve an access token:
- By authenticating using your Gremlin account credentials and receiving a
Bearer
token. - By using a user or team-level API key.
Authenticating using your Gremlin credentials
Authenticating with a username and password
If you log into Gremlin using a username and password, you can receive a Bearer
token by providing your credentials to /users/auth
:
Authenticating with multi-factor authentication (MFA) enabled
If you have MFA enabled, include the token from your password authenticator in your call to /users/auth/mfa/auth:
If you’re a member of more than one company, you can specify the company by adding companyName=’[your company name]’
.
Receiving the bearer token
If your authentication was successful, Gremlin will return a JSON response containing a bearer token, as well as other information about your session:
Note the ”header”: “Bearer …”
key-value pair. You’ll need this value for future API calls.
Formatting API calls using bearer tokens
When running API calls, include your bearer token as a header. For example, this command starts a CPU experiment using the bearer token from Receiving the bearer token:
Authenticating using API keys
Instead of using your username and password, you can authenticate using API keys. These are tied to your Gremlin user account and have the same privileges as your user. This also lets you create user accounts specifically for running API commands (i.e., “service accounts”).
Creating a new API key
- Go to your Account Settings and select the API Keys tab.
- Click the New API Key button.
- Give your key a unique Name and an optional Description.
- Click save, and copy your key.
Now, when formatting an API call, use Authorization: Key [api key]
in place of Authorization: Bearer [bearer token]
:
Revoking an API key
- Go to your Account Settings and select the API Keys tab.
- Click on the 3 dots to the right of your API Key.
- Select Revoke Key and confirm by clicking the Revoke button.
If you want to reinstate a revoked API key, click Reinstate Key instead.
API Key limitations
There is a limit of 5 active API keys per user.
Managing API keys on the Company level
For users with the API_KEYS_READ, API_KEYS_WRITE, or ALL_API_KEYS_READ privileges, there is now an API Keys tab located on the Company Settings page. This page lists all user-level API keys that your users have created. You can search by the name of the API Key or the name of who created it. This is to provide insight for if you plan to remove a user or edit their roles, you know what API keys will be affected by the change.