The Mesa Python SDK is the ergonomic async client for Mesa. It wraps the generatedDocumentation Index
Fetch the complete documentation index at: https://docs.mesa.dev/llms.txt
Use this file to discover all available pages before exploring further.
mesa-rest client, resolves the default organization for you, and exposes a native virtual filesystem for repo I/O and shell execution.
Python 3.10 or newer is required.
Installation
Create a client
Client options
API key used as a bearer token. If omitted, the SDK reads
MESA_API_KEY from the environment. If neither is present, construction raises MissingApiKeyError.REST API base URL. Defaults to
https://api.mesa.dev/v1. http and https are accepted. Trailing slashes are stripped.VCS service URL used by
mesa.fs.mount(...). Leave unset for the default Mesa deployment. Set this when using a non-default API deployment with MesaFS.Default organization slug. When provided, SDK calls skip
/whoami for organization resolution.Appended to the SDK user agent. The default user agent starts with
mesa-sdk-python.Client lifecycle
Create oneMesa client for your process or application and reuse it across request handlers. If your framework has a lifespan hook and you want explicit cleanup, wrap the client in async with Mesa(...) at application lifespan, not inside each handler.
Organization resolution
The SDK chooses an organization in this order:| Source | When it applies |
|---|---|
Per-call org | The method call passes org="...". |
Constructor org | The client was created with Mesa(org="..."). |
mesa.whoami() | No per-call or constructor org was supplied. The result is cached. |
Resource namespaces
| Namespace | Purpose |
|---|---|
mesa.repos | Create, read, update, delete, pull, and push repositories. |
mesa.sync_runs | Read repository upstream sync history. |
mesa.content | Read files, symlinks, and directory listings without mounting. |
mesa.changes | Create, patch, and inspect Mesa changes. |
mesa.diffs | Inspect diffs and conflicts between changes. |
mesa.bookmarks | Manage branch-like bookmark refs. |
mesa.api_keys | Create, list, and revoke Mesa API keys. |
mesa.webhook_targets | Manage outbound webhook targets. |
mesa.fs | Mount repos as a virtual filesystem and run Bash commands. |
mesa.org | Fetch organization metadata. |
Response objects
The high-level SDK returns model instances generated bymesa-rest. Use attribute access, not dictionary access.
Common types
Import common dataclasses and native result types frommesa_sdk.
| Type | Purpose |
|---|---|
Author | Commit author or committer identity. |
FileUpsert | Create or replace one file in a change. content must be base64-encoded. |
FileDelete | Delete one file in a change. |
WholeFileResolution | Resolve a conflicted path by replacing full content or taking one side. |
HunkResolution / HunkFix | Resolve individual conflict hunks. |
RepoConfig | Pin a mounted repo to a bookmark or change. |
DiskCacheConfig | Configure on-disk MesaFS cache placement and size. |
FsStat | File metadata returned by stat and lstat. |
ChangeInfo | Change metadata returned by mounted filesystem change operations. |
ExecResult | Output from fs.bash().exec(...). |
mesa_sdk.types:
mesa.repos.update(...), UpstreamConfig.auth is tri-state: omit to preserve existing credentials, pass None to clear credentials, or pass TokenAuth / UsernamePasswordAuth to set credentials.
Error model
REST API operations raiseMesaError subclasses.
| Exception | Status | Meaning |
|---|---|---|
ValidationError | 400, 406 | Invalid request parameters or unacceptable response variant. |
AuthenticationError | 401 | Missing or invalid API key. |
AuthorizationError | 403 | The API key does not have the required scope. |
NotFoundError | 404 | Requested resource does not exist. |
ConflictError | 409 | Resource conflict, optimistic concurrency failure, or merge conflict. |
RateLimitError | 429 | Rate limit exceeded. |
ServerError | 5xx | Server-side failure. |
MissingApiKeyError, InvalidApiUrlError, OrgResolutionError, and InvalidOptionsError.
Filesystem and Bash operations raise built-in Python exceptions such as FileNotFoundError, FileExistsError, IsADirectoryError, NotADirectoryError, PermissionError, NotImplementedError, and OSError.
Raw generated client
mesa.raw exposes the authenticated generated mesa-rest client. Use it when the high-level SDK does not expose a generated REST operation or option yet.
Response[T] wrapper with status_code, parsed, and headers. High-level SDK methods unwrap successful responses and raise typed errors for non-2xx responses.

