Skip to main content

MTX API PY

Python SDK (wrapper) to consume the MTX API.

Installation

pip install mtx-api-py

Quick start

import asyncio
from mtx_api import MTXClient


async def main():
    async with MTXClient(
        base_url="https://api.mtx.example.com",
        client_id="<YOUR_CLIENT_ID>",
        jwt_secret="<BASE64_SECRET>",  # optional; only if you will use auth.login_jwt
    ) as client:
        ok = await client.base.status(access_token="<ACCESS_TOKEN>")
        print(ok)


asyncio.run(main())

Configure via environment variables

Each MTXClient argument left out is read from its environment variable. The SDK does not read .env files: load yours first, for example with load_dotenv() from python-dotenv as in the example below.

# .env
MTX_BASE_URL=https://api.mtx.example.com
MTX_CLIENT_ID=<YOUR_CLIENT_ID>
MTX_JWT_SECRET=<BASE64_SECRET> # Optional: only needed if you will use login_jwt
MTX_OPEN_ID_AUTH_URL=<AUTH_URL> # Optional: only needed for the OpenID login
MTX_OPEN_ID_CLIENT_KEY=<CLIENT_KEY> # Optional: only needed for the OpenID login
MTX_APP_KEY=<YOUR_APP_KEY> # Optional: numeric key of your MTX application, sent as app_key
MTX_REDACT_LOGS=false # Optional: show secrets and personal data in debug logs
MTX_TIMEOUT=60 # Optional: seconds each call waits for the platform

The SDK logs each call on logger mtx_logs: the method and path at INFO, and a curl-style line and the response, error responses included, at DEBUG. It raises errors without logging them, so your application decides whether and how to log each one. Set its level with logging.getLogger("mtx_logs").setLevel(...).

Debug logs mask secrets and personal data, such as emails, names and phones: the value of every header or field named in SENSITIVE_LOG_KEYS is replaced by the REDACTED placeholder, and so is, in what the SDK sends, every field or query parameter named in SENSITIVE_REQUEST_KEYS, which adds the codes the user types (all three constants in mtx_api/client/_mtx_http_client.py). Disable it with MTX_REDACT_LOGS=false or MTXClient(redact_logs=False); it only changes what is logged, never what is sent. The SDK leaves the httpx logger as your application configures it; at INFO it logs the method, URL and status of each call.

import asyncio
from mtx_api import MTXClient
from dotenv import load_dotenv

load_dotenv()  # Load environment variables from .env


async def main():
    async with MTXClient() as client:
        ok = await client.base.status(access_token="<ACCESS_TOKEN>")
        print(ok)


asyncio.run(main())

Development

Install hatch, then run the checks and tests with hatch run dev:tests. Every command and convention of the repository is in AGENTS.md, at its root.

MTX Client Reference

All available functions accept their parameters as keyword arguments. You can omit arguments that are not needed and accept None. Each function's Effect says what it changes on the platform, and effect_of(client.requests.create) returns it as an OperationEffect: read_only changes nothing, additive adds without changing or removing what exists, and destructive changes or removes what exists.

MTXClient

Asynchronous client of the MTX platform.

Each attribute groups the operations on one resource; get_documentation() describes them all. Each operation says when to call it; this text says only how they fit together.

A jurisdiction, identified by its code, offers services, and each request belongs to one of its services. The client keeps no session: a login returns the user's tokens, and each operation on the user's behalf takes their access token.

To create a request, call services.list to choose the service, services.detail for its questions, which the additional_data operations help answer, services.validate_position, location.resolve and requests.find_duplicates with the chosen position, and then requests.create.

Constructor

Signature

MTXClient(*, base_url: 'str | None' = None, client_id: 'str | None' = None, app_key: 'int | None' = None, jwt_secret: 'str | None' = None, open_id_auth_url: 'str | None' = None, open_id_client_key: 'str | None' = None, timeout: 'float | None' = None, redact_logs: 'bool | None' = None, transport: 'httpx.AsyncBaseTransport | None' = None)

Docstring

Creates a client of the MTX platform.

Every argument left out is read from its MTX_* environment variable; an argument passed here wins over the variable. Use the client as an async context manager, so its connections close when the block ends.

Args:

  • base_url (str, optional): Optional base URL of the platform, such as https://api.example.com. If not provided, it is read from MTX_BASE_URL; one of the two is required. Defaults to None.
  • client_id (str, optional): Optional identifier of the application on the platform, sent with every operation. If not provided, it is read from MTX_CLIENT_ID; one of the two is required. Defaults to None.
  • app_key (int, optional): Optional numeric key of the application, sent by jurisdictions.list and jurisdictions.detail; when set, jurisdictions.list returns only that application's jurisdictions. If not provided, it is read from MTX_APP_KEY. Defaults to None.
  • jwt_secret (str, optional): Optional standard base64 secret that auth.login_jwt signs its tokens with; no other operation uses it. If not provided, it is read from MTX_JWT_SECRET. Defaults to None.
  • open_id_auth_url (str, optional): Optional authorization URL of the platform's identity provider, where the user signs in for auth.open_id_login_start; no other operation uses it. If not provided, it is read from MTX_OPEN_ID_AUTH_URL. Defaults to None.
  • open_id_client_key (str, optional): Optional client identifier the application registered with the identity provider, with the out-of-band redirect URI; it also selects the platform's configuration for that provider, and the OpenID login needs it. If not provided, it is read from MTX_OPEN_ID_CLIENT_KEY. For an application with several identity providers, create one client per provider. Defaults to None.
  • timeout (float, optional): Optional number of seconds each operation waits for the platform before it fails. If not provided, it is read from MTX_TIMEOUT, and it is 30 when neither is set. Defaults to None.
  • redact_logs (bool, optional): Optional. Whether the debug logs mask secrets and personal data; False shows them. It changes only what is logged, never what is sent. If not provided, it is read from MTX_REDACT_LOGS, and logs are masked when neither is set. Defaults to None.
  • transport (httpx.AsyncBaseTransport, optional): Optional transport for the client's connections, such as httpx.MockTransport to simulate the platform in tests. If not provided, the client connects to base_url. Defaults to None.

additional_data

external_answers

Effect: read_only

Signature

additional_data.external_answers(*, access_token: 'str | None' = None, question_id: 'str', variables: 'Mapping[str, str] | None' = None, query: 'str | None' = None, page: 'int | None' = None, limit: 'int | None' = None) -> 'PossibleAnswerList'

Docstring

List the answer options of an externalSingleValueList or externalMultiValueList question.

The options of an external question come from a system outside the platform and may depend on the values of the question's required_variables. When that list is empty, call this tool without variables; otherwise call it only when every required variable has a value, and call it again when one of those values changes. When exactly one option is returned, select it without asking the user, since other external questions may need its value as a variable.

Args:

  • access_token (str, optional): Optional token used for authentication. If not provided, the operation will be made without authentication. Defaults to None.
  • question_id (str): The unique identifier of the external question.
  • variables (Mapping[str, str], optional): Optional values of the question's required_variables, by name. Each name is either a known value (lat, lng, service_name, level, jurisdiction_id or jurisdiction_element_id) or the id of another question, whose value is the answer given to it. Defaults to None.
  • query (str, optional): Optional case-insensitive text to look for in the option values. It only filters the options of the requested page, so a page can come back shorter or empty while later pages still have matches. Defaults to None.
  • page (int, optional): Optional page number, starting at 1. Defaults to None.
  • limit (int, optional): Optional number of options per page, at most 90. Defaults to None.

