Skip to main content

Create or update file contents

Creates a new file or replaces an existing file in a repository.

PUT/repos/{owner}/{repo}/contents/{path}
Source
github-v3-rest.json
Revision
f5f067c1e6f6
Active snapshot
85e53e3d0d65

Request

Path Parameters
owner string
required
repo string
required
path string
required

path parameter

Body Params
required
application/jsonobject
author object
optional

The author of the file. Default: The `committer` or the authenticated user if you omit `committer`.

date string
optional

Example: "2013-01-15T17:13:22+05:00"

email string
required

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

name string
required

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

branch string
optional

The branch name. Default: the repository’s default branch (usually `master`)

committer object
optional

The person that committed the file. Default: the authenticated user.

date string
optional

Example: "2013-01-05T13:13:22+05:00"

email string
required

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

name string
required

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

content string
required

The new file content, using Base64 encoding.

message string
required

The commit message.

sha string
optional

**Required if you are updating a file**. The blob SHA of the file being replaced.

Responses

application/json File Commit object

Response

commit object
required
author object
optional
date string
optional
email string
optional
name string
optional
committer object
optional
date string
optional
email string
optional
name string
optional
html_url string
optional
message string
optional
node_id string
optional
parents array[object]
optional
items object
html_url string
optional
sha string
optional
url string
optional
sha string
optional
tree object
optional
sha string
optional
url string
optional
url string
optional
verification object
optional
payload string
optionalnullable
reason string
optional
signature string
optionalnullable
verified boolean
optional
content object
requirednullable
_links object
optional
git string
optional
html string
optional
self string
optional
download_url string
optional
git_url string
optional
html_url string
optional
name string
optional
path string
optional
sha string
optional
size integer
optional
type string
optional
url string
optional
application/json File Commit object

Response

commit object
required
author object
optional
date string
optional
email string
optional
name string
optional
committer object
optional
date string
optional
email string
optional
name string
optional
html_url string
optional
message string
optional
node_id string
optional
parents array[object]
optional
items object
html_url string
optional
sha string
optional
url string
optional
sha string
optional
tree object
optional
sha string
optional
url string
optional
url string
optional
verification object
optional
payload string
optionalnullable
reason string
optional
signature string
optionalnullable
verified boolean
optional
content object
requirednullable
_links object
optional
git string
optional
html string
optional
self string
optional
download_url string
optional
git_url string
optional
html_url string
optional
name string
optional
path string
optional
sha string
optional
size integer
optional
type string
optional
url string
optional
application/json Basic Error object

Resource not found

documentation_url string
optional
message string
optional
status string
optional
url string
optional
application/json Basic Error object

Conflict

documentation_url string
optional
message string
optional
status string
optional
url string
optional
application/json Validation Error object

Validation failed

documentation_url string
required
errors array[object]
optional
items object
code string
required
field string
optional
index integer
optional
message string
optional
resource string
optional
value
optional
message string
required