> ## Documentation Index
> Fetch the complete documentation index at: https://docs.superdoc.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# metadata.update

> Replace the JSON payload of an existing anchored-metadata entry. Replace semantics; no merge. The anchor is left untouched.

## Summary

Replace the JSON payload of an existing anchored-metadata entry. Replace semantics; no merge. The anchor is left untouched.

* Operation ID: `metadata.update`
* API member path: `editor.doc.metadata.update(...)`
* Mutates document: `yes`
* Idempotency: `idempotent`
* Supports tracked mode: `no`
* Supports dry run: `yes`
* Deterministic target resolution: `yes`

## Expected result

Returns an AnchoredMetadataMutationResult with the entry id on success or a failure.

## Input fields

| Field     | Type   | Required | Description |
| --------- | ------ | -------- | ----------- |
| `id`      | string | yes      |             |
| `payload` | any    | yes      |             |

### Example request

```json theme={null}
{
  "id": "id-001",
  "payload": {}
}
```

## Output fields

### Variant 1 (success=true)

| Field     | Type   | Required | Description      |
| --------- | ------ | -------- | ---------------- |
| `id`      | string | yes      |                  |
| `success` | `true` | yes      | Constant: `true` |

### Variant 2 (success=false)

| Field             | Type    | Required | Description       |
| ----------------- | ------- | -------- | ----------------- |
| `failure`         | object  | yes      |                   |
| `failure.code`    | string  | yes      |                   |
| `failure.details` | any     | no       |                   |
| `failure.message` | string  | yes      |                   |
| `success`         | `false` | yes      | Constant: `false` |

### Example response

```json theme={null}
{
  "id": "id-001",
  "success": true
}
```

## Pre-apply throws

* `TARGET_NOT_FOUND`
* `INVALID_TARGET`
* `INVALID_INPUT`
* `CAPABILITY_UNAVAILABLE`
* `REVISION_MISMATCH`

## Non-applied failure codes

* `TARGET_NOT_FOUND`
* `INVALID_INPUT`

## Raw schemas

<Accordion title="Raw input schema">
  ```json theme={null}
  {
    "additionalProperties": false,
    "properties": {
      "id": {
        "minLength": 1,
        "type": "string"
      },
      "payload": {}
    },
    "required": [
      "id",
      "payload"
    ],
    "type": "object"
  }
  ```
</Accordion>

<Accordion title="Raw output schema">
  ```json theme={null}
  {
    "oneOf": [
      {
        "additionalProperties": false,
        "properties": {
          "id": {
            "minLength": 1,
            "type": "string"
          },
          "success": {
            "const": true
          }
        },
        "required": [
          "success",
          "id"
        ],
        "type": "object"
      },
      {
        "additionalProperties": false,
        "properties": {
          "failure": {
            "additionalProperties": false,
            "properties": {
              "code": {
                "type": "string"
              },
              "details": {},
              "message": {
                "type": "string"
              }
            },
            "required": [
              "code",
              "message"
            ],
            "type": "object"
          },
          "success": {
            "const": false
          }
        },
        "required": [
          "success",
          "failure"
        ],
        "type": "object"
      }
    ]
  }
  ```
</Accordion>

<Accordion title="Raw success schema">
  ```json theme={null}
  {
    "additionalProperties": false,
    "properties": {
      "id": {
        "minLength": 1,
        "type": "string"
      },
      "success": {
        "const": true
      }
    },
    "required": [
      "success",
      "id"
    ],
    "type": "object"
  }
  ```
</Accordion>

<Accordion title="Raw failure schema">
  ```json theme={null}
  {
    "additionalProperties": false,
    "properties": {
      "failure": {
        "additionalProperties": false,
        "properties": {
          "code": {
            "type": "string"
          },
          "details": {},
          "message": {
            "type": "string"
          }
        },
        "required": [
          "code",
          "message"
        ],
        "type": "object"
      },
      "success": {
        "const": false
      }
    },
    "required": [
      "success",
      "failure"
    ],
    "type": "object"
  }
  ```
</Accordion>
