# fields.rebuild

> Rebuild (recalculate) a field.



- Member path: `doc.fields.rebuild(…)`
- Mutates document: yes
- Idempotency: `idempotent`
- Supports tracked mode: no
- Supports dry run: yes

## Expected result

Returns a FieldMutationResult indicating success or a failure.

## Input schema

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$defs": {},
  "type": "object",
  "properties": {
    "target": {
      "type": "object",
      "properties": {
        "kind": {
          "const": "field"
        },
        "blockId": {
          "type": "string"
        },
        "occurrenceIndex": {
          "type": "integer"
        },
        "nestingDepth": {
          "type": "integer"
        },
        "storyId": {
          "type": "string"
        },
        "fieldId": {
          "type": "string"
        }
      },
      "additionalProperties": false,
      "required": [
        "kind",
        "blockId",
        "occurrenceIndex"
      ]
    }
  },
  "additionalProperties": false,
  "required": [
    "target"
  ]
}
```

## Output schema

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$defs": {},
  "oneOf": [
    {
      "type": "object",
      "properties": {
        "success": {
          "const": true
        },
        "field": {
          "type": "object",
          "properties": {
            "kind": {
              "const": "field"
            },
            "blockId": {
              "type": "string"
            },
            "occurrenceIndex": {
              "type": "integer"
            },
            "nestingDepth": {
              "type": "integer"
            },
            "storyId": {
              "type": "string"
            },
            "fieldId": {
              "type": "string"
            }
          },
          "additionalProperties": false,
          "required": [
            "kind",
            "blockId",
            "occurrenceIndex"
          ]
        }
      },
      "additionalProperties": false,
      "required": [
        "success",
        "field"
      ]
    },
    {
      "type": "object",
      "properties": {
        "success": {
          "const": false
        },
        "failure": {
          "type": "object",
          "properties": {
            "code": {
              "type": "string"
            },
            "message": {
              "type": "string"
            },
            "details": {}
          },
          "additionalProperties": false,
          "required": [
            "code",
            "message"
          ]
        }
      },
      "additionalProperties": false,
      "required": [
        "success",
        "failure"
      ]
    }
  ]
}
```

## Pre-apply throws

- `TARGET_NOT_FOUND`
- `INVALID_TARGET`
- `INVALID_INPUT`
- `CAPABILITY_UNAVAILABLE`

## Non-applied receipt codes

- None

