# Replace resource metadata — API reference

> Accepts a resource type, resource ID and key/value pairs.

Source: https://upfour.io/docs/api/metadata/replace-resource-metadata

[Developers](https://upfour.io/docs/api.md)/[Resource metadata](https://upfour.io/docs/api/metadata.md)

Accepts a resource type, resource ID and key/value pairs.

PUT https://app.upfour.io/v1/metadata

scope metadata.write stable returns 200

## Body

`application/json` required 3 fields

metadatamap of string (required)max 100 keyseach value max length 4096

Custom key/value pairs (at most 100 keys; keys 1-128 characters, values up to 4096). Sent to machine-readable alert channels and API webhook subscriptions, and copied onto the incidents the resource opens.

resource_iduuid (required)

resource_typestring (required)

monitorheartbeatincidentclient

## Returns

A successful request returns `200` with application/json.

Response fields 2 top-level fields

| Field | Type | Description |
| --- | --- | --- |
| `data` | ResourceMetadata[]  · nullable | |
| Each item · 8 fields FieldTypeDescription `created_at` string (date-time) `id` uuid `key` string `organization_id` uuid `resource_id` uuid `resource_type` string one of`monitor` `heartbeat` `incident` `client` `updated_at` string (date-time) `value` string | | |
| `pagination` | Pagination | |
| Pagination · 5 fields FieldTypeDescription `cursor` string  · nullable `has_more` boolean `limit` integer 1–250 `next_cursor` string  · nullable `prev_cursor` string  · nullable | | |

## Errors

Only the errors this operation can return. Every error uses the [same envelope](https://upfour.io/docs/api/responses.md).

| Status | Code | Meaning |
| --- | --- | --- |
| 400 | [bad_request](https://upfour.io/docs/api/errors#code-bad_request) | The request is malformed or fails validation. |
| 404 | [not_found](https://upfour.io/docs/api/errors#code-not_found) | The requested resource does not exist or is outside the caller's scope. |
| 403 | [permission_denied](https://upfour.io/docs/api/errors#code-permission_denied) | The credentials do not permit this action. |

Every call can also return `unauthorized` (401), `rate_limit_exceeded` (429) or `internal_error` (500 / 502). See [Responses and errors](https://upfour.io/docs/api/responses.md).

[PreviousList resource metadata](https://upfour.io/docs/api/metadata/list-resource-metadata.md)

## Request

### cURL

```bash
curl -s -X PUT "https://app.upfour.io/v1/metadata" \
  -H "Authorization: Bearer $UP4_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "metadata": {
      "team": "platform",
      "tier": "1"
    },
    "resource_id": "00000000-0000-4000-8000-000000000001",
    "resource_type": "monitor"
  }'
```

### JavaScript

```javascript
const res = await fetch("https://app.upfour.io/v1/metadata", {
  method: "PUT",
  headers: {
    Authorization: `Bearer ${process.env.UP4_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    metadata: {
      team: "platform",
      tier: "1",
    },
    resource_id: "00000000-0000-4000-8000-000000000001",
    resource_type: "monitor",
  }),
});
console.log(res.status, await res.json());
```

### Python

```python
import os
import requests

res = requests.put(
    "https://app.upfour.io/v1/metadata",
    headers={"Authorization": f"Bearer {os.environ['UP4_API_KEY']}"},
    json={
        "metadata": {
            "team": "platform",
            "tier": "1",
        },
        "resource_id": "00000000-0000-4000-8000-000000000001",
        "resource_type": "monitor",
    },
)
print(res.status_code, res.json())
```

### Go

```go
package main

import (
	"fmt"
	"io"
	"net/http"
	"os"
	"strings"
)

func main() {
	payload := strings.NewReader(`{
  "metadata": {
    "team": "platform",
    "tier": "1"
  },
  "resource_id": "00000000-0000-4000-8000-000000000001",
  "resource_type": "monitor"
}`)
	req, _ := http.NewRequest("PUT", "https://app.upfour.io/v1/metadata", payload)
	req.Header.Set("Authorization", "Bearer "+os.Getenv("UP4_API_KEY"))
	req.Header.Set("Content-Type", "application/json")
	res, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer res.Body.Close()
	out, _ := io.ReadAll(res.Body)
	fmt.Println(res.StatusCode, string(out))
}
```

### PHP

```php
<?php
$payload = <<<'JSON'
{
  "metadata": {
    "team": "platform",
    "tier": "1"
  },
  "resource_id": "00000000-0000-4000-8000-000000000001",
  "resource_type": "monitor"
}
JSON;

$ch = curl_init("https://app.upfour.io/v1/metadata");
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => "PUT",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer " . getenv("UP4_API_KEY"),
        "Content-Type: application/json",
    ],
    CURLOPT_POSTFIELDS => $payload,
]);
$response = curl_exec($ch);
echo curl_getinfo($ch, CURLINFO_RESPONSE_CODE), " ", $response, "\n";
curl_close($ch);
```

## Response

### 200

```json
{
  "data": [
    {
      "created_at": "2026-10-27T09:00:00Z",
      "id": "00000000-0000-4000-8000-000000000002",
      "key": "team",
      "organization_id": "00000000-0000-4000-8000-000000000003",
      "resource_id": "00000000-0000-4000-8000-000000000001",
      "resource_type": "monitor",
      "updated_at": "2026-10-27T09:00:00Z",
      "value": "platform"
    },
    {
      "created_at": "2026-10-27T09:00:00Z",
      "id": "00000000-0000-4000-8000-000000000004",
      "key": "tier",
      "organization_id": "00000000-0000-4000-8000-000000000003",
      "resource_id": "00000000-0000-4000-8000-000000000001",
      "resource_type": "monitor",
      "updated_at": "2026-10-27T09:00:00Z",
      "value": "1"
    }
  ],
  "pagination": {
    "cursor": null,
    "has_more": false,
    "limit": 50,
    "next_cursor": null,
    "prev_cursor": null
  }
}
```

### 400

```json
{
  "error": {
    "code": "bad_request",
    "message": "The request is malformed or fails validation.",
    "request_id": "req_…"
  }
}
```

### 403

```json
{
  "error": {
    "code": "permission_denied",
    "message": "The credentials do not permit this action.",
    "request_id": "req_…"
  }
}
```

### 404

```json
{
  "error": {
    "code": "not_found",
    "message": "The requested resource does not exist or is outside the caller's scope.",
    "request_id": "req_…"
  }
}
```
