1. Bitbucket
  2. Public Issue Tracker
  3. master
  4. Issues


Issue #8672 open

Is there any API to make a commit? (BB-9954)

created an issue

Is there any API to make a commit? I mean some way to send a repo a diff using rest api to apply it on the top of some branch.

Comments (111)

  1. Marcus Bertrand staff
    • changed status to open

    We've actually created one for online editing but it is undocumented. We'll keep this issue open for the day we will add this to the 2.0 API. You can discover how it works by watching the requests to the Online Editor. However, we will certainly change the behavior of this API and we wouldn't recommend using it at this time except for experimental purposes.

  2. Juha Kuitunen

    I'm speaking on behalf of Bitbeaker (open source Bitbucket client for Android). Every now and then users are requesting support for making a commit and it would be nice to someday be able to make that possible. So, big + to commit API! :)

  3. Marcus Zanona

    After some testing using the internal file editor as Marcus Bertrand recommended, I got to this point which may help a few of you :)

    //POST https://bitbucket.org/!api/internal/repositories/user/repo/oecommits/
    //JSON Request Payload:
        "branch": "master",
        "files": [
                "path": "README.md",
                "content": "Instructions Here"
                "path": "file.md",
                "content": "#New file here"
        "message": "Update README and File content",
        "parents": ["7b3f851d7864ba958656de64bbbc1e82ae1b49fd"],
        "repository": {"full_name": "user/repo"},
        "timestamp": "2014-11-19T09:20:05.338Z",
        "transient": false


    • branch field not declared creates a "None" branch
    • parents field requires only one commit_id
    • repository field doesn't seem to be necessary
    • timestamp field doesn't seem to be necessary
    • transient field omitted is the same as false, while true, creates a hidden branch (apparently with the name of the commit_id)

    I still missed a functionality where I can define the encoding type of a file like utf-8 or base64 so we can also add binaries or images. Hopefully this is something that is on their roadmap.

    The really great thing about this API which I think it should definitely stay when it is publicly released is possibility to add multiple files to a commit by having a files parameters as an array. On both Github or Gitlab, it is necessary through their API to do a lot of work before making this happen.

    So, awesome job there Bitbucket :D

  4. Chris Rose

    +1 for this, could use it in POEditor, would greatly simplify our workflow if we could have external tools update assets in a repository and use that to kick off a CI process

  5. Jakub Korál

    So you actually can use that online-editor endpoint - as mentioned in https://bitbucket.org/site/master/issues/8672/is-there-any-api-to-make-a-commit#comment-14118574

    It works with a header Authorization: Bearer xyz_your_Oauth2_token retrieved previously.

    Please just remember that you'd need to use refresh_token after an hour, so be ready. If you receive 403 with message "Access token expired. Use your refresh token to obtain a new access token" - and then use the refresh_token to obtain new access_token, try to repeat your action and be happy.

    As long as I send heads (from last branch commit), creating a new-file / updating existing file works with oecommits (internal) endpoint.

    Acquiring latest heads is easy thanks to https://bitbucket.org/api/1.0/repositories/username/repo-name/branches-tags and iterating through {"branches":[]} Array.

    But still - there are options: Either make the endpoint available publicly, or make a new and fresh one. This 2 years old-issue should be a no-brainer to finish.

    Can't be a production dependency... :-(

  6. anentropic

    I don't think so, it's just that services like Apiary have asked users to vote on this issue because users are asking them for a feature which can't be implemented without BitBucket support

  7. Joshua Perry

    With this issue languishing and all the painful workarounds required in the wiki in conjunction with github's recent reasonable pricing restructure and the fantastic new features (including a GraphQL API), I no longer see a reason to postpone migrating our projects.

  8. Log in to comment