Skip to main content
When you embed Amika, each of your users is an end-user in your Amika organization. Your users don’t need Amika accounts. Amika creates an end-user the first time your backend acts for it, using your own ID for that user. This guide sets up your backend, creates a rig for a user, and shows how to remove a user’s access. The API reference has every endpoint, field, and error code. For diagrams of how your backend and your users authenticate, see End-user auth model.

Each user owns their rigs

An end-user owns the rigs and hosts it creates. Only that user can use them: open SSH or open service ports.
The API that runs a command on a rig, and the API that reads a rig’s files, are not available to end-users yet. Until then, an end-user runs commands over SSH, for example amika rig ssh <rig> -- <command>.
Other users can’t see them at all. Your own team can see, stop, and delete them, for support and cleanup. Your team can’t get into them: no SSH, no commands, no file reads. It also can’t start a stopped rig, since starting runs code on it.

Set up your backend

1

Turn on end-users

End-users are off by default. Contact Amika to turn them on for your organization.
2

Create an act-as key

An organization owner creates an API key with only the end-users:act-as permission, under Settings → API Keys. Admins and members cannot create this key. Store it on your backend only.This key can act for your users, but it can’t read your organization’s own data. A key can’t have both end-users:act-as and org:access, so a request that forgets to name a user never sees every user’s data.
3

Act as a user

Add the Amika-As-Principal header with your ID for the user. The request runs as that user, with exactly that user’s access.
Without the header, the key gets 403 on every route except token minting and user disable.

Create a rig for a user

Create the rig with the act-as header. The user owns the rig.
A user’s rig gets none of your organization’s credentials: no API key, no secrets, no integrations, and no GitHub token. The create refuses fields that would attach them, such as secret_env_vars or a snapshot. The user has root on the rig, so anything on it is theirs to read.

Give your app a token for the user

If your user’s own app or CLI talks to Amika directly, mint a short-lived principal token for that user. Send this request without the act-as header.
The token can do only what the user can do. It lasts one hour by default, and 24 hours at most (ttl_seconds). In your client app, the TypeScript SDK can get a new token from your backend before the old one expires:
With a token, the user can:
  • Create, list, stop, start, and delete their rigs.
  • Open SSH, and use their rigs’ services and ports.
  • Add and delete their own SSH keys.
  • Connect their own machines as hosts. See the next section.
The rest of the API, such as organization settings, secrets, and API keys, is closed to them. The web terminal isn’t available on a user’s rig yet.

Let users connect their own machines

A user can run rigs on their own machine. They install the amika-hostd daemon there, and it registers the machine as a host that the user owns. Your team can see the host, but it can’t use it or put rigs on it.
1

Get a token for the user

Your backend mints a principal token and gives it to the user, for example through your app or CLI. Don’t give the user one of your organization’s API keys.
2

Install the daemon

On the user’s machine:
3

Set up and start the host

Pass the user’s token in AMIKA_HOSTD_API_KEY for each command. Don’t write it to a file.
up registers the host to the user. The daemon keeps only its own host secret, not the user’s token. With bare_metal, a rig is the machine itself. See Bring your own compute for the other runtimes and options.
The user, or your backend acting as the user, can now create rigs on the host. Host names are per user, so two users can each have a my-laptop. Your organization’s own work never runs on a user’s host. amika-hostd up registers the host each time it starts. To restart the daemon later, pass a new token, since tokens expire.

Rigs that create rigs

Each user’s rig gets its own credential, AMIKA_RUNTIME_TOKEN, so code on the rig can call Amika. With it, the rig can create more rigs for the same user, and connect to, stop, start, and delete the rigs it created. It can stop and delete itself, but it can’t start itself or reach the user’s other rigs. Amika replaces the credential each time the rig starts. To create a rig with no credential, pass "rig_credential": "none". A bare-metal rig never gets one.

Find users’ rigs in your organization

Your team’s rig, host, and snapshot lists show only your organization’s own resources by default. To see users’ resources, pass owner=end_user or owner=any. Each resource has an owner field that names the user.
Use a key with org:access here, not your act-as key.

Remove a user’s access

When a user leaves, disable them. The TypeScript SDK has no call for this yet, so use the HTTP API.
Their tokens stop working, their open SSH sessions close, and their queued work doesn’t run. Amika stops their running rigs within a few minutes. It’s safe to call again. If it returns 502, call it again to finish.
Sharing a rig between users isn’t available yet. Today each rig belongs to one user.