Create

Creates a new file in the repository.

Required scopes: WORKSPACE, REPOSITORY_WRITE

Resource URL

POST /workspaces/:domain/projects/:project_name/repository/contents

URL Parameters

NameTypeDescription
domain
Required
StringThe workspace domain.
project_name
Required
StringThe name ID of the project.

POST Parameters

NameTypeDescription
content
Required
StringThe file contents encoded in Base64.
message
Required
StringThe log message of a commit.
path
Required
StringThe new file location in the repository.
branchStringThe branch name.

Example

Request

POST https://api.buddy.works/workspaces/buddy/projects/company-website/repository/contents

JSON

{
  "path": "test.txt",
  "branch": "development",
  "message": "add test.txt",
  "content": "TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNlY3RldHVyIGFkaXBpc2NpbmcgZWxpdC4gTnVuYyBwcmV0aXVtIG9kaW8gZWdldCB0ZWxsdXMgYWxpcXVhbSwgdmVsIHZ1bHB1dGF0ZSBzYXBpZW4gdmVzdGlidWx1bS4="
}

Sample Response

HTTP

Status: 201 Created
X-Rate-Limit-Limit: 1
X-Rate-Limit-Remaining: 999

JSON

{
  "content": {
    "url": "https://api.buddy.works/workspaces/buddy/projects/company-website/repository/contents/test.txt?revision=f659e787d8f6c19c125c60c025afa9d0def29fed",
    "html_url": "https://app.buddy.works/buddy/company-website/repository/content/revision/f659e787d8f6c19c125c60c025afa9d0def29fed/test.txt",
    "content_type": "FILE",
    "encoding": "base64",
    "size": 128,
    "name": "test.txt",
    "path": "test.txt",
    "content": "TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNlY3RldHVyIGFkaXBpc2NpbmcgZWxpdC4gTnVuYyBwcmV0aXVtIG9kaW8gZWdldCB0ZWxsdXMgYWxpcXVhbSwgdmVsIHZ1bHB1dGF0ZSBzYXBpZW4gdmVzdGlidWx1bS4="
  },
  "commit": {
    "url": "https://api.buddy.works/workspaces/buddy/projects/company-website/repository/commits/f659e787d8f6c19c125c60c025afa9d0def29fed",
    "html_url": "https://app.buddy.works/buddy/company-website/repository/commit/f659e787d8f6c19c125c60c025afa9d0def29fed",
    "revision": "f659e787d8f6c19c125c60c025afa9d0def29fed",
    "author_date": "2016-03-02T12:31:32Z",
    "commit_date": "2016-03-02T12:31:32Z",
    "message": "add test.txt",
    "committer": {
      "url": "https://api.buddy.works/workspaces/buddy/member/1",
      "html_url": "https://app.buddy.works/buddy/profile/1",
      "id": 1,
      "name": "Mike Benson",
      "avatar_url": "https://app.buddy.works/image-server/user/0/0/0/0/0/0/1/d643744fbe5ebf2906a4d075a5b97110/w/32/32/AVATAR.png"
    },
    "author": {
      "url": "https://api.buddy.works/workspaces/buddy/member/1",
      "html_url": "https://app.buddy.works/buddy/profile/1",
      "id": 1,
      "name": "Mike Benson",
      "avatar_url": "https://app.buddy.works/image-server/user/0/0/0/0/0/0/1/d643744fbe5ebf2906a4d075a5b97110/w/32/32/AVATAR.png"
    }
  }
}

Last modified on April 26, 2022

Get Started

Sign up for free and deploy your project in less than 10 minutes.