Returns:

  • PossibleAnswerList: The options of the requested page, empty after the last page.

external_questions

Effect: read_only

Signature

additional_data.external_questions(*, access_token: 'str | None' = None, question_list_id: 'str', variables: 'Mapping[str, str]') -> 'AdditionalDataAnswerList'

Docstring

Get the answers that the platform fills in from an external system for a question list.

Use this tool when the required_variables of a service's additional_data is not empty. The platform asks the external system for the questions that have a response_attribute and returns them already answered; send those answers in the additional_data of requests.create.

Args:

  • access_token (str, optional): Optional token used for authentication. If not provided, the operation will be made without authentication. Defaults to None.
  • question_list_id (str): The unique identifier of the question list, the id of the service's additional_data.
  • variables (Mapping[str, str]): Values of every name in the question list's required_variables; the operation fails when one is missing. Each name is either a known value (lat, lng, service_name, level, jurisdiction_id or jurisdiction_element_id) or the id of a question, whose value is the answer given to it.

Returns:

  • AdditionalDataAnswerList: The answers filled in, each with its question, value and whether it is required and editable.

list_answers

Effect: read_only

Signature

additional_data.list_answers(*, access_token: 'str | None' = None, question_id: 'str', page: 'int | None' = None, limit: 'int | None' = None) -> 'PossibleAnswerList'

Docstring

List the answer options of a massiveSingleValueList question, one page at a time.

A massiveSingleValueList question can have thousands of options, and the service detail only includes the first ones. Use this tool to browse the rest in order; to find an option from what the user said, use additional_data.search_answers instead.

Args:

  • access_token (str, optional): Optional token used for authentication. If not provided, the operation will be made without authentication. Defaults to None.
  • question_id (str): The unique identifier of the massiveSingleValueList question.
  • page (int, optional): Optional page number, starting at 1. Defaults to None.
  • limit (int, optional): Optional number of options per page, at most 10: the platform returns 10 options for a higher value but skips that many options when moving to the next page. Defaults to None.

Returns:

  • PossibleAnswerList: The options of the requested page, empty after the last page.

search_answers

Effect: read_only

Signature

additional_data.search_answers(*, access_token: 'str | None' = None, question_id: 'str', query: 'str', page: 'int | None' = None, limit: 'int | None' = None) -> 'PossibleAnswerList'

Docstring

Search the answer options of a massiveSingleValueList question by text.

Use this tool to find the option that matches what the user said, since the service detail only includes the first options of a massiveSingleValueList question. The match is case-insensitive and looks for the text anywhere in the option value.

Args:

  • access_token (str, optional): Optional token used for authentication. If not provided, the operation will be made without authentication. Defaults to None.
  • question_id (str): The unique identifier of the massiveSingleValueList question.
  • query (str): Text to look for in the option values. An empty text matches every option.
  • page (int, optional): Optional page number, starting at 1. Defaults to None.
  • limit (int, optional): Optional number of options per page, at most 90. Defaults to None.

Returns:

  • PossibleAnswerList: The matching options of the requested page, empty when none match.

upload_file

Effect: additive

Signature

additional_data.upload_file(*, access_token: 'str | None' = None, file: 'tuple[str, bytes]') -> 'str'

Docstring

Upload a file and get the URL to answer a media question with.

Use this tool when the user provides the file for an image, imageGallery, signature, videoClip or audioClip question of a service's additional_data: send the returned URL as the answer's value in requests.create (one URL per image for imageGallery). A file already published at a URL needs no upload. The platform accepts images (JPEG, PNG, GIF, TIFF, BMP, SVG or ICO), MP4 video and MP3 or WAV audio, and rejects a file whose content does not match its extension.

Args:

  • access_token (str, optional): Optional token used for authentication. If not provided, the operation will be made without authentication. Defaults to None.
  • file (tuple[str, bytes]): A tuple containing the file name (str) and the file content (bytes). The file name must include an extension and the content must not be empty.

Returns:

  • str: The URL of the uploaded file.

auth

confirm_two_factor

Effect: additive

Signature

auth.confirm_two_factor(*, two_factor_hash: str, code: str) -> mtx_api.models.auth.Authentication

Docstring

Completes a login that requires a second factor, with the code the user received by email.

Call it when auth.login raises TwoFactorRequiredError, with that error's two_factor_hash and the 4-digit code the platform emailed the user. The code is valid for one day and allows 3 attempts: the platform rejects a wrong code, and after the third wrong one, or once the code expires, it no longer finds the login, which must start again with auth.login.

Args:

  • two_factor_hash (str): The two_factor_hash of the TwoFactorRequiredError raised by auth.login.
  • code (str): The 4-digit code the user received by email.

Returns:

  • Authentication: A model containing access and refresh tokens.

generate_biotoken

Effect: destructive

Signature

auth.generate_biotoken(*, access_token: str, device_id: str) -> mtx_api.models.auth.BioToken

Docstring

Generates the biotoken that logs the user back in on this device without their password.

Use this tool after a login, when the user wants to log in again on this device without their credentials, for example once their refresh token expires. Each user has one biotoken per device: generating another one for the same device replaces it. Store it on the device and never show it.

Args:

  • access_token (str): Token of the user the biotoken logs in.
  • device_id (str): A stable and unique identifier for the device that stores the biotoken.

Returns:

  • BioToken: The biotoken and a greeting with the user's first name.

login

Effect: additive

Signature

auth.login(*, username: str, password: str) -> mtx_api.models.auth.Authentication

Docstring

Authenticates a user using their username (email) and password.

Use this tool for standard user login to obtain access credentials. When the platform requires a second factor, the login raises TwoFactorRequiredError and the platform emails the user a 4-digit code: ask the user for it and call auth.confirm_two_factor with the error's two_factor_hash. The platform rejects that login when the user has no confirmed email.

Args:

  • username (str): The user's email address.
  • password (str): The user's password.

Returns:

  • Authentication: A model containing access and refresh tokens.

login_anonymous

Effect: additive

Signature

auth.login_anonymous(*, device_id: str) -> mtx_api.models.auth.Authentication

Docstring

Authenticates a user anonymously using a unique device identifier.

Use this tool to log in a user who does not have a registered account, identifying them solely by their device ID. This enables access to features that require authentication without user registration.

Args:

  • device_id (str): A stable and unique identifier for the device.

Returns:

  • Authentication: A model containing access and refresh tokens.

login_biotoken

Effect: destructive

Signature

auth.login_biotoken(*, device_id: str, biotoken: str) -> mtx_api.models.auth.BioTokenLogin

Docstring

Logs a user in with the biotoken stored on this device, without their password.

Use this tool with the biotoken that auth.generate_biotoken or the last auth.login_biotoken returned for this device. Each login replaces the biotoken: store the new one in place of the used one, because the used one stops working. The platform rejects a biotoken already replaced, one generated for another device and one of an inactive user.

