Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

add boilerplate code from an old repository to a new one using an API

Abhishek Kumar March 28, 2023


I'm working on a project in JS and I have boilerplate code in one repository that I want to add to a new repository I just created in Bitbucket.

I've heard that it's possible to do this using the Bitbucket API, but I'm not sure how to get started. Specifically, I want to know:

- Which Bitbucket API should I use to add code to a new repository?

- What is the syntax for adding code to a new repository using the API?

- Are there any limitations or restrictions to adding code in this way?


Any help or guidance would be appreciated. Thanks in advance!




1 answer

0 votes
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 30, 2023

Hello @Abhishek Kumar ,

Welcome to Atlassian Community!

If you would like to commit a file to a repository using the API, you might want to use the Create a commit by uploading a file endpoint.

Following is an example of a request to that endpoint : 

curl -X POST -u username:app_password<workspace>/<repository>/src -F /repo/path/to/image.png=@image.png

This would create a new commit in the repository by uploading a local file named image.png and saving it in the repository under the directory /repo/path/to/image.png. 

In this example, we are authenticating the request using the bitbucket username (which you can find in your Personal Settings) and an App Password.

For additional examples of the usage of this endpoint, you're also welcome to check its official documentation in the link below : 

Thank you, @Abhishek Kumar !

Patrik S

Suggest an answer

Log in or Sign up to answer
Site Admin
AUG Leaders

Atlassian Community Events