Integrating Bitbucket and Slack via API

Noa Schvartz January 5, 2025

Hey :)
I'm writing a python script that creates and configures the bitbucket repositories in a certain workspace for my team, using the Bitbucket Cloud API.

Part of our configuration is adding some slack notifications, and until now we configured it like you mentioned in your documentation here https://support.atlassian.com/bitbucket-cloud/docs/integrate-bitbucket-cloud-with-slack/ 

To my understanding (fix me if i'm wrong) this configuration is different than the traditional webhook configuration, as written in the above link and as seen in the UI, but it seems like the API does not support it (used this API doc)

 

My team and I would like to get some guidance for how to handle this, assuming we don't want to continue creating the integration manually; should we use the API and add slack as a webhook? will this method be out of support sometime?

Thanks in advance!

1 answer

1 accepted

0 votes
Answer accepted
Ben
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 6, 2025

Hi Noa,

Can you please clarify the exact behaviour you are trying to achieve? Are you trying to use the API to trigger a slack notification?

The recommended method for integrating Slack notifications is via the documentation you've provided.

Cheers!

- Ben (Bitbucket Cloud Support)

 

Noa Schvartz January 8, 2025

Hey, Thank you for your answer!

To clarify, I'm not looking to directly trigger a Slack notification using the API.

Instead, using the API, I want to configure my repository to send Slack notifications for certain events, such as when a pull request is created.

The only way I saw possible for doing so is using webhook related API calls, for example:

curl --location 'https://api.bitbucket.org/2.0/repositories/<workspace>/<repo slug>/hooks' --header .... 

--request POST
--data '{
"description": "Slack notifications",
"active": true,
"events": ["pullrequest:created"]
}'

But then this is the outcome:

image.png

While in the documentation it's a completely different settings section and configuration process:image.png

The behavior I would like to achieve is to configure using the API what you call a slack integration (the picture above), and not a webhook directing to slack.

Is that possible? and if not, do you suggest creating a webhook for every repository (assuming we want it automatic)?

Have a pleasant day!

 

Ben
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 8, 2025

Hi Noa,

Unfortunately, you are not able to configure a Slack integration over API which would not just be a regular webhook.

Refer to this documentation to install the Slack integration, this will allow you to configure which events would trigger a Slack notification:

Essentially you would go to Repository Settings > Slack and then click the Add Subscription button on this screen.

This integration is still a webhook, but does not require manual setup like you would with configuring other webhooks. 

 Please let me know if further clarification is needed.

Cheers!

- Ben (Bitbucket Cloud Support)

Noa Schvartz January 12, 2025

Okay, thank you

Erko Knoll January 18, 2025

ScriptRunner Connect has a template that integrates Bitbucket with Slack, not exactly the use case you need, but you may get some clues from that code.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin Site Admin
TAGS
AUG Leaders

Atlassian Community Events