Args:

  • device_id (str): The identifier of the device the biotoken was generated for.
  • biotoken (str): The newest biotoken stored on this device.

Returns:

  • BioTokenLogin: The tokens of the new session and the biotoken that replaces the one used.

login_google

Effect: additive

Signature

auth.login_google(*, id_token: str, jurisdiction_code: str | None = None) -> mtx_api.models.auth.Authentication

Docstring

Authenticates a user with the ID token Google issued when the user signed in with Google.

Use this tool when the application already identifies the user with a Google sign-in, instead of asking for a password. The platform validates the token with Google, finds the user by the token's email or creates them, marks that email as confirmed and fills the user's name and avatar with Google's. The platform rejects a token that Google does not accept or that carries no email.

Args:

  • id_token (str): The ID token Google issued to the user.
  • jurisdiction_code (str, optional): Optional jurisdiction code to associate the user with. Without it, the platform associates a new user with the application's default jurisdiction, and rejects the login when the application has none. Defaults to None.

Returns:

  • Authentication: A model containing access and refresh tokens.

login_jwt

Effect: additive

Signature

auth.login_jwt(*, email: str, first_name: str | None = None, last_name: str | None = None, register: bool | None = None, legal_terms_accepted: bool | None = None) -> mtx_api.models.auth.Authentication

Docstring

Authenticates a user using a signed JSON Web Token (JWT).

Use this tool for trusted server-side authentication or Single Sign-On (SSO) integration. It facilitates logging in or registering a user based on their email address.

Args:

  • email (str): The user's email address.
  • first_name (str, optional): Optional user's first name. Defaults to None.
  • last_name (str, optional): Optional user's last name. Defaults to None.
  • register (bool, optional): Optional. If True, registers the user if they do not exist. Defaults to None.
  • legal_terms_accepted (bool, optional): Optional. Whether the user has accepted the legal terms. Defaults to None.

Returns:

  • Authentication: A model containing access and refresh tokens.

login_open_id

Effect: additive

Signature

auth.login_open_id(*, login: mtx_api.models.auth.OpenIdLogin, code: str) -> mtx_api.models.auth.Authentication

Docstring

Finishes a strong login with the code the identity provider showed the user after the sign-in.

Call it with the login that auth.open_id_login_start returned and the code the user gives. The platform exchanges the code with the identity provider, finds the user by the email the provider returns and creates them when its configuration for the provider allows it. The platform rejects a provider it has no configuration for, and a code the provider does not accept, such as one from another login, one already used or an expired one. After a rejected code, start a new login with auth.open_id_login_start.

Args:

  • login (OpenIdLogin): The login that auth.open_id_login_start returned.
  • code (str): The code the identity provider showed the user after the sign-in.

Returns:

  • Authentication: A model containing access and refresh tokens.

login_refresh

Effect: additive

Signature

auth.login_refresh(*, refresh_token: str) -> mtx_api.models.auth.Authentication

Docstring

Refreshes an existing authentication session using a valid refresh token.

Use this tool to obtain a new access token when the current one has expired, allowing the user's session to continue without requiring re-authentication.

Args:

  • refresh_token (str): The token issued during a previous authentication, used to refresh the session.

Returns:

  • Authentication: A model containing access and refresh tokens.

logout

Effect: destructive

Signature

auth.logout(*, access_token: str) -> bool

Docstring

Logs a user out, ending the session of their access token.

Use this tool when the user wants to log out. The platform deletes the access token, so later operations with it are rejected as with an invalid token, and so is a second logout. The refresh token of the session keeps working in auth.login_refresh: discard it too so that the session cannot be renewed.

Args:

  • access_token (str): Token of the session to end.

Returns:

  • bool: True when the session has ended.

open_id_login_start

Effect: read_only

Signature

auth.open_id_login_start(*, register_passkey: bool | None = None) -> mtx_api.models.auth.OpenIdLogin

Docstring

Starts a strong login: a sign-in of the user with the platform's identity provider.

Use this tool when the user must prove their identity with the identity provider instead of a password. Send the returned url to the user to open in their browser and keep the returned login. After the sign-in, the identity provider shows the user a code: ask the user who opened the URL for it, and pass it whole with the login to auth.login_open_id as soon as the user gives it, since the code is valid only for a short time. If the browser already has a session with the identity provider, the sign-in can finish without asking the user anything, with that session's user: after the login, check with user.profile that it is the expected user and that strongly_identified is true. This tool makes no call to the platform. It is available only when the client is configured with the identity provider (open_id_auth_url and open_id_client_key).

Args:

  • register_passkey (bool, optional): Optional. When True, after the sign-in the identity provider asks the user to register a passkey, with which later sign-ins skip the identity check. Offer it to the user when they will sign in again from the same device, and use it only if they accept. When the identity provider does not offer passkeys or the user cancels, the login goes on as usual, and there is no way to know whether a passkey was registered. Defaults to None.

Returns:

  • OpenIdLogin: The sign-in URL and the secret that auth.login_open_id needs to finish the login.

recover_password

Effect: additive

Signature

auth.recover_password(*, username: str, jurisdiction_code: str | None = None) -> bool

Docstring

Sends the user an email with a link to choose a new password.

Use this tool when a registered user has forgotten their password. The platform rejects the operation when no user has that username, when the user has no email address and when the jurisdiction does not exist.

Args:

  • username (str): The user's username, typically their email address.
  • jurisdiction_code (str, optional): Optional code of the jurisdiction whose email is sent. When not provided and the user belongs to a single jurisdiction, the platform uses that one. Defaults to None.

Returns:

  • bool: True when the email has been sent.

register

Effect: additive

Signature

auth.register(*, username: str, password: str, first_name: str, last_name: str, legal_terms_accepted: bool, jurisdiction_code: str | None = None) -> mtx_api.models.auth.Authentication

Docstring

Registers a new user account and immediately authenticates the user.

Use this tool to create a new user profile with the provided credentials and personal information. This action also logs the user in.

Args:

  • username (str): The email address to use as the username.
  • password (str): The password for the new account.
  • first_name (str): The user's first name.
  • last_name (str): The user's last name.
  • legal_terms_accepted (bool): Must be True to indicate acceptance of legal terms.
  • jurisdiction_code (str, optional): Optional jurisdiction code for the user. Defaults to None.

Returns:

  • Authentication: A model containing access and refresh tokens.

base

openapi

Effect: read_only

Signature

base.openapi() -> 'str'

Docstring

Retrieves the OpenAPI specification of the platform.

Fetches the complete OpenAPI documentation in plain text. This provides details on available tools, operation structures, and expected responses.

Returns:

  • str: The OpenAPI document content as a string.

status

Effect: read_only

Signature

base.status(*, access_token: 'str | None' = None) -> 'bool'

Docstring

Checks the operational status of the platform.

Verifies if the platform is running and reachable. Use this tool to confirm platform availability before performing other operations.

Args:

  • access_token (str, optional): Optional token used for authentication. If not provided, the operation will be made without authentication. Defaults to None.

Returns:

  • bool: True if the platform is available and the operation succeeds.

jurisdiction_elements

list

Effect: read_only

Signature

jurisdiction_elements.list(*, access_token: str | None = None, jurisdiction_code: str, element_type: JurisdictionElementType | None = None) -> mtx_api.models.jurisdiction.JurisdictionElementList

