Client SDK · Start here

Configuration.

Constructor options, config fields, and per-instance isolation.

MatildaClient

Python
client = MatildaClient(
    token="",                     # static Bearer JWT
    # keyword-only below:
    base_url=DEFAULT_BASE_URL,    # https://matilda.maincode.com/api
    get_token=None,               # async token provider
    config=None,                  # or pass a pre-built MatildaConfig
)
Fieldtypedescription
tokenstrA static access token. Use this for simple setups, or use get_token for managed refresh. Defaults to the empty string.
base_urlstrThe Matilda API base URL. Must be absolute for auth flows. Defaults to https://matilda.maincode.com/api.
get_tokenTokenProviderAsync token provider called on every request (and once with force_refresh=True after a 401, before the single retry). A managed TokenManager is wired here automatically after client.auth.login_with_*.
configMatildaConfigA pre-built config. When omitted, one is constructed from the other parameters.

MatildaConfig

A frozen dataclass — create a new client to change configuration.

Fieldtypedescription
base_urlstrThe Matilda API base URL. Defaults to https://matilda.maincode.com/api.
tokenstrStatic Bearer token. Defaults to the empty string.
get_tokenTokenProvider | NoneAsync token provider (see above).
timeoutfloatRequest timeout in seconds. Defaults to 120.0.
api_versionstrAPI version sent via the X-Matilda-API-Version header. Defaults to MATILDA_CURRENT_API_VERSION.
chunk_sizeintChunked-upload part size in bytes. Defaults to 8388608 (8 MiB).
chunked_thresholdintFile size at/above which uploads switch to the chunked protocol. Defaults to 16777216 (16 MiB).
part_concurrencyintParallel parts per chunked upload. Defaults to 4.
max_part_retriesintRetries per upload part before the session is aborted. Defaults to 3.

Environment URLs

EnvironmentBase URL
Productionhttps://matilda.maincode.com/api
Staginghttps://staging.matilda.maincode.com/api

Instance isolation

Each MatildaClient instance holds its own independent config. Multiple instances in the same process are fully isolated — constructor options are scoped to that instance.

Python
staging = MatildaClient(base_url="https://staging.matilda.maincode.com/api")
prod = MatildaClient(base_url="https://matilda.maincode.com/api")

print(staging.config.base_url)  # https://staging.matilda.maincode.com/api
print(prod.config.base_url)     # https://matilda.maincode.com/api

config (attribute)

Returns the current MatildaConfig.

Python
cfg = client.config
print(cfg.base_url, cfg.token)

origin (config property)

The scheme+host of base_url — the origin where core-auth endpoints live. Auth flows resolve endpoints against config.origin, so base_url must be an absolute URL:

Python
client.config.origin  # e.g. "https://matilda.maincode.com"