# Manage & Operate › Identity & Access Management › Tags API

> Part of the OVHcloud developer hub. Index of every page and section: https://developers.eu.ovhcloud.com/llms.txt
> The Manage & Operate product's sections: https://developers.eu.ovhcloud.com/reference/manage-operate/llms.txt
> Everything in one file: https://developers.eu.ovhcloud.com/llms-full.txt

> 3 operations of the OVHcloud API. Calls carry `authorization: Bearer $OVH_TOKEN`; the EU host is shown, Canada and the United States answer on api.ca.ovhcloud.com and api.us.ovhcloud.com.

Page: https://developers.eu.ovhcloud.com/reference/manage-operate/identity-access-management/tags/

OpenAPI v1: https://api.eu.ovhcloud.com/1.0/__schemas/developer-hub-navigation/manage-operate/identity-access-management/tags.json?format=openapi3
OpenAPI v2: https://api.eu.ovhcloud.com/v2/__schemas/developer-hub-navigation/manage-operate/identity-access-management/tags.json?format=openapi3

## Operations

- `POST /iam/resource/{resourceURN}/tag` — Add a resource tag
- `DELETE /iam/resource/{resourceURN}/tag/{key}` — Delete a resource tag
- `PUT /iam/resource/{resourceURN}` — Update a resource

## Add a resource tag

`POST /v2/iam/resource/{resourceURN}/tag`

Link: https://developers.eu.ovhcloud.com/reference/manage-operate/identity-access-management/tags/#post-iam-resource-resourceurn-tag

**Status:** Stable production version  
**IAM actions:** `account:apiovh:iam/resource/tag/add`

Adds a tag, made of a key and a value, to the resource. Requires the `$resourceType:apiovh:iam/resource/tag/add` action on the resource type.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `resourceURN` | path | string | yes | ResourceURN |

### Request body (required)

Type: `iam.resource.AddTag`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `key` | string | yes | Resource tag key. It must comply with `^[a-zA-Z0-9_.:/=+@-]{1,128}\z`. |
| `value` | string | yes | Resource tag value. It must comply with `^[a-zA-Z0-9_.:/=+@-]{0,256}\z`. |

```json
{
  "key": "string",
  "value": "string"
}
```

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | — | successful operation |

### Example

```bash
curl -X POST \
  "https://api.eu.ovhcloud.com/v2/iam/resource/{resourceURN}/tag" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN" \
  -H "content-type: application/json" \
  -d '{ }'
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

# Request body type: iam.resource.AddTag
result = client.post("/v2/iam/resource/{resourceURN}/tag",
	key = None, # Resource tag key. It must comply with `^[a-zA-Z0-9_.:/=+@-]{1,128}\z`. (type: string)
	value = None, # Resource tag value. It must comply with `^[a-zA-Z0-9_.:/=+@-]{0,256}\z`. (type: string)
)

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

// Request body type: iam.resource.AddTag
$result = $ovh->post("/v2/iam/resource/{resourceURN}/tag", array(
	key => null, // Resource tag key. It must comply with `^[a-zA-Z0-9_.:/=+@-]{1,128}\z`. (type: string)
	value => null, // Resource tag value. It must comply with `^[a-zA-Z0-9_.:/=+@-]{0,256}\z`. (type: string)
));

print_r($result);
?>
```

## Delete a resource tag

`DELETE /v2/iam/resource/{resourceURN}/tag/{key}`

Link: https://developers.eu.ovhcloud.com/reference/manage-operate/identity-access-management/tags/#delete-iam-resource-resourceurn-tag-key

**Status:** Stable production version  
**IAM actions:** `account:apiovh:iam/resource/tag/remove`

Deletes the tag identified by its key. Computed `ovh:` tags cannot be deleted. Requires the `$resourceType:apiovh:iam/resource/tag/remove` action on the resource type.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `key` | path | string | yes | Key |
| `resourceURN` | path | string | yes | ResourceURN |

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | — | successful operation |

### Example

```bash
curl -X DELETE \
  "https://api.eu.ovhcloud.com/v2/iam/resource/{resourceURN}/tag/{key}" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN"
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

result = client.delete("/v2/iam/resource/{resourceURN}/tag/{key}")

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

$result = $ovh->delete("/v2/iam/resource/{resourceURN}/tag/{key}");

print_r($result);
?>
```

## Update a resource

`PUT /v2/iam/resource/{resourceURN}`

Link: https://developers.eu.ovhcloud.com/reference/manage-operate/identity-access-management/tags/#put-iam-resource-resourceurn

**Status:** Stable production version  
**IAM actions:** `account:apiovh:iam/resource/edit`

Updates the tags of the resource. Adding a tag requires the `$resourceType:apiovh:iam/resource/tag/add` action and removing one requires `$resourceType:apiovh:iam/resource/tag/remove`, with `$resourceType` the type of the resource.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `resourceURN` | path | string | yes | ResourceURN |

### Request body (required)

Type: `iam.resource.Resource`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `displayName` | string | read-only | Resource display name |
| `id` | string (uuid) | read-only | Identifier of the resource |
| `name` | string | read-only | Resource name |
| `owner` | string | read-only | Resource owner |
| `tags` | object |  | Resource tags. Tags that were internally computed are prefixed with ovh: |
| `type` | string | read-only | Resource type. All types can be retrieved at /reference/resource/type. |
| `urn` | string | read-only | Unique resource name used in policies |

```json
{
  "tags": {
    "key": "string"
  }
}
```

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | iam.resource.Resource | successful operation |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `displayName` | string | read-only | Resource display name |
| `id` | string (uuid) | read-only | Identifier of the resource |
| `name` | string | read-only | Resource name |
| `owner` | string | read-only | Resource owner |
| `tags` | object |  | Resource tags. Tags that were internally computed are prefixed with ovh: |
| `type` | string | read-only | Resource type. All types can be retrieved at /reference/resource/type. |
| `urn` | string | read-only | Unique resource name used in policies |

```json
{
  "displayName": "string",
  "id": "00000000-0000-0000-0000-000000000000",
  "name": "string",
  "owner": "string",
  "tags": {
    "key": "string"
  },
  "type": "string",
  "urn": "string"
}
```

### Example

```bash
curl -X PUT \
  "https://api.eu.ovhcloud.com/v2/iam/resource/{resourceURN}" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN" \
  -H "content-type: application/json" \
  -d '{ }'
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

# Request body type: iam.resource.Resource
result = client.put("/v2/iam/resource/{resourceURN}",
	tags = None, # Resource tags. Tags that were internally computed are prefixed with ovh: (type: object, nullable)
)

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

// Request body type: iam.resource.Resource
$result = $ovh->put("/v2/iam/resource/{resourceURN}", array(
	tags => null, // Resource tags. Tags that were internally computed are prefixed with ovh: (type: object, nullable)
));

print_r($result);
?>
```