Docstring

Retrieves jurisdiction elements associated with a specific jurisdiction code.

Use this tool to find all jurisdiction elements linked to a given jurisdiction code from the platform.

Args:

  • access_token (str, optional): Optional token used for authentication. If not provided, the operation will be made without authentication. Defaults to None.
  • jurisdiction_code (str): The unique string code of the jurisdiction to query.
  • element_type (JurisdictionElementType, optional): Optional type of the elements to return, 'city' or 'building'. If not provided, elements of every type are returned. Defaults to None.

Returns:

  • JurisdictionElementList: An object containing the list of retrieved jurisdiction elements.

jurisdictions

detail

Effect: read_only

Signature

jurisdictions.detail(*, access_token: 'str | None' = None, jurisdiction_code: 'str') -> 'Jurisdiction'

Docstring

Retrieves detailed information for a specific jurisdiction.

This tool fetches the complete details of a jurisdiction using its unique code. Use this tool when you need more information about a specific jurisdiction than what is provided in the list.

Args:

  • access_token (str, optional): Optional token used for authentication. If not provided, the operation will be made without authentication. Defaults to None.
  • jurisdiction_code (str): The unique string code of the jurisdiction to query.

Returns:

  • Jurisdiction: An object containing comprehensive information about the jurisdiction.

list

Effect: read_only

Signature

jurisdictions.list(*, access_token: 'str | None' = None) -> 'JurisdictionList'

Docstring

Retrieves the list of jurisdictions available on the platform.

When the client is configured with an app_key, only the jurisdictions of that application are returned.

Args:

  • access_token (str, optional): Optional token used for authentication. If not provided, the operation will be made without authentication. Defaults to None.

Returns:

  • JurisdictionList: A collection of Jurisdiction objects with basic details.

location

resolve

Effect: read_only

Signature

location.resolve(*, jurisdiction_element_id: str, formatted_address: str | None = None, lat: float | None = None, lng: float | None = None) -> mtx_api.models.additional_data.LocationAdditionalDataList

Docstring

Resolves the position of an address, or the address of a position, with its location questions.

This tool fetches location-specific questions configured for a jurisdiction element. You can identify the location by providing either a formatted address, geographic coordinates (lat, lng), or both. Regardless of which parameters you provide, the tool always returns the complete location information including formatted address, geographic coordinates, and the list of additional data questions.

Use this tool when you need to know what additional information should be collected for a specific location.

Args:

  • jurisdiction_element_id (str): The unique identifier string of the jurisdiction element where the location is being queried.
  • formatted_address (str, optional): Optional complete address string in human-readable format to identify the location. Defaults to None.
  • lat (float, optional): Optional latitude coordinate as a decimal number to identify the location. Must be provided together with lng. Defaults to None.
  • lng (float, optional): Optional longitude coordinate as a decimal number to identify the location. Must be provided together with lat. Defaults to None.

Returns:

  • LocationAdditionalDataList: A collection of location entries. Each entry always contains the formatted address, geographic coordinates (latitude and longitude), and a list of additional data questions configured for that location, regardless of which input parameters were used to identify the location.

requests

attach_comment

Effect: additive

Signature

requests.attach_comment(*, access_token: 'str | None' = None, request_id: 'str', comment: 'str | None' = None, files: 'Sequence[tuple[str, bytes]]' = ()) -> 'RequestComment'

Docstring

Attach a comment to an existing request.

Args:

  • access_token (str, optional): Optional token used for authentication. If not provided, the operation will be made without authentication. Defaults to None.
  • request_id (str): The unique identifier of the request to add the comment to.
  • Note: this is the internal request id, not the service_request_id.
  • comment (str, optional): Optional text of the comment. Can be empty. Defaults to None.
  • files (Sequence[tuple[str, bytes]], optional): Optional sequence of files to attach with the comment. Each file is a tuple containing the file name (str) and the file content (bytes). Each file name must include an extension and each content must not be empty. Defaults to ().

Returns:

  • RequestComment: The created comment object.

attach_file

Effect: additive

Signature

requests.attach_file(*, access_token: 'str | None' = None, request_id: 'str', file: 'tuple[str, bytes]') -> 'RequestFile'

Docstring

Attach a document file (such as a PDF) to an existing request.

Only for services whose ask_for_files is true. The file is visible only to the jurisdiction's staff, so it does not appear in the request detail.

Args:

  • access_token (str, optional): Optional token used for authentication. If not provided, the operation will be made without authentication. Defaults to None.
  • request_id (str): The unique identifier of the request to attach the file to.
  • Note: this is the internal request id, not the service_request_id.
  • file (tuple[str, bytes]): A tuple containing the file name (str) and the file content (bytes). The file name must include an extension and the content must not be empty.

Returns:

  • RequestFile: The object representing the attached file.

attach_media

Effect: additive

Signature

requests.attach_media(*, access_token: 'str | None' = None, request_id: 'str', jurisdiction_code: 'str', file: 'tuple[str, bytes]') -> 'RequestMedia'

Docstring

Attach a media file to an existing request.

Only for services whose ask_for_medias is true.

Args:

  • access_token (str, optional): Optional token used for authentication. If not provided, the operation will be made without authentication. Defaults to None.
  • request_id (str): The unique identifier of the request to attach the media to.
  • Note: this is the internal request id, not the service_request_id.
  • jurisdiction_code (str): The code of the jurisdiction associated with the request.
  • file (tuple[str, bytes]): A tuple containing the file name (str) and the file content (bytes). The file name must include an extension and the content must not be empty.

Returns:

  • RequestMedia: The object representing the attached media.

create

Effect: additive

Signature

requests.create(*, access_token: 'str | None' = None, service_id: 'str', jurisdiction_code: 'str', origin_device_id: 'str', jurisdiction_element_id: 'str | None' = None, description: 'str | None' = None, public: 'bool | None' = None, lat: 'float | None' = None, lng: 'float | None' = None, address_string: 'str | None' = None, situation: 'str | None' = None, email: 'str | None' = None, first_name: 'str | None' = None, last_name: 'str | None' = None, phone: 'str | None' = None, twitter_nickname: 'str | None' = None, additional_data: 'Sequence[AnyAdditionalDataValue] | None' = None, location_additional_data: 'Sequence[AnyAdditionalDataValue] | None' = None) -> 'CreatedRequest'

Docstring

Create a new request in the platform.

This function allows creating a new request (issue report) within a specific jurisdiction. When the jurisdiction's only_registered_users is true, only a registered user can create a request: the platform rejects it with an anonymous user's token. Some services require the contact details of the person making the request: give the ones that the service's mandatory_informant_config in services.detail marks as required, since the platform rejects the request without them and does not take them from the user's profile. The platform also rejects a request in a service the user shares no channel with, unless the service is open to everyone (user.channels).

