Fleet logo
Menu An icon indicating that interacting with this button will open the navigation menu.
Fleet logo An 'X' icon indicating that this can be interacted with to close the navigation menu.

Solutions

a small chevron
Device management

Device management

Remotely manage, and protect laptops and mobile devices.

Orchestration

Orchestration

Automate tasks across devices, from app installs to scripts.

Software management

Software management

Inventory, patch, and manage installed software.

GitOps

Infrastructure as code

See every change, undo any error, repeat every success.

Extend Fleet

Extend Fleet

Integrate your favorite tools with Fleet.


Customers
Pricing

More

a small chevron
Docs

Docs

Guides

Guides

Support

Support

News

News

Get your license

Get your license

The handbook

The handbook

GitOps for device management

In-person workshop for beginners.

Join us
Get a demo
Solutions A small chevron
Device management

Device management

Remotely manage, and protect laptops and mobile devices.

Orchestration

Orchestration

Automate tasks across devices, from app installs to scripts.

Software management

Software management

Inventory, patch, and manage installed software.

GitOps

Infrastructure as code

See every change, undo any error, repeat every success.

Extend Fleet

Extend Fleet

Integrate your favorite tools with Fleet.

Customers Pricing
More A small chevron

GitOps for device management

In-person workshop for beginners.

Join us
Docs

Docs

Guides

Guides

Support

Support

News

News

Get your license

Get your license

The handbook

The handbook

Get a demo
{{categoryFriendlyName}}/
{{thisPage.meta.articleTitle}}
search

Set a device hostname via the Fleet API

{{articleSubtitle}}

Last updated on |
The author's GitHub profile picture

Kitzy

Share

Share this article on Hacker News Share this article on LinkedIn Share this article on Twitter

On this page

{{topic.title}}
Docs Docs REST API REST API Guides Guides Get a demoGet a demo
Suggest an editSuggest an edit

Set a device hostname via the Fleet API

{{articleSubtitle}}

Last updated on | The author's GitHub profile picture

Kitzy

Set a device hostname via the Fleet API

You can rename macOS, iOS, and iPadOS devices by sending an MDM command through Fleet's API. This is useful for enforcing naming conventions or identifying devices at a glance.

For more MDM commands and detailed guidance, see MDM commands.

Prerequisites

  • A Fleet API token with write access
  • The device's serial number
  • The device must be enrolled in Fleet's MDM

Get the host UUID

First, retrieve the host's UUID using its serial number.

Endpoint: GET /api/v1/fleet/hosts/identifier/{serial}

Headers:

  • Accept: application/json
  • Authorization: Bearer {your_api_token}

The response includes the host object. Extract the uuid field from host.uuid.

Create the rename command

Build an XML payload using Apple's Settings MDM command. Replace NEW-HOSTNAME with your desired device name.

Important: The CommandUUID must be unique for each command you send. You can use a timestamp, UUID generator, or any unique identifier. For example: Settings_20260127_143052 or a proper UUID like A1B2C3D4-E5F6-7890-ABCD-EF1234567890.

To generate a UUID on macOS:

uuidgen
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Command</key>
    <dict>
        <key>RequestType</key>
        <string>Settings</string>
        <key>Settings</key>
        <array>
            <dict>
                <key>DeviceName</key>
                <string>NEW-HOSTNAME</string>
                <key>Item</key>
                <string>DeviceName</string>
            </dict>
        </array>
    </dict>
    <key>CommandUUID</key>
    <string>UUID-GOES-HERE</string>
</dict>
</plist>

Base64 encode the command

The Fleet API requires MDM command payloads to be base64 encoded.

macOS or Linux:

cat command.xml | base64

Windows (PowerShell):

[Convert]::ToBase64String((Get-Content -Path "command.xml" -Encoding byte))

Save the output for the next step.

Send the command

Submit the encoded command to Fleet. For complete endpoint details, see the Run MDM command API reference.

Endpoint: POST /api/v1/fleet/commands/run

Headers:

  • Content-Type: application/json
  • Authorization: Bearer {your_api_token}

Body:

{
  "command": "{base64_encoded_command}",
  "host_uuids": ["{host_uuid}"]
}

To rename multiple devices at once, include multiple UUIDs separated by commas in the host_uuids array:

{
  "command": "{base64_encoded_command}",
  "host_uuids": ["{host_uuid_1}", "{host_uuid_2}", "{host_uuid_3}"]
}

The device will update its hostname the next time it checks in with Fleet.

Fleet logo
Solutions Device management Orchestration Software management Integrations Pricing
Documentation Support Docs API Release notes Get your license
Company About Trust Jobs Logos/artwork Why open source?
a small checkmarkSOC2 Type 2 Creative Commons Licence CC BY-SA 4.0
© 2026 Fleet Inc. Privacy
Slack logo GitHub logo LinkedIn logo X (Twitter) logo Youtube logo Mastadon logo