"On Octopus Deploy UI, we can deploy to a single machine on a specified environment. The use case is the following: when we create a new machine in an environment (for scaling out the web application), we do not want to do a full deploy on the environment, only just on this single machine (initial deploy for this machine).
As you may have noticed already, by default Octopus deploys to all the machines on the environment. On the JSON above you can see "SpecificMachineIds": . When this value is set to an empty array, that means it’ll deploy to all the machines on the environment. If you want to cherry pick the machines you’ll be deploying to, you’re gonna have to add MachineIDs to SpecificMachineIds before you do the POST.
To get the machine IDs you could:
A) On the Web UI click on the tentacle from the environments page and then check the URL, it should be something like /app#/machines/machines-1. The machine ID is machines-1
B) Using the API, GET the environment (i.e /api/environments/Environments-1). The response will return a JSON that will contain links to many resources. One of them will be Machines. Do a GET to the machines link (i.e /api/environments/Environments-1/machines) and it’ll return a collection of machines, which will have the machine ID
Once you have the machine IDs, add them to SpecificMachineIDs and POST the message to /api/deployments. The SpecificMachineIDs on the message should look like this for a deployment to only 1 machine
The gist at the beginning of the post makes pretty much all the same API calls a regular deployment invoked from the Web UI or Octo.exe would do. The comments on it should help understanding what is going on behind scenes.