Skip to main content
PUT
/
repos
/
{owner}
/
{repo}
/
contents
/
{path}
Create or update a file
curl --request PUT \
  --url https://gogs.example.com/api/v1/repos/{owner}/{repo}/contents/{path} \
  --header 'Authorization: <api-key>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "message": "<string>",
  "content": "<string>",
  "branch": "<string>"
}
'
{
  "content": {
    "type": "file",
    "encoding": "<string>",
    "size": 123,
    "name": "<string>",
    "path": "<string>",
    "content": "<string>",
    "sha": "<string>",
    "url": "<string>",
    "git_url": "<string>",
    "html_url": "<string>",
    "download_url": "<string>",
    "_links": {
      "git": "<string>",
      "self": "<string>",
      "html": "<string>"
    }
  },
  "commit": {
    "url": "<string>",
    "sha": "<string>",
    "html_url": "<string>",
    "commit": {
      "url": "<string>",
      "message": "<string>",
      "author": {
        "name": "<string>",
        "email": "<string>",
        "date": "<string>"
      },
      "committer": {
        "name": "<string>",
        "email": "<string>",
        "date": "<string>"
      },
      "tree": {
        "url": "<string>",
        "sha": "<string>"
      }
    },
    "author": {
      "id": 123,
      "username": "<string>",
      "login": "<string>",
      "full_name": "<string>",
      "email": "[email protected]",
      "avatar_url": "<string>"
    },
    "committer": {
      "id": 123,
      "username": "<string>",
      "login": "<string>",
      "full_name": "<string>",
      "email": "[email protected]",
      "avatar_url": "<string>"
    },
    "parents": [
      {
        "url": "<string>",
        "sha": "<string>"
      }
    ]
  }
}

Authorizations

Authorization
string
header
required

Personal access token. Use format: token {YOUR_ACCESS_TOKEN}

Path Parameters

owner
string
required

Owner of the repository

repo
string
required

Name of the repository

path
string
required

Path of the file to create or update

Body

application/json
message
string
required

Commit message

content
string
required

Base64-encoded file content

branch
string

Branch to commit to. Defaults to the repository's default branch.

Response

File created or updated successfully.

content
object
commit
object