Skip to content
Logging in

Logging in

The CLI talks to the AgentSpaces portal with an API key, a personal access token like GitHub’s and GitLab’s. You create keys in the portal; the CLI cannot create them. Keys are for your own computer (the command line, an agent on it, CI), not for inside a machine.

Create a key

  1. Sign in to the portal.
  2. Go to Account → API keys and create a key.
  3. Choose:
    • Name: something that tells you where it is used, like laptop or ci.
    • Organization: the key works in this one organization (asked only when you are in more than one).
    • Projects: All projects (every project of the organization, also ones made later) or Only selected projects (tick them). Requests for anything outside them are refused.
    • Permission: read and write, or read only. A read-only key can list and inspect but cannot create, change or delete anything.
    • Expires: in 30 days, 90 days (the default) or a year, or never.
  4. Copy the key. It is shown once; the portal keeps only a hash of it. If you lose it, revoke it and create a new one.
The Create an API key dialog under Account, API keys, filled in: the name laptop, Projects All projects, Permission Read and write and Expires In 90 days, with Cancel and Create key The Create an API key dialog under Account, API keys, filled in: the name laptop, Projects All projects, Permission Read and write and Expires In 90 days, with Cancel and Create key

Keys start with asp_. The portal lists your keys by their first 12 characters (for example asp_4Qm9abcd), so you can tell them apart without the full key.

A key acts as you, with your role in its organization at the time of each request, and only in its projects. If you leave the organization, your keys for it stop working straight away, except at a project’s developer MCP, where access ends within about half a minute. Keys made before personal access tokens reach one project each; they keep working until they expire or you revoke them.

Give the key to the CLI

space login

space login asks for the key without showing it, checks it against the portal and saves it in your config file (readable only by you). It prints who you are and the key’s name, prefix, permission and the projects it reaches. Its organization becomes your default.

The CLI talks to the hosted portal, https://app.agent-spaces.eu. To use another portal, pass --url https://<portal host> to space login; the URL is saved with the key.

The key is never a command-line argument, because arguments show up in ps and your shell history. To log in from a password manager or a script, pipe the key in:

pass show agentspaces | space login

In CI you need no config file at all; set the key as an environment variable instead:

export AGENTSPACES_API_KEY=<key>   # from your CI's secret store

Choose a project

A key that reaches one project works there. One that reaches several needs to know which project a command is about; otherwise the command stops and lists them. Name it, from the most specific:

  • --project <slug> (or -p) on the command, or AGENTSPACES_PROJECT;

  • a .space file in the directory you work in or one above it, so a checkout of a project’s code works in that project:

    org = "acme"
    project = "web"
  • the profile’s default, set with space use:

space projects          # the projects the key reaches
space use acme/web      # work in project web of acme from now on
space use               # what is in use, and where it comes from
space --project main machines list

Several accounts or portals

Each login is saved as a profile. Use --profile to keep more than one:

space login --profile staging --url https://<portal host>
space profiles                  # list, the default is marked
space profiles use staging      # make it the default
space --profile staging machines list

Check who you are

space whoami

This shows your user, the key in use (name, prefix, organization, the projects it reaches, permission, expiry), the project commands work in, the profile, and the organization with your role, region and SSH endpoint in it.

Log out

space logout

This removes the key from your config file. It does not revoke the key; do that in the portal under Account → API keys.

Keep keys safe

  • Use one key per computer or pipeline, so you can revoke one without breaking the others.
  • Give a key only the projects it needs: Only selected projects for CI.
  • Give CI a read-only key unless it must change machines.
  • No API key can add or remove SSH keys: an SSH key opens the machines of every project of your organizations, and an API key works in the projects it reaches. Do that in the portal under Account → SSH keys.
  • Prefer an expiry. Revoke keys you no longer use under Account → API keys.
  • Do not put a key in a command line you share, a repository or a container image.

A revoked or expired key stops working immediately; the CLI then reports that you are not authenticated (see Troubleshooting).

Last updated on