Args:

  • access_token (str, optional): Optional token used for authentication. If not provided, the operation will be made without authentication. Defaults to None.
  • service_id (str): Identifier of the service to request.
  • jurisdiction_code (str): Code of the jurisdiction where the request is made.
  • origin_device_id (str): ID of the medium the request comes from. Choose, among the origin_devices of jurisdictions.detail, the one whose options best describe how the user reaches you.
  • jurisdiction_element_id (str, optional): Optional ID of a specific element within the jurisdiction. Defaults to None.
  • description (str, optional): Optional textual description of the request. Leave it empty when the service's ask_for_description is false. Defaults to None.
  • public (bool, optional): Optional boolean. If True, the request is public; if False, it is private. Defaults to None.
  • lat (float, optional): Optional latitude coordinate of the request location. Defaults to None.
  • lng (float, optional): Optional longitude coordinate of the request location. Defaults to None.
  • address_string (str, optional): Optional physical address associated with the request. Defaults to None.
  • situation (str, optional): Optional free-text hint about where exactly the issue is. Defaults to None.
  • email (str, optional): Optional email address of the person making the request. Defaults to None.
  • first_name (str, optional): Optional first name of the person making the request. Defaults to None.
  • last_name (str, optional): Optional last name of the person making the request. Defaults to None.
  • phone (str, optional): Optional phone number of the person making the request. Defaults to None.
  • twitter_nickname (str, optional): Optional Twitter handle of the person making the request. Defaults to None.
  • additional_data (Sequence[AnyAdditionalDataValue], optional): Optional answers to the questions of the service's additional_data, each with the AdditionalDataValue subclass whose type accepts the question's type. When a chosen option has a next_question_list, answer its questions in this same sequence. A media question (image, imageGallery, signature, videoClip or audioClip) is answered with URLs, which additional_data.upload_file gives for a file. Defaults to None.
  • location_additional_data (Sequence[AnyAdditionalDataValue], optional): Optional answers to the location questions of the jurisdiction element, in the same format as additional_data. Get them by calling location.resolve with the same jurisdiction_element_id, lat and lng, and send one value per item of its data whose value is not empty, with that item's question id and value. When the element has required location questions, omitting them fails. Ignored when the service has no location. Defaults to None.

Returns:

  • CreatedRequest: The created request instance with its details.

detail

Effect: read_only

Signature

requests.detail(*, access_token: 'str | None' = None, request_id: 'str') -> 'Request'

Docstring

Retrieve detailed information about a specific request.

Args:

  • access_token (str, optional): Optional token used for authentication. If not provided, the operation will be made without authentication. Defaults to None.
  • request_id (str): The unique identifier of the request to fetch.
  • Note: this is the internal request id, not the service_request_id.

Returns:

  • Request: The detailed Request object containing all information.

detail_by_code

Effect: read_only

Signature

requests.detail_by_code(*, access_token: 'str | None' = None, jurisdiction_code: 'str', service_request_id: 'str') -> 'Request'

Docstring

Retrieve detailed information about a request from its service_request_id.

Use this tool when only the human-readable service_request_id of a request is known, such as when the user gives it. It returns the same information as requests.detail. Both the jurisdiction code and the service_request_id are case-sensitive. The platform does not find the request when the jurisdiction does not exist or has no request with that service_request_id, and rejects the operation when the request is private and the user is anonymous or not authenticated.

Args:

  • access_token (str, optional): Optional token used for authentication. If not provided, the operation will be made without authentication. Defaults to None.
  • jurisdiction_code (str): Code of the jurisdiction where the request was created.
  • service_request_id (str): The human-readable identifier of the request.

Returns:

  • Request: The detailed Request object containing all information.

evaluate

Effect: additive

Signature

requests.evaluate(*, access_token: 'str', request_id: 'str', evaluation: 'Evaluation') -> 'RequestEvaluation'

Docstring

Evaluate how a request was handled, on behalf of its author.

Only the registered user who created the request can evaluate it, only once, and only while its is_evaluable is true. is_evaluable stays true after the evaluation, so check that the request's evaluation is 0 before calling this tool. The platform rejects the evaluation when the user is anonymous, when the user is not the request's author, when the request was already evaluated, and when the request's status does not allow it.

Args:

  • access_token (str): Token of the request's author, a registered user.
  • request_id (str): The unique identifier of the request to evaluate.
  • Note: this is the internal request id, not the service_request_id.
  • evaluation (Evaluation): 1 when the request was handled badly, 2 when it was handled acceptably and 3 when it was handled well.

Returns:

  • RequestEvaluation: The evaluation given.

find_duplicates

Effect: read_only

Signature

requests.find_duplicates(*, access_token: 'str | None' = None, service_id: 'str', lat: 'float', lng: 'float') -> 'RequestList'

Docstring

Find existing requests that may describe the same issue as a new one.

Use this tool before requests.create, with the service and the position the user chose. When it returns requests, show them to the user and offer to reiterate one with requests.reiterate instead of creating a new request. It returns up to 20 public requests of that service near the position, within the distance, statuses and time range configured in the service, and an empty list when the service does not look for duplicates. The platform rejects the search when the service's workflow is not configured.

Args:

  • access_token (str, optional): Optional token used for authentication. If not provided, the operation will be made without authentication. Defaults to None.
  • service_id (str): The identifier of the service of the new request.
  • lat (float): Latitude of the new request's position.
  • lng (float): Longitude of the new request's position.

Returns:

  • RequestList: The requests that may be duplicates of the new one, possibly empty.

list

Effect: read_only

Signature

requests.list(*, access_token: 'str | None' = None, jurisdiction_codes: 'list[str] | None' = None, service_request_ids: 'list[str] | None' = None, service_ids: 'list[str] | None' = None, start_date: 'str | None' = None, end_date: 'str | None' = None, own: 'bool | None' = None, lat: 'float | None' = None, lng: 'float | None' = None, page: 'int | None' = None, limit: 'int | None' = None, address_and_service_request_id: 'str | None' = None, status: 'list[str] | None' = None, typology_ids: 'list[str] | None' = None, distance: 'int | None' = None, following: 'bool | None' = None, order: 'str | None' = None, complaints: 'bool | None' = None, reiterations: 'bool | None' = None, user_reiterated: 'bool | None' = None, user_complaint: 'bool | None' = None, jurisdiction_element_ids: 'list[str] | None' = None, level: 'int | None' = None, polygon: 'list[float] | None' = None, final_ok: 'bool | None' = None, final_not_ok: 'bool | None' = None, final_status: 'bool | None' = None, interested: 'bool | None' = None, timezone: 'str | None' = None) -> 'RequestList'

Docstring

List and filter requests from the platform.

This function retrieves a list of requests based on multiple filtering criteria.

