PUT /repos/{owner}/{repo}/contents/{path}
Creates a new file or replaces an existing file in a repository.
[!NOTE] If you use this endpoint and the "Delete a file" endpoint in parallel, the concurrent requests will conflict and you will receive errors. You must use these endpoints serially instead.
OAuth app tokens and personal access tokens (classic) need the repo
scope to use this endpoint. The workflow
scope is also required in order to modify files in the .github/workflows
directory.
Servers
- https://api.github.com
Path parameters
Name | Type | Required | Description |
---|---|---|---|
repo |
String | Yes |
The name of the repository without the |
owner |
String | Yes |
The account owner of the repository. The name is not case sensitive. |
path |
String | Yes |
path parameter |
Request headers
Name | Type | Required | Description |
---|---|---|---|
Content-Type |
String | Yes |
The media type of the request body.
Default value: "application/json" |
Request body fields
Name | Type | Required | Description |
---|---|---|---|
sha |
String | No |
Required if you are updating a file. The blob SHA of the file being replaced. |
committer |
Object | No |
The person that committed the file. Default: the authenticated user. |
committer.name |
String | Yes |
The name of the author or committer of the commit. You'll receive a |
committer.email |
String | Yes |
The email of the author or committer of the commit. You'll receive a |
committer.date |
String | No | |
message |
String | Yes |
The commit message. |
branch |
String | No |
The branch name. Default: the repository’s default branch. |
content |
String | Yes |
The new file content, using Base64 encoding. |
author |
Object | No |
The author of the file. Default: The |
author.name |
String | Yes |
The name of the author or committer of the commit. You'll receive a |
author.email |
String | Yes |
The email of the author or committer of the commit. You'll receive a |
author.date |
String | No |
How to start integrating
- Add HTTP Task to your workflow definition.
- Search for the API you want to integrate with and click on the name.
- This loads the API reference documentation and prepares the Http request settings.
- Click Test request to test run your request to the API and see the API's response.