API keys
An API key lets ons, the E2B SDKs and your own code call the onshore.sh API for one organization. It looks like msb_<id>_<secret>. Only the prefix msb_<id> is ever shown again after creation.
Get a key
Section titled “Get a key”ons loginons login opens a page in your browser and prints a code (XXXX-XXXX). Sign in, type the code, and ons saves a new key named msb login · <host>. <host> is your machine’s name.
- The key is saved with its domain in
~/.config/onshore/config.toml, readable only by you. - If you belong to several organizations, pick one with
ons login --org <organization-id>. - When the browser runs on another machine, add
--pasteand paste the address the browser ends on. - A new
ons loginfrom the same machine revokes the key of the previous one, unless that key still owns live miniVMs or AI accounts.onstells you which keys it kept.
- Open onshore.sh/app → API keys.
- Give the key a name (1 to 64 characters), such as the job or service that uses it.
- Copy the key. It is shown once.
Store it in your CI’s or platform’s secret store, never in a repository.
ons login --agentAn AI agent signs in with its own agent identity in its own browser. The key lasts 1 hour and belongs to its owner’s organization. When calls start answering 401, the agent runs ons login --agent again. The owner must have signed in to the console once.
Use a key
Section titled “Use a key”| Where | How |
|---|---|
ons |
ons login saves it. In CI, set ONS_API_KEY instead; it wins over the saved login. |
| E2B SDKs | Set E2B_API_KEY=<your-key> and E2B_DOMAIN=onshore.sh. ons ignores these two variables. |
| REST API | Send the header X-API-Key: <your-key> to https://api.onshore.sh. |
<your-key> is the full key, msb_….
To pass a key to ons login from a script, pipe it on stdin:
printf '%s\n' "$ONS_API_KEY" | ons login --keyWhat a key can see
Section titled “What a key can see”- A key sees and acts on the miniVMs it created. Another key of the same organization does not see them through the API.
- In the console, every member sees all the organization’s miniVMs (shape and who started them, never their environment, metadata or tokens). Members pause, resume and kill the miniVMs of their own keys; owners act on any. See Organizations.
- A key calls the miniVM and template API. It cannot create keys, manage members or change billing: that is done in the console.
Revoke a key
Section titled “Revoke a key”Open API keys in the console and revoke the key. Members revoke the keys they created; owners revoke any key.
- Revocation takes effect within 5 seconds and is final.
- The miniVMs the key created keep running, but nothing can act on them through that key anymore. Kill them from Fleet in the console, or let them reach their timeout. A miniVM of a revoked key cannot be resumed.
Rotate a key
Section titled “Rotate a key”- Create a new key.
- Deploy it where the old one was used.
- Kill or let end the miniVMs the old key created: the new key cannot reach them.
- Revoke the old key.
If a key leaked, revoke it at once, then rotate.
Limits
Section titled “Limits”- An organization holds at most 100 active keys.
- An organization creates at most 200 keys per 24 hours, revoked ones included.
- Repeated calls with a wrong key are rate-limited per client address.