Skip to content

SpaceAPI

SpaceAPI is DesktopRenamer's local integration interface. It is useful for integrations that need to observe spaces or issue commands without launching AppleScript. Contract 1.3.0 introduced an authenticated Unix-domain socket and retains DistributedNotificationCenter (DNC) for compatibility when access restriction is off. Contract 1.3.1 adds each space's current ManagedSpaceID beside its stable ID in structured records. Contract 1.3.0 also reports the app-wide automatic-return setting.

There are two SpaceAPI formats:

Format Use it when Data shape
Structured protocol Building a new integration. JSON-RPC 2.0 messages containing typed JSON values.
Legacy format Supporting an existing client. Distributed notifications with the original user-info keys and delimiter-based strings.

The structured protocol is the first formally versioned contract and should be the default for new clients. The legacy format remains supported but is not changed in place, so existing integrations can migrate on their own schedule.

Common request flow

  1. Register response observers before posting a request.
  2. Confirm that the API is enabled.
  3. Request an initial snapshot.
  4. Reconcile updates by space identifier, not by array position.
  5. Re-fetch after reconnecting or after a display, sleep/wake, or fullscreen change.

Distributed notifications are broadcasts and can be dropped. The structured protocol includes snapshot revisions so clients can detect a gap and fetch a complete snapshot again.

Requirements

SpaceAPI is available when Settings → General → Advanced → Enable SpaceAPI is enabled. When Allow only approved apps is on in Manage SpaceAPI access, an unapproved app using the authenticated socket can request access from the user; DNC requests and broadcasts are disabled. Older DNC-only clients cannot request access and will not work in restricted mode. The same setting also restricts AppleScript access, so approved apps and their read/write levels are shared between both interfaces. macOS Automation permission remains required for AppleScript. A client does not need to activate or bring DesktopRenamer to the front. Requests that switch or rearrange spaces can complete asynchronously; observe a later state update before assuming Mission Control has settled.

Optional usage statistics are available in Manage SpaceAPI access and are off by default. When enabled, DesktopRenamer stores per-app request counts on this Mac for identifiable socket clients; it does not save request contents. DNC requests are not included because their sender cannot be identified. Turning collection off pauses new counts, and Clear removes the saved history.

For a typed contract, transport details, methods, and error handling, see the structured protocol. For existing notification names and payload keys, see the legacy format.