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

Path parameters

Name Type Required Description
repo String Yes

The name of the repository without the .git extension. The name is not case sensitive.

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 422 status code if name is omitted.

committer.email String Yes

The email of the author or committer of the commit. You'll receive a 422 status code if email is omitted.

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 committer or the authenticated user if you omit committer.

author.name String Yes

The name of the author or committer of the commit. You'll receive a 422 status code if name is omitted.

author.email String Yes

The email of the author or committer of the commit. You'll receive a 422 status code if email is omitted.

author.date String No

How to start integrating

  1. Add HTTP Task to your workflow definition.
  2. 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.
  3. Click Test request to test run your request to the API and see the API's response.