Args:

  • access_token (str, optional): Optional token used for authentication. If not provided, the operation will be made without authentication. Defaults to None.
  • jurisdiction_codes (list[str], optional): Optional list of jurisdiction codes to filter by. Defaults to None.
  • service_request_ids (list[str], optional): Optional list of specific request IDs to retrieve. Defaults to None.
  • service_ids (list[str], optional): Optional list of service IDs to filter by. Defaults to None.
  • start_date (str, optional): Optional ISO date-time string (inclusive) to filter requests created after this date. Defaults to None.
  • end_date (str, optional): Optional ISO date-time string (inclusive) to filter requests created before this date. Defaults to None.
  • own (bool, optional): Optional boolean. If True, returns only requests created by the authenticated user. Defaults to None.
  • lat (float, optional): Optional latitude to be used for distance filtering or ordering by proximity. Defaults to None.
  • lng (float, optional): Optional longitude to be used for distance filtering or ordering by proximity. Defaults to None.
  • page (int, optional): Optional page number for pagination. Defaults to None.
  • limit (int, optional): Optional number of items per page. Defaults to None.
  • address_and_service_request_id (str, optional): Optional free text search for address or service request ID. Defaults to None.
  • status (list[str], optional): Optional list of status codes to filter by. Defaults to None.
  • typology_ids (list[str], optional): Optional list of typology IDs to filter by. Defaults to None.
  • distance (int, optional): Optional radius in meters to filter requests around the provided lat/lng. Defaults to None.
  • following (bool, optional): Optional boolean. If True, returns only requests followed by the authenticated user. Defaults to None.
  • order (str, optional): Optional ordering strategy (e.g., "newest_date_desc"). Defaults to None.
  • complaints (bool, optional): Optional boolean. If True, filters only complaints. Defaults to None.
  • reiterations (bool, optional): Optional boolean. If True, filters only reiterations. Defaults to None.
  • user_reiterated (bool, optional): Optional boolean. If True, filters requests reiterated by the authenticated user. Defaults to None.
  • user_complaint (bool, optional): Optional boolean. If True, filters complaints made by the authenticated user. Defaults to None.
  • jurisdiction_element_ids (list[str], optional): Optional list of jurisdiction element IDs to filter by. Defaults to None.
  • level (int, optional): Optional floor level to filter by. Defaults to None.
  • polygon (list[float], optional): Optional list of float coordinates describing a polygon area to filter requests within. Defaults to None.
  • final_ok (bool, optional): Optional boolean. If True, filters requests with a final status of OK. Defaults to None.
  • final_not_ok (bool, optional): Optional boolean. If True, filters requests with a final status of NOT OK. Defaults to None.
  • final_status (bool, optional): Optional boolean. If True, filters requests with any final status. Defaults to None.
  • interested (bool, optional): Optional boolean. If True, filters requests where the user has expressed interest. Defaults to None.
  • timezone (str, optional): Optional IANA timezone string used by the backend for date filtering. Defaults to None.

Returns:

  • RequestList: A list of Request items matching the criteria.

list_comments

Effect: read_only

Signature

requests.list_comments(*, access_token: 'str | None' = None, request_id: 'str') -> 'RequestCommentList'

Docstring

List the comments of a request.

Use this tool to read the conversation of a request: the comments of the jurisdiction's staff, in internal_user, and those of external users, in external_user.

Args:

  • access_token (str, optional): Optional token used for authentication. If not provided, the operation will be made without authentication. Defaults to None.
  • request_id (str): The unique identifier of the request to list the comments of.
  • Note: this is the internal request id, not the service_request_id.

Returns:

  • RequestCommentList: The comments of the request.

reiterate

Effect: additive

Signature

requests.reiterate(*, access_token: 'str', request_id: 'str', follow: 'bool' = True, description: 'str | None' = None, origin_device_id: 'str | None' = None) -> 'RequestReiteration'

Docstring

Reiterate a request, to report that the user has the same issue it describes.

Use this tool instead of creating a new request when an existing request already describes the user's issue. Each reiteration adds one to the request's reiterations_count. The platform rejects the reiteration when the user is the request's author, when a registered user already reiterated the request, and when a registered user already complained about it.

Args:

  • access_token (str): Token of the user who reiterates the request.
  • request_id (str): The unique identifier of the request to reiterate.
  • Note: this is the internal request id, not the service_request_id.
  • follow (bool, optional): Optional. Whether the user follows the request after reiterating it, to be notified of its updates. Defaults to True.
  • description (str, optional): Optional text the user adds to the reiteration. The platform also adds it to the request as a comment by the user. Defaults to None.
  • origin_device_id (str, optional): Optional ID of the device making the request. Can be found on Jurisdiction detail. Defaults to None.

Returns:

  • RequestReiteration: The reiteration made.

Effect: read_only

Signature

requests.search(*, access_token: 'str | None' = None, query: 'str', jurisdiction_codes: 'list[str]', page: 'int | None' = None, limit: 'int | None' = None) -> 'FoundRequestList'

Docstring

Searches the public requests of the given jurisdictions by text.

It finds requests by words of their description or address, or by their code. Use this tool only when the user asks to search requests; it is not a step of creating one.

Args:

  • access_token (str, optional): Optional token used for authentication. If not provided, the operation will be made without authentication. Defaults to None.
  • query (str): The words or the request code to search for.
  • jurisdiction_codes (list[str]): Codes of the jurisdictions to search in. Must contain at least one code.
  • page (int, optional): Optional page of results to return, starting at 1, the one returned when not given; a page past the last one is empty. Defaults to None.
  • limit (int, optional): Optional number of requests per page, from 1 to 90; the platform returns 3 when not given. Defaults to None.

Returns:

  • FoundRequestList: The public requests found, best match first.

services

detail

Effect: read_only

Signature

services.detail(*, access_token: 'str | None' = None, service_id: 'str', jurisdiction_code: 'str') -> 'Service'

Docstring

Retrieves the detailed information of a specific service.

This function fetches the full details of a service identified by its ID within a specific jurisdiction. Details include additional_data and other relevant information.

Args:

  • access_token (str, optional): Optional token used for authentication. If not provided, the operation will be made without authentication. Defaults to None.
  • service_id (str): The identifier of the service to fetch details for.
  • jurisdiction_code (str): The jurisdiction code where the service is located.

Returns:

  • Service: The detailed information of the requested service.

list

Effect: read_only

Signature

services.list(*, access_token: 'str | None' = None, jurisdiction_codes: 'list[str]', lat: 'float | None' = None, lng: 'float | None' = None, typology_ids: 'list[str] | None' = None) -> 'ServiceList'

Docstring

Retrieves a list of services available in the specified jurisdictions.

This function allows searching for services filtering by jurisdiction codes, and optionally by geographic location (latitude and longitude) or typology identifiers. With a user's token, it returns only the services that share a channel with the user, besides those open to everyone; user.channels lists the user's channels.

Args:

  • access_token (str, optional): Optional token used for authentication. If not provided, the operation will be made without authentication. Defaults to None.
  • jurisdiction_codes (list[str]): List of jurisdiction codes to filter the services. Must contain at least one code.
  • lat (float, optional): Optional latitude for geolocation filtering. Defaults to None.
  • lng (float, optional): Optional longitude for geolocation filtering. Defaults to None.
  • typology_ids (list[str], optional): Optional list of typology identifiers to filter the services. Defaults to None.

Returns:

  • ServiceList: The list of services matching the specified criteria.

search

Effect: read_only

Signature

services.search(*, access_token: 'str | None' = None, query: 'str', jurisdiction_codes: 'list[str]', typology_ids: 'list[str] | None' = None, page: 'int | None' = None, limit: 'int | None' = None) -> 'FoundServiceList'

Docstring

Searches the services of the given jurisdictions by text.

It finds services by words of their name, description, keywords or typology. Use this tool only when the user asks to search services; to choose the service of a new request, use services.list. The search can find a service that is not configured to take requests, which services.detail rejects.

