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

# changes.patch()

> Amend metadata, apply file operations, or resolve conflicts on an existing change.

Patch a change. A successful patch snapshots the result into a new commit owned by the same Mesa change.

**Required scope: `write`**

```python theme={null}
import base64
from mesa_sdk import FileUpsert

change = await mesa.changes.patch(
    repo="app",
    change_id="zyxwvutsrqponmlkzyxwvutsrqponmlk",
    message="Update README",
    files=[
        FileUpsert(
            path="README.md",
            content=base64.b64encode(b"# Updated\n").decode(),
        )
    ],
)
```

Resolve conflicts:

```python theme={null}
from mesa_sdk import HunkFix, HunkResolution

change = await mesa.changes.patch(
    repo="app",
    change_id="zyxwvutsrqponmlkzyxwvutsrqponmlk",
    resolutions=[
        HunkResolution(
            path="README.md",
            hunks=[HunkFix(hunk_id="h1", take="target")],
        )
    ],
)
```

## Options

<ParamField path="repo" type="str" required>
  Repository name.
</ParamField>

<ParamField path="change_id" type="str" required>
  Existing Mesa change ID.
</ParamField>

<ParamField path="org" type="str | None">
  Organization override.
</ParamField>

<ParamField path="message" type="str | None">
  Replacement change description. Pass `None` to omit the field and preserve the existing description; pass `""` to clear it.
</ParamField>

<ParamField path="author" type="Author | None">
  New author identity.
</ParamField>

<ParamField path="committer" type="Author | None">
  New committer identity.
</ParamField>

<ParamField path="files" type="list[FileChange] | None">
  File operations to apply. Mutually exclusive with `resolutions`.
</ParamField>

<ParamField path="base_commit_oid" type="str | None">
  Optimistic-concurrency token. When set, the patch fails with `ConflictError` if the change has advanced past this commit.
</ParamField>

<ParamField path="resolutions" type="list[Resolution] | None">
  Conflict resolutions to apply to a conflicted change. Mutually exclusive with `files`.
</ParamField>

## Response

<ResponseField name="id" type="str">
  Change ID.
</ResponseField>

<ResponseField name="current_commit_oid" type="str">
  Current commit OID for the change.
</ResponseField>

<ResponseField name="is_conflicted" type="bool">
  Whether the current commit still contains unresolved conflicts.
</ResponseField>

<ResponseField name="message" type="str">
  Current change description. Empty string means the change has no description.
</ResponseField>

<ResponseField name="author" type="CommitIdentity">
  Commit author identity.
</ResponseField>

<ResponseField name="committer" type="CommitIdentity">
  Committer identity.
</ResponseField>

<ResponseField name="parents" type="list[str]">
  Parent change IDs for this change.
</ResponseField>

<ResponseField name="created_at" type="datetime">
  Creation time.
</ResponseField>

<ResponseField name="updated_at" type="datetime">
  Last update time.
</ResponseField>

### CommitIdentity

<ResponseField name="name" type="str">
  Author or committer display name.
</ResponseField>

<ResponseField name="email" type="str">
  Author or committer email address.
</ResponseField>

<ResponseField name="date" type="datetime | None">
  Timestamp for this identity when provided.
</ResponseField>
