# Update metadata record

Changes a metadata record's values, renames its key, or moves it to another resource. Send only what you want to change.

[endpoint]
base_url = "https://incidents.betterstack.com"
path = "/api/v4/metadata/{metadata_id}"
method = "PATCH"

[[path_param]]
name = "metadata_id"
description = "The `id` of the metadata record, from [List metadata](https://betterstack.com/docs/uptime/api/list-all-existing-metadata/). It stands for all values of that key on that resource."
required = true
type = "string"

[[body_param]]
name = "values"
description = "All values the key should have, replacing the current ones. Each value is a plain string or an object, as described for `values` when [creating a metadata record](https://betterstack.com/docs/uptime/api/update-an-existing-metadata-record/). Send `[]` to remove the key, or leave it out to keep the current values."
required = false
type = "array of objects"

[[body_param]]
name = "key"
description = "A new name for the metadata key."
required = false
type = "string"

[[body_param]]
name = "owner_id"
description = "The ID of another resource to move the values to. `owner_type` defaults to the current one."
required = false
type = "string"

[[body_param]]
name = "owner_type"
description = "The type of the resource in `owner_id`: `Monitor`, `Heartbeat`, `Incident`, `WebhookIntegration`, `EmailIntegration`, `IncomingWebhook`, `AmazonSnsIntegration`, or `CallRouting`."
required = false
type = "string"

[[header]]
name = "Authorization"
description = "Bearer `$TOKEN`"
required = true
type = "string"

[[header]]
name = "Content-Type"
description = "application/json"
required = true
type = "string"
[/endpoint]

[responses]
[[response]]
status = 200
description = '''Returns the updated metadata record.'''
body = '''{
  "data": {
    "id": "25",
    "type": "metadata",
    "attributes": {
      "key": "Owner",
      "values": [{ "type": "Team", "item_id": "t123", "name": "Platform team" }],
      "team_name": "Testing",
      "owner_id": "2",
      "owner_type": "Monitor"
    },
    "relationships": {
      "owner": {
        "data": { "id": "2", "type": "monitor" }
      }
    }
  }
}'''

[[response]]
status = 204
description = '''`values` was empty, so the key was removed.'''
body = ''''''

[[response]]
status = 404
description = '''No metadata record, or no resource in `owner_id`, with this ID exists in your team.'''
body = '''{
  "errors": "Resource type Metadata with id = 25 was not found"
}'''

[[response]]
status = 422
description = '''The values are invalid, for example repeated or of different types.'''
body = '''{
  "errors": {
    "values": ["Values for Owner must be unique"]
  }
}'''
[/responses]

#### Example cURL

[code-tabs]
```shell
[label Replace values]
curl --request PATCH \
  --url https://incidents.betterstack.com/api/v4/metadata/25 \
  --header "Authorization: Bearer $TOKEN" \
  --header "Content-Type: application/json" \
  --data '{
    "values": [{ "type": "Team", "item_id": "t123" }]
  }'
```
```shell
[label Rename the key]
curl --request PATCH \
  --url https://incidents.betterstack.com/api/v4/metadata/25 \
  --header "Authorization: Bearer $TOKEN" \
  --header "Content-Type: application/json" \
  --data '{
    "key": "Service owner"
  }'
```
[/code-tabs]