Args:

  • access_token (str, optional): Optional token used for authentication. If not provided, the operation will be made without authentication. Defaults to None.
  • query (str): The words to search for.
  • jurisdiction_codes (list[str]): Codes of the jurisdictions to search in. Must contain at least one code.
  • typology_ids (list[str], optional): Optional typology identifiers the services must have. Defaults to None.
  • page (int, optional): Optional page of results to return, starting at 1, the one returned when not given; a page past the last one is empty. Defaults to None.
  • limit (int, optional): Optional number of services per page, from 1 to 90; the platform returns 3 when not given. Defaults to None.

Returns:

  • FoundServiceList: The services found, best match first.

validate_position

Effect: read_only

Signature

services.validate_position(*, access_token: 'str | None' = None, service_id: 'str', jurisdiction_element_id: 'str', lat: 'float', lng: 'float', level: 'int | None' = None) -> 'PositionValidation'

Docstring

Checks whether a service accepts requests at a position.

Use this tool after the user chooses a position and before calling location.resolve and requests.create with it. When the position is invalid, show the user the message (Markdown) if it is not empty and let them choose another service, or another position: the closest_position when it is returned, or one they choose. A parent service (one that other services reference in parent_service_id) has no zones, so the platform rejects the check: choose one of its sub-services instead.

Args:

  • access_token (str, optional): Optional token used for authentication. If not provided, the operation will be made without authentication. Defaults to None.
  • service_id (str): The identifier of the service to check the position for.
  • jurisdiction_element_id (str): The identifier of the jurisdiction element that contains the position.
  • lat (float): Latitude of the position.
  • lng (float): Longitude of the position.
  • level (int, optional): Optional floor or level of the position, for jurisdiction elements with several levels. Defaults to None.

Returns:

  • PositionValidation: Whether the position is valid and, when it is not, the service's message and possibly the closest valid position.

typologies

list

Effect: read_only

Signature

typologies.list(*, access_token: 'str | None' = None, jurisdiction_codes: 'list[str]', jurisdiction_element_id: 'str | None' = None, typology_ids: 'list[str] | None' = None, lat: 'float | None' = None, lng: 'float | None' = None, page: 'int | None' = None, limit: 'int | None' = None) -> 'TypologyList'

Docstring

Retrieve a list of typologies from the platform based on jurisdiction codes.

This tool fetches typologies available for the specified jurisdiction codes, optionally filtering by specific typology IDs, jurisdiction element, or location.

Args:

  • access_token (str, optional): Optional token used for authentication. If not provided, the operation will be made without authentication. Defaults to None.
  • jurisdiction_codes (list[str]): List of jurisdiction codes used to filter the typologies. Must contain at least one code.
  • jurisdiction_element_id (str, optional): Optional ID of a specific jurisdiction element to filter results. Defaults to None.
  • typology_ids (list[str], optional): Optional list of specific typology IDs to retrieve. Defaults to None.
  • lat (float, optional): Optional latitude coordinate for location-based filtering. Defaults to None.
  • lng (float, optional): Optional longitude coordinate for location-based filtering. Defaults to None.
  • page (int, optional): Optional page number for result pagination. Defaults to None.
  • limit (int, optional): Optional maximum number of items to return per page. Defaults to None.

Returns:

  • TypologyList: A collection of typology items matching the specified criteria.

user

accept_terms

Effect: additive

Signature

user.accept_terms(*, access_token: str) -> bool

Docstring

Accepts the legal terms and conditions for the currently authenticated user.

Use this tool to register the acceptance of legal terms for a previously registered user. Accepting these terms allows the user to use the platform. If not accepted, the user will not be allowed to use the platform.

Call it only after showing the user the policies of user.legal_terms and the user accepts them; then retry the operation that raised LegalTermsRequiredError.

Args:

  • access_token (str): Token of the user who accepts the legal terms.

Returns:

  • bool: True if the terms were successfully accepted.

channels

Effect: read_only

Signature

user.channels(*, access_token: str) -> mtx_api.models.channel.UserChannelList

Docstring

Lists the channels offered to the user in their jurisdictions, and which ones they belong to.

Channels are interests or roles of the user. The platform offers a user only the services that share a channel with them, besides those open to everyone, and rejects creating a request in a service the user shares no channel with. Use this tool to see which channels the user can join with user.update_channels, for example when a service the user needs is missing. The list holds every channel the user can join or leave, and the ones the platform's managers assigned to the user.

Args:

  • access_token (str): Token of the user whose channels are listed.

Returns:

  • UserChannelList: The channels, each with whether the user belongs to it and gets its notifications.

Effect: read_only

Signature

user.legal_terms() -> mtx_api.models.common.LegalTerms

Docstring

Retrieves the current legal terms and conditions content.

Use this function to fetch the complete legal terms and conditions content that users must accept to use the platform. Each document is the URL of a web page with its full text. This is typically given to users during registration or when terms have been updated and require re-acceptance.

Returns:

  • LegalTerms: A model containing the URLs of the legal documents: privacy policy, terms of use, accessibility statement and cookies policy.

profile

Effect: read_only

Signature

user.profile(*, access_token: str) -> mtx_api.models.auth.Profile

Docstring

Retrieves the profile information of the currently authenticated user.

Use this tool to fetch details about the current user, including personal information and account settings.

Args:

  • access_token (str): Token of the user whose profile is retrieved.

Returns:

  • Profile: A model containing the user's profile details.

request_account_deletion

Effect: additive

Signature

user.request_account_deletion(*, email: str, jurisdiction_code: str) -> bool

Docstring

Sends the user an email with a link to confirm the deletion of their account.

Use this tool when a registered user wants to delete their account. The account is not deleted yet: the platform anonymizes it only when the user opens the link and confirms, which the user must do themselves. The platform rejects the operation when no user has that email address and when the jurisdiction does not exist.

Args:

  • email (str): The email address of the user's account.
  • jurisdiction_code (str): The code of the jurisdiction whose email is sent.

Returns:

  • bool: True when the email has been sent.

update_avatar

Effect: destructive

Signature

user.update_avatar(*, access_token: str, file: tuple[str, bytes]) -> mtx_api.models.auth.Profile

Docstring

Sets an image as the profile picture of the currently authenticated user.

Use this tool when the user provides an image to use as their profile picture. It replaces the previous picture. The platform rejects the operation when the file is not an image.

Args:

  • access_token (str): Token of the user whose profile picture changes.
  • file (tuple[str, bytes]): A tuple containing the file name (str) and the image content (bytes). The file name must include an extension and the content must not be empty.

Returns:

  • Profile: A model containing the updated user's profile details, with the URL of the new picture in avatar.

update_channels

Effect: destructive

Signature

user.update_channels(*, access_token: str, channel_ids: list[str] | None = None, notification_channel_ids: list[str] | None = None) -> mtx_api.models.channel.UserChannelList

Docstring

Changes the channels the user belongs to and the ones whose notifications they get.

Each list replaces the user's channels they can join or leave: send every channel the user keeps, not only the new ones, and an empty list to leave all of them. The channels the platform's managers assigned stay. Take the ids from user.channels.

