# Assign a tag to a machine

Source: https://www.jawsdeploy.net/rest-api/machines-tag-assign | Section: Machines

Add one tag to a machine, leaving its other tags alone.

`POST /api/machine/tag`

Adds one tag to the machine. The machine's other tags are left untouched.

The call is **idempotent**: assigning a tag the machine already has succeeds and changes nothing.

The tag must belong to the same workspace as the machine.

## Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `machineId` | body | string | yes | ID of the machine, from [List machines](https://www.jawsdeploy.net/rest-api/machines-list). |
| `tagId` | body | string | yes | ID of the tag, from [List tags](https://www.jawsdeploy.net/rest-api/tags-list). |

## Errors

| Status | Meaning |
|---|---|
| 400 | Invalid `machineId`. A machine that belongs to another organization is reported the same way as one that does not exist. |
| 400 | Missing `tagId`, or a tag that does not belong to the machine's workspace. |
| 401 | Missing or invalid Basic auth credentials, or the service account lacks permission to manage machines in this workspace. |

Example request:

```
POST /api/machine/tag HTTP/1.1
Authorization: Basic <base64(...)>
Content-Type: application/json

{
  "machineId": "mch_web01",
  "tagId": "tag_canary"
}
```

Example response:

```
{}
```

