- API keys: long-lived credentials meant for use in trusted environments (ex. your application server).
- Ephemeral tokens (JWTs): short-lived access tokens meant for use in ephemeral, less-trusted environments (ex. an agent sandbox).
Basic Usage
The recommended pattern depends on how you mount MesaFS:- For app mounts, construct the SDK client with an API key in your trusted backend. When you call
mesa.fs.mount(...), the SDK signs a scoped JWT under the hood and uses it for that mount. - For POSIX mounts, mint a scoped, ephemeral token in your trusted backend, pass it into the sandbox as
MESA_API_KEY, then runmesa mountinside the sandbox.
ttl that covers the mount’s work.
REST and Git APIs
The REST API and Git server both accept a bearer credential, which can be either a durable API key or ephemeral JWT.REST API
Include the credential in theAuthorization header:
Git API
Use the credential as the password when cloning or pushing:Minting Credentials
Ephemeral Tokens
Usemesa.tokens.create(...) when you need to hand a credential to another environment, such as a sandbox where the Mesa CLI will run.
API Keys
API keys are long-lived bearer credentials. Use them for trusted services that need to create repos, manage API keys, mint tokens, or construct SDK clients. Your first API key is created in the Mesa dashboard. If you haven’t done this yet, follow the Quickstart to create the initial key. Construct SDK clients with an API key:expires_in_seconds, or without an expiration. Revoking an API key immediately invalidates the key and every ephemeral token signed from it.
Scopes
Scopes are hierarchical. Each level includes the permissions from the levels below it.| Scope | Description |
|---|---|
read | Clone, fetch, and view repositories, bookmarks, changes, commits, diffs, and content |
write | Everything read can do, plus push, create/update/delete repos, and create/move/delete bookmarks and changes |
admin | Everything write can do, plus API key and webhook management |
Common Failures
| Symptom | Likely cause |
|---|---|
UNAUTHORIZED | The API key or token is missing, malformed, expired, or revoked |
FORBIDDEN | The credential is valid but lacks the required scope or repository access |
| Mount starts but later fails with auth errors | The mount’s credential expired; re-mint a token and remount |
| Sandbox can access too many repos | The token was not repo-scoped; mint it with repos: ["org/repo"] |

