Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Disable and Enable hooks in Bitbucket

Hi, I'd like to enable and disable hooks, like: 'Reject Force Push', through script.
Is it possible? Exists API to do that action?



2 answers

1 accepted

1 vote
Answer accepted

@Raphael Viana 

You can make a Bitbucket REST API call (via curl or postman) to enable/disable specific hooks programmatically.

1. GET your repo hook keys via /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/settings/hooks

2. PUT request for hook to be enabled  (DELETE disables the hook) via /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/settings/hooks/{hookKey}/enabled

As a general practice for automating UI tasks, play the scenario in the UI and log the XHR data requests in the browser console. This gives you a good idea what to look for in the REST API spec.

Let me know if that approach works for you.

Best, Ulrich

Izymes - Remove boring from work 

Hey @Ulrich Kuhnhardt _IzymesCo_ 
thanks so much about your explanation.
I got it and my automation works now.

0 votes
Syahrul Atlassian Team Nov 07, 2021

Hi @Raphael Viana

Welcome to the community!

Currently, Bitbucket doesn't support the Hooks feature. We do have an existing feature request on this, please Vote & Watch the feature request so that you'll receive an update if we have any at:

Meantime, you may want to look into an alternate feature Bitbucket has which is Branch permission where you can enforce specific workflows and prevent errors like a new workspace member deleting the main branch or pushing to branch without creating pull request and approved.

Feel free to let me know if you have any additional questions.


Hey @Syahrul
I'd like to check that information.


In BitBuket server we can't enable or disable pre-receive hook with API or
another script access, that action is only possible manually. Correct?

Syahrul Atlassian Team Nov 08, 2021

Hi @Raphael Viana

Apologize for that as I thought you were asking about Bitbucket cloud. If you are looking into Bitbucket server, I believe this documentation could help you:

If you still failing to enable or use your pre-hook I would suggest you raise a support ticket for further assistance.

I hope this helps.


It's possible to enable or disable the hooks using traditional API path as @Ulrich Kuhnhardt _IzymesCo_  said.
It's a great point to put in tutorial or any other content.
As complementing: PUT verb enable hook and Delete disable, so by this way we can control hooks passing his key (obtained through GET to the same endpoint).

Like # people like this

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Bitbucket

Git push size limits are coming to Bitbucket Cloud starting April 4th, 2022

Beginning on April 4th, we will be implementing push limits. This means that your push cannot be completed if it is over 3.5 GB. If you do attempt to complete a push that is over 3.5 GB, it will fail...

2,229 views 2 9
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you