pyaxm
A Python client library for querying the Apple Business Manager API.
pyaxm handles authentication, token caching, and response pagination for you, and
returns strongly-typed Pydantic models for every resource.
A companion command-line tool, pyaxm-cli, is bundled with the library for quick access
from the terminal.
Features
- Devices — list all organization devices (pagination handled for you), fetch a device by serial number, and read its AppleCare coverage.
- MDM servers — list servers, list the devices assigned to a given server, and check which server a device is currently assigned to.
- Device assignment — assign/unassign devices to MDM servers, including MDM migration flows: assign with a migration deadline, move the deadline, cancel an in-progress migration, or release devices from the organization entirely. Calls return once the activity has finished.
- Activity reports — completed device activities expose a downloadable CSV report.
- Audit events — search the audit log over a date range, with optional filters for actor, subject, event type, paging, and more.
- Users — list organization users and look up a user by ID.
- Auth made simple — OAuth2 client-credentials flow built on your ABM private key, with the access token cached on disk until it expires so you don't trip Apple's token rate limits.
Installation
pip install pyaxm
Authentication
Create an API client and private key in Apple Business Manager, then either configure the environment or pass the values to the client directly.
Using environment variables:
AXM_CLIENT_ID— the ABM client ID.AXM_KEY_ID— the ABM key ID.
Place the private key at ~/.config/pyaxm/key.pem. This directory is also where the
cached access token is stored (as token.json) and reused until it expires. Requesting
too many tokens in a short window can cause Apple to return HTTP 400, so caching matters.
Alternatively, configure the client explicitly:
from pyaxm.client import Client
axm_client = Client(
axm_client_id="CLIENT_ID",
axm_key_id="KEY_ID",
key_path="/absolute/path/to/key.pem",
token_path="/path/to/token.json",
)
When the environment variables are set, Client() works with no arguments.
Usage
from pyaxm.client import Client
from pyaxm.utils import download_activity_csv
client = Client()
# Devices
devices = client.list_devices() # all pages fetched automatically
device = client.get_device(device_id="SERIAL_NUMBER")
coverage = client.get_apple_care_coverage(device_id="SERIAL_NUMBER")
# MDM servers
mdm_servers = client.list_mdm_servers()
server_devices = client.list_devices_in_mdm_server(server_id="MDM_SERVER_ID")
assigned_server = client.get_device_server_assignment(device_id="SERIAL_NUMBER")
# Assign / unassign devices to an MDM server.
# The client waits for the activity to complete before returning.
activity = client.assign_unassign_device_to_mdm_server(
device_ids=["SERIAL_NUMBER", "ANOTHER_SERIAL_NUMBER"],
server_id="MDM_SERVER_ID",
action="ASSIGN_DEVICES", # or "UNASSIGN_DEVICES"
)
print(activity.attributes.status)
# MDM migration: assign with a deadline, then update or cancel it later
client.assign_unassign_device_to_mdm_server(
device_ids=["SERIAL_NUMBER"],
server_id="MDM_SERVER_ID",
action="ASSIGN_DEVICES_WITH_MDM_MIGRATION_DEADLINE",
mdm_migration_deadline_date_time="2026-10-15T17:00:00.000Z",
)
# Release one or more devices from the organization
client.release_devices(device_ids=["SERIAL_NUMBER"])
# Audit events (optional filters: actor_id, subject_id, event_type, limit, fields, cursor)
events = client.get_audit_events(
start_timestamp="2026-08-01",
end_timestamp="2026-08-31",
)
# Users
users = client.list_users()
user = client.get_user(user_id="USER_ID")
# Download the CSV report produced by a completed device activity.
# The report may take a few seconds to become available after the activity completes.
report_path = download_activity_csv(activity)
CLI
The pyaxm-cli command-line tool is installed alongside the library and mirrors these
features from the terminal, with yaml or csv output. See the
CLI documentation for every command, its options, and examples.
Development
Install in editable mode to work on the source:
pip install -e .
The CLI reference in docs/cli.md is generated from the code. After
changing pyaxm/cli.py, regenerate it with:
typer pyaxm.cli utils docs --name pyaxm-cli --output docs/cli.md
A GitHub workflow checks that the generated documentation stays in sync with the CLI.
Metadata
Release files for pyaxm 2026.9.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyaxm-2026.9.3.1.tar.gz | 29.2 kB | With provenance | Details for pyaxm-2026.9.3.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyaxm-2026.9.3.1-py3-none-any.whl | Python 3 | none | any | Details for pyaxm-2026.9.3.1-py3-none-any.whl |
Total release size: 57.6 kB
Release files / pyaxm-2026.9.3.1.tar.gz
| Download URL | pyaxm-2026.9.3.1.tar.gz |
|---|---|
| Size | 29.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
26099d59f53097c0b8156719ba97c38cd9fc84b837c4ea38c5edcbf5e780c8f5
|
|
BLAKE2b-256 checksum How to use checksums |
6c4adfc5df57e4979d03e71d3f64d6b6d9b5595ec298b3aaa488c8b77580e517
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 3, 2026.
Transparency logRelease files / pyaxm-2026.9.3.1-py3-none-any.whl
| Download URL | pyaxm-2026.9.3.1-py3-none-any.whl |
|---|---|
| Size | 28.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
861edb9a093b7fdc9c6065de16510f87a8d9e23a57ada8ad4a1767189429a03a
|
|
BLAKE2b-256 checksum How to use checksums |
424c21be7eb852af934e9a9eb24adf562a502813fbba5bb530f1c52e24fd22ed
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 3, 2026.
Transparency logSecurity for pyaxm 2026.9.3.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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for pyaxm-2026.9.3.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 3, 2026.
Transparency logA 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.