Skip to content
Authentication

Authentication

Every request the CLI sends carries an API key of your project. Save keys once with status200 login, one context for each environment, or hand them to a command in flags or environment variables, as scripts do. This page shows each way, and which one a command uses when there are several.

Before you begin

You need an API key of your project. Create one in Project Settings → Advanced → API Keys with Create API Key, and give it the access your commands need: see Create an API key. A key does what its permissions allow, so a key that may only read records can list and read them, but not change them.

On Status200 Cloud, API keys work only while the project is on the Growth plan or above. Below it, every command answers API error (402) with a message that names the plan, until the project is upgraded; then the same key works again. See API keys and SCIM below their plan.

Log in

status200 login saves an API key and your Status200's address as a context, and makes it the current context:

Bash
status200 login <api-key> <instance-url> [--context-name <name>]
Argument or optionWhat it is
<api-key>An API key of your project
<instance-url>Your Status200's address: https://status200.ru, or your own server's, such as https://status200.example.com
--context-name <name>The name to save the context under. Default: default

For example, a context named production:

Bash
status200 login <api-key> https://status200.ru --context-name production

It answers Logged in successfully. Context "production" is now active. A slash at the end of the address is removed, and logging in again under the same name replaces that context.

Note
login saves the key without asking Status200 about it. Run a command, such as status200 incident count, to see that the key works.

Contexts

A context is a saved login: a name, an address and an API key. Save one for each project or environment, then choose one for all the commands that follow, or for a single command.

  1. Save a context for each environment

    Bash
    status200 login <production-api-key> https://status200.ru --context-name production
    status200 login <staging-api-key> https://status200.example.com --context-name staging

    Each login makes its context the current one, so staging is current now.

  2. List them

    Bash
    status200 context list
    ┌───┬────────────┬───────────────────────────────┐
    │   │ Name       │ URL                           │
    ├───┼────────────┼───────────────────────────────┤
    │   │ production │ https://status200.ru          │
    ├───┼────────────┼───────────────────────────────┤
    │ * │ staging    │ https://status200.example.com │
    └───┴────────────┴───────────────────────────────┘

    The * marks the current context. API keys are never listed.

  3. Switch to another context

    Bash
    status200 context use production

    It answers Switched to context "production". and the commands that follow use it.

  4. Use a context for one command

    Bash
    status200 incident list --context staging

    The current context stays as it was.

CommandWhat it does
status200 context listLists the saved contexts; * marks the current one. With -o json, each context's name, apiUrl and isCurrent, never its key
status200 context use <name>Makes a saved context the current one
status200 context currentShows the current context's name, URL and API key, with all but the first four and last four characters of the key hidden
status200 context delete <name>Deletes a saved context. If it was the current one, the first context left becomes current

Which credentials a command uses

A command needs an API key and a URL. It takes each of the two from the first of these places that has it:

flowchart TB F["1. Flags on the command:<br/>--api-key and --url"] --> E["2. Environment variables:<br/>STATUS200_API_KEY<br/>and STATUS200_URL"] E --> N["3. The context named<br/>with --context"] N --> C["4. The current context"] C --> X["Not found anywhere:<br/>the command stops"]

Where a command finds its API key and its URL

So you can mix them: an API key from an environment variable with the URL of the current context, for example. Environment variables suit scripts and CI jobs, which have no saved contexts:

Linux

Bash
export STATUS200_API_KEY=<api-key>
export STATUS200_URL=https://status200.ru
status200 incident list

macOS

Bash
export STATUS200_API_KEY=<api-key>
export STATUS200_URL=https://status200.ru
status200 incident list

Windows

PowerShell
$env:STATUS200_API_KEY = "<api-key>"
$env:STATUS200_URL = "https://status200.ru"
status200 incident list

Flags come before everything else, for one command:

Bash
status200 --api-key <api-key> --url https://status200.ru incident list
Warning

A key given as a flag lands in your shell history, and other users of the machine can see it in the process list. On a shared machine, use a context or an environment variable instead.

Check what the CLI will use

status200 whoami shows the URL and the API key the next command will use, and the context they come from:

Bash
status200 whoami
URL:     https://status200.ru
API Key: 4f1c****0a13
Context: production

Only the first four and the last four characters of the key are shown. The Context line appears only when the URL and the key are that context's own, not values a flag or an environment variable replaced. whoami reads your settings without calling Status200: it shows what a command will send, not whether Status200 accepts it. With nothing saved or set, it answers:

Not authenticated. Run `status200 login` to authenticate.

The configuration file

status200 login saves contexts in ~/.oneuptime/config.json, in your home folder (%USERPROFILE%\.oneuptime\config.json on Windows). The CLI creates it so that only your user can read and write it (mode 0600):

~/.oneuptime/config.jsonJSON
{
  "currentContext": "production",
  "contexts": {
    "production": {
      "name": "production",
      "apiUrl": "https://status200.ru",
      "apiKey": "<api-key>"
    },
    "staging": {
      "name": "staging",
      "apiUrl": "https://status200.example.com",
      "apiKey": "<api-key>"
    }
  }
}

The file holds the API keys as they are: keep it out of shared folders, backups and repositories. To log out of one context, delete it with status200 context delete <name>; to log out of all of them, delete the file. A key that may have leaked stays valid until you delete it in Status200, in Project Settings → Advanced → API Keys.

Output formats and list sizes are not saved here: give -o and --limit to each command.

Troubleshooting

No credentials found

Authentication error: No credentials found. means no flag, environment variable or saved context gave the command its API key and URL. Run status200 login, or set both STATUS200_API_KEY and STATUS200_URL. The command exits with code 2.

API error (400): Invalid API Key

The key is not an API key of Status200, has expired, or was reset. Copy it again from its page in Project Settings → Advanced → API Keys, where its Expires date is too, and log in again under the same context name. The command exits with code 2.

API error (402): API keys need the Growth plan

On Status200 Cloud, the project is below the Growth plan, so its API keys stopped working. Upgrade the project, and the same key works again: nothing to change in the CLI.

API error (422): You do not have permissions

The key's permissions do not reach what the command asks for. Give the key a role or a permission on its page in Project Settings → Advanced → API Keys: the message names the permissions that would let the request in.

Context "staging" does not exist

No context of that name is saved. status200 context list shows the names there are.

whoami shows another URL or key than the context has

An environment variable or a flag replaces the context's value. env | grep ONEUPTIME shows the variables that are set, and unset STATUS200_API_KEY STATUS200_URL goes back to your contexts.

Request failed to the address

Error: Request failed to https://... means the CLI could not reach Status200 at that address. Check the URL with status200 whoami: it is the address you open Status200 at, with https://, such as https://status200.ru.

Next steps