Args:

  • access_token (str): Token of the user whose channels change.
  • channel_ids (list[str], optional): Optional ids of every channel the user belongs to after the change. When not provided, these channels do not change. Defaults to None.
  • notification_channel_ids (list[str], optional): Optional ids of every channel whose notifications the user gets after the change. When not provided, these channels do not change. Defaults to None.

Returns:

  • UserChannelList: The channels after the change, as user.channels returns them.

update_profile

Effect: destructive

Signature

user.update_profile(*, access_token: str, email: str | None = None, username: str | None = None, first_name: str | None = None, last_name: str | None = None, twitter_nickname: str | None = None, phone: str | None = None, gender: Gender | None = None, birthday: str | None = None, old_password: str | None = None, new_password: str | None = None) -> mtx_api.models.auth.Profile

Docstring

Updates the profile information of the currently authenticated user.

Use this tool to modify the personal details and account information of the user. Only the fields provided will be updated; fields set to None will remain unchanged.

Anonymous users cannot update their profile. When the profile's strongly_identified is true, first_name and last_name cannot be changed, and the password can only be changed when has_password is true.

Args:

  • access_token (str): Token of the user whose profile is updated.
  • email (str, optional): Optional new email address for the user. Defaults to None.
  • username (str, optional): Optional new username for the user, typically their email address. Defaults to None.
  • first_name (str, optional): Optional new first name or given name for the user. Defaults to None.
  • last_name (str, optional): Optional new last name or family name for the user. Defaults to None.
  • twitter_nickname (str, optional): Optional new shown name or twitter_nickname visible to others. Defaults to None.
  • phone (str, optional): Optional new primary phone number for contact purposes. Defaults to None.
  • gender (Gender, optional): Optional new gender identification for the user. Defaults to None.
  • birthday (str, optional): Optional new date of birth in format YYYY-MM-DD. Defaults to None.
  • old_password (str, optional): Optional current password of the user, sent together with new_password to change it. Defaults to None.
  • new_password (str, optional): Optional new password for the user. Defaults to None.

Returns:

  • Profile: A model containing the updated user's profile details.

Errors

Every SDK error extends MTXError, so except MTXError catches them all.

  • Errors returned by the platform raise ApiError with fields code (platform error code) and description. Its message is the category, then code and the description, e.g. permission denied: 1058 The client is not allowed to access this API. Each category has its subclass; any other error raises ApiError itself (category platform error):
    • InvalidRequestError (invalid request): the platform rejects the data sent, including a wrong username or password.
    • AuthenticationError (authentication failed): the token or the client is not valid.
    • PermissionDeniedError (permission denied): the user or the client may not perform the operation.
    • NotFoundError (not found): the item does not exist.
    • ConflictError (conflict): the operation clashes with the item's state, e.g. the same request is still being created.
    • RateLimitError (too many requests): too many attempts or requests; retry later.
    • LegalTermsRequiredError (legal terms required): the user must accept the current legal terms (user.accept_terms, only once the user accepts them).
    • TwoFactorRequiredError (two-factor code required): the login needs the code the platform emailed the user; its two_factor_hash, also in its message, goes to auth.confirm_two_factor with that code.
    • ServerError (platform failure): the platform failed while performing the operation.
  • When a response of the platform does not fit its model, ApiDecodingError (invalid response): its message names the model and, for each failing field, the error and the field's path, such as invalid response: RequestList: string_type at 1.service_request_id, without the response's values, which can be personal data.
  • When the platform cannot be reached or does not answer in time (network failure, timeout), ApiConnectionError; its message gives the cause.
  • SDK parameter validation errors raise specific exceptions, which all extend ValueError. Their message is the category, then the cause.
    • Configuration missing from the MTXClient constructor and its MTX_* variables (category missing configuration, e.g. missing configuration: base_url is required: set MTX_BASE_URL or pass MTXClient(base_url=...)):
      • MissingBaseUrlError: missing base_url configuration (via MTX_BASE_URL or base_url parameter).
      • MissingClientIdError: missing client_id configuration (via MTX_CLIENT_ID or client_id parameter).
      • MissingJwtSecretError: missing JWT secret configuration (via MTX_JWT_SECRET or jwt_secret parameter) when using auth.login_jwt.
      • MissingOpenIdAuthUrlError: missing identity provider authorization URL (via MTX_OPEN_ID_AUTH_URL or open_id_auth_url parameter) when using auth.open_id_login_start.
      • MissingOpenIdClientKeyError: missing identity provider client (via MTX_OPEN_ID_CLIENT_KEY or open_id_client_key parameter) when using auth.open_id_login_start or auth.login_open_id.
    • Arguments of an operation (category invalid argument, e.g. invalid argument: request_id is required):
      • MissingArgumentError: a required argument is missing; its message names it.
      • InvalidEmailError: the email is not valid.
      • InvalidArgumentError: an id is . or .., or contains /, ?, #, % or a backslash; or the jwt_secret is not standard base64 (only A-Z, a-z, 0-9, +, / and the final = padding) when using auth.login_jwt; or effect_of gets a function that is not a public operation of MTXClient.

Metadata

Release files for mtx-api-py 0.8.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mtx-api-py 0.8.1
File Size Uploaded Provenance Actions
mtx_api_py-0.8.1.tar.gz 72.1 kB Without provenance Details for mtx_api_py-0.8.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mtx-api-py 0.8.1
File Interpreter ABI Platform Actions
mtx_api_py-0.8.1-py3-none-any.whl Python 3 none any Details for mtx_api_py-0.8.1-py3-none-any.whl

Total release size: 146.7 kB

Release files / mtx_api_py-0.8.1.tar.gz

Download URL mtx_api_py-0.8.1.tar.gz
Size 72.1 kB
Tags Source
SHA-256 checksum
How to use checksums
e6e0f3d36d12dc412ed59221b10035e0aa2ade2a5fda8a4ec7f93a9f9a09477c
BLAKE2b-256 checksum
How to use checksums
4b4e7a3195e5e11f6271ff46d8f1ab833d875bfc6f0973f02c69a1e80130c629
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Hatch/1.18.2 {"ci":null,"cpu":"arm64","distro":{"name":"macOS","version":"26.5.1"},"implementation":{"name":"CPython","version":"3.14.10"},"installer":{"name":"hatch","version":"1.18.2"},"openssl_version":"OpenSSL 4.1.0 23 Oct 2026","python":"3.14.10","system":{"name":"Darwin","release":"25.5.0"}} HTTPX2/2.16.0

Release files / mtx_api_py-0.8.1-py3-none-any.whl

Download URL mtx_api_py-0.8.1-py3-none-any.whl
Size 74.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8fae26d8d6ea9d986b5aa258dadd351fc230e528d555ab42bb906dab71ea036c
BLAKE2b-256 checksum
How to use checksums
02304fc477477d89ddef9a28f77b3e17df0843f46abbf4966a409cede28c4056
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Hatch/1.18.2 {"ci":null,"cpu":"arm64","distro":{"name":"macOS","version":"26.5.1"},"implementation":{"name":"CPython","version":"3.14.10"},"installer":{"name":"hatch","version":"1.18.2"},"openssl_version":"OpenSSL 4.1.0 23 Oct 2026","python":"3.14.10","system":{"name":"Darwin","release":"25.5.0"}} HTTPX2/2.16.0

Security for mtx-api-py 0.8.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page