Skip to main content

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, or cancel an in-progress migration. 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",
)

# 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.2

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

Source distribution (sdist)

Source distribution for pyaxm 2026.9.2
File Size Uploaded Provenance Actions
pyaxm-2026.9.2.tar.gz 28.7 kB With provenance Details for pyaxm-2026.9.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pyaxm 2026.9.2
File Interpreter ABI Platform Actions
pyaxm-2026.9.2-py3-none-any.whl Python 3 none any Details for pyaxm-2026.9.2-py3-none-any.whl

Total release size: 56.6 kB

Release files / pyaxm-2026.9.2.tar.gz

Download URL pyaxm-2026.9.2.tar.gz
Size 28.7 kB
Tags Source
SHA-256 checksum
How to use checksums
1092bd146765845bfb8f3740a05abc5455b8e254c6d65820678b16d1d44e4932
BLAKE2b-256 checksum
How to use checksums
059aeba6e2239e1ce3c85446a934f62f66796dcf39aefa31833deeea7853db6e
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 2, 2026.

Transparency log

Release files / pyaxm-2026.9.2-py3-none-any.whl

Download URL pyaxm-2026.9.2-py3-none-any.whl
Size 27.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
69daa7e053bf6749c7926b518c4380bcb860de0e036e1745aeb5f2c2d4ed8a0f
BLAKE2b-256 checksum
How to use checksums
7aec4caf508013c3d87dae8e89b4f0015189a34832ed21e8e0d914526baf4eee
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 2, 2026.

Transparency log

Security for pyaxm 2026.9.2

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.

Select from 2 files

Attestation for pyaxm-2026.9.2.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 2, 2026.

Transparency log

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