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

# repos_create_or_update_file

> Create a file or replace an existing one, in a single commit. Write the content as plain text. To replace a file, read it first and pass its `sha`; without one GitHub treats this as a create and refuses if the path exists.

<div className="tool-route"><span className="tool-row-method" data-method="PUT">PUT</span><code>{"https://api.github.com/repos/{owner}/{repo}/contents/{path}"}</code></div>

```python github_repos_create_or_update_file.py theme={null}
from charter.packs import github

result = await github.repos_create_or_update_file.ainvoke({"owner": ..., "repo": ..., "path": ..., "message": ..., "content": ...})
```

<Note>
  Requires `repo`, `read:user`.
</Note>

## Path parameters

<div className="reference-table">
  | Field                                                         | Type     | Description                                                                              |
  | ------------------------------------------------------------- | -------- | ---------------------------------------------------------------------------------------- |
  | `owner` <span className="required" title="required">\*</span> | `string` | The account owner of the repository. The name is not case sensitive.                     |
  | `repo` <span className="required" title="required">\*</span>  | `string` | The name of the repository without the `.git` extension. The name is not case sensitive. |
  | `path` <span className="required" title="required">\*</span>  | `string` | Path to the file, relative to the repository root.                                       |
</div>

## Body

<div className="reference-table">
  | Field                                                           | Type                                                                                                          | Description                                                                                                        |
  | --------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ |
  | `message` <span className="required" title="required">\*</span> | `string`                                                                                                      | The commit message.                                                                                                |
  | `content` <span className="required" title="required">\*</span> | `string`<br /><span className="markers"><span className="marker" data-marker="transform">base64</span></span> | Plain text content                                                                                                 |
  | `sha`                                                           | `string`                                                                                                      | The blob SHA of the file being replaced. Required when updating an existing file, omitted when creating a new one. |
  | `branch`                                                        | `string`                                                                                                      | The branch to commit to. Absent, the default branch.                                                               |
  | `committer`                                                     | [GitAuthor](/charter/charter/packs/github/repos/objects#gitauthor)                                                    | Who made the commit. Absent, the authenticated user.                                                               |
  | `author`                                                        | [GitAuthor](/charter/charter/packs/github/repos/objects#gitauthor)                                                    | Who wrote the change, if not the committer.                                                                        |
</div>
