Skip to main content
An account service key is a long-lived machine credential for your account. Use one for automation that must act as your account where no one can approve a browser-based device login, such as a script that runs photon account commands. A service key acts as your account. Treat it like a password. Which credential to use (see the full table):
  • Your own machine: photon login.
  • CI: a service identity API key with only the permissions the job needs. See Use a key in CI.
  • An app’s own calls: a project API key.
  • Automation that must act as your account: an account service key.
  • Creating or rotating keys: a person, not CI or an agent.

Create a key

Every key needs a name and an explicit expiry decision. Pass either --expires-at with an RFC 3339 timestamp, or --no-expiry:
Names are limited to 128 characters. An expiry must be in the future and no more than 3650 days out.
The credential is printed once, when the key is created. Photon returns the secret only when it creates the key. The list and revoke responses carry the key’s metadata without it. Copy it into your secret store before the command scrolls away.

Use a key in CI

CI gets a service identity API key, unless the job must act as your account, such as one that runs photon account commands. A service identity API key works in one organization, across its projects, and holds only the permissions a person grants it in the Dashboard, under the organization’s service identities. Grant only what the job needs. This job lists a project’s webhooks, so its key holds only project:read:
Every command uses the key in PHOTON_API_TOKEN, and the CLI saves no credential for it. An account service key goes in the variable the same way, for automation that must act as your account. See which credential to use and how the CLI uses a key from the environment.

Sign in with a key

On a machine that should stay signed in, such as a long-lived server, save the key with photon login --service-key. It reads one complete credential from non-interactive stdin. The CLI refuses to read it from a terminal, so it never lands in your shell history or in the process list:
The CLI verifies the key against Photon before storing it. If you are already signed in, add --force to replace the current session:
On machines with no OS keychain, as in most containers, the CLI stores the key in a plain-text file and says where. While PHOTON_API_TOKEN is set, photon login --service-key refuses, because the variable’s key would win. See where credentials are stored. After signing in, every other command works exactly as it does for a human session:

List and revoke keys

list shows unrevoked keys only, expired ones included, newest first. Photon’s response carries each key’s metadata without its secret:
Revocation is immediate and cannot be undone:
revoke asks for confirmation unless you pass --yes. Automation must pass it, since a non-interactive command with no answer exits with code 2.

Credential format

A service key is a pho_ask_ prefix, a 26-character key ID, and a secret. The key ID is the part you pass to revoke and the part that appears in list output. The whole credential is at most 512 bytes and must be piped in exactly as issued, with no surrounding whitespace beyond a single trailing newline.

Recovery

create and revoke are journaled mutations. If the network fails after the request leaves your machine, the result is recorded and you can replay it — see Recoverable operations. This matters most for create, where a lost response means a lost credential.