Skip to main content

Authentication

Every endpoint documented in this section except GET /v1/health requires a bearer token:

Authorization: Bearer <token>

Two kinds of credential

The same header accepts two credential types, and they do not have the same reach.

Session tokenAPI key
Looks likeA JWT issued when you sign in to the consoleshk_ followed by 48 hex characters
Where it comes fromThe browser session, refreshed automaticallyCreated once under API Keys in the console
LifetimeShort-lived; expires and refreshesUntil you revoke it
Role it acts withYour real role in the organization, admin or memberAlways member
OrganizationWhichever one you selectOnly the organization the key was created in
Account endpoints (/v1/me, /v1/ssh-keys)AllowedRejected with 401 TOKEN_INVALID
Admin actions, including billingAllowed if you are an adminRejected with 403 ADMIN_REQUIRED

Use an API key for anything that runs unattended. Session tokens expire, so a script that carries one stops working without warning. See API keys for how to create and revoke them.

curl -s "$SUPERHEAT_API/v1/instances" \
-H "Authorization: Bearer $SUPERHEAT_KEY"

Choosing the organization

Instances, templates, balances and keys belong to an organization. The X-Org-Id header picks which one a request runs against:

HeaderSession tokenAPI key
AbsentYour personal organizationThe key's own organization
Set to an organization you belong toThat organization, with your role thereAllowed only if it matches the key's organization
Set to an organization you do not belong to403 NOT_A_MEMBER403 ORG_MISMATCH
Not a valid id400 INVALID_ORG_ID403 ORG_MISMATCH — a key compares the header against its own organization id before validating it
curl -s "$SUPERHEAT_API/v1/instances" \
-H "Authorization: Bearer $SUPERHEAT_KEY" \
-H "X-Org-Id: 9c1b7d4e-3a52-4a1f-8c6d-b0e9f2a71c48"

List the organizations you can act in with GET /v1/orgs, which returns each one's id, name, personal flag, your role and the balance. That call needs a session token.

Failure modes

StatusCodeMeaning
401TOKEN_INVALIDMissing header, malformed token, unknown or revoked API key, or an API key sent to an account endpoint
401TOKEN_EXPIREDThe session token is past its expiry — sign in again
403NOT_A_MEMBERThe X-Org-Id organization is not one of yours
403ORG_MISMATCHThe API key belongs to a different organization than X-Org-Id
403ADMIN_REQUIREDThe action is admin-only, or you tried it with an API key
400INVALID_ORG_IDX-Org-Id is not a valid id on a session-token request

Full response shapes are in Errors.

Treat a key like a password

Anyone holding an shk_ key can deploy instances that spend your organization's balance. Keep keys out of source control and revoke any key you have pasted somewhere you cannot control.