Skip to main content
Skip table of contents

How to get configurations using Post Webhooks for Bitbucket APIs?

API for 2.5.3 and lower versions

Prior to version 3.5.5 configurations exist only at the repository level and there is no API to get all available configurations at one REST call.

API:

CODE
/rest/webhook/1.0/projects/$PROJECT/repos/$REPO/configurations

Returns a list of configurations per repository.

Full description at Atlassian Bitbucket Post Webhook API

API for 3.5.5 and newer versions

All operations respect user permissions. If the user doesn’t have permissions to a project/repository he can’t get/save/update/delete configurations at particular levels.

  • Get all configurations:

    CODE
    GET
    /rest/webhook/2.0/configurations

    Response:

    CODE
    [
       {
          "id":2,
          "enabled":true,
          "name":"test",
          "destinations":[
             {
                "useUrl":false,
                "url":"http://localhost:8080/test"
             }
          ],
          "sources":[
             {
                "projectKey":"PROJECT_1",
                "repositorySlug":"rep_1"
             }
          ],
          "ignoredSources":[
             
          ],
          "users":[
             
          ],
          "ignoredUsers":[
             
          ],
          "groups":[
             
          ],
          "ignoredGroups":[
             
          ],
          "projectKey":"PROJECT_1",
          "repositorySlug":"rep_1",
          "eventTypes":[
             "TAG_CREATED",
             "BRANCH_DELETED",
             "ABSTRACT_REPOSITORY_REFS_CHANGED",
             "PULL_REQUEST_OPENED",
             "PULL_REQUEST_COMMENT",
             "PULL_REQUEST_CANCELABLE_COMMENT",
             "PULL_REQUEST_COMMENT_ACTIVITY"
          ],
          "pullRequestBranchSource":"FROM",
          "ignoreCerts":false,
          "ignoreURLValidation":false,
          "override":true,
          "skipCI":false,
          "azureDevOps":false,
          "skipPersonalProjects":false,
          "azureSource":"CLOUD",
          "httpMethod":"POST",
          "enableAuthentication":false,
          "authenticationType":"BASIC",
          "mutualAuthenticationEnabled":false,
          "type":"NOTIFICATION"
       }
    ]

  • Get all configurations for the project

    CODE
    GET
    /rest/webhook/2.0/configurations?projectKey=$PROJECT

    Response:

    CODE
    [
       {
          "id":2,
          "enabled":true,
          "name":"test",
          "destinations":[
             {
                "useUrl":false,
                "url":"http://localhost:8080/test"
             }
          ],
          "sources":[
             {
                "projectKey":"PROJECT_1",
                "repositorySlug":"rep_1"
             }
          ],
          "ignoredSources":[
             
          ],
          "users":[
             
          ],
          "ignoredUsers":[
             
          ],
          "groups":[
             
          ],
          "ignoredGroups":[
             
          ],
          "projectKey":"PROJECT_1",
          "repositorySlug":"rep_1",
          "eventTypes":[
             "TAG_CREATED",
             "BRANCH_DELETED",
             "ABSTRACT_REPOSITORY_REFS_CHANGED",
             "PULL_REQUEST_OPENED",
             "PULL_REQUEST_COMMENT",
             "PULL_REQUEST_CANCELABLE_COMMENT",
             "PULL_REQUEST_COMMENT_ACTIVITY"
          ],
          "pullRequestBranchSource":"FROM",
          "ignoreCerts":false,
          "ignoreURLValidation":false,
          "override":true,
          "skipCI":false,
          "azureDevOps":false,
          "skipPersonalProjects":false,
          "azureSource":"CLOUD",
          "httpMethod":"POST",
          "enableAuthentication":false,
          "authenticationType":"BASIC",
          "mutualAuthenticationEnabled":false,
          "type":"NOTIFICATION"
       }
    ]

  • Get all configurations for the repository

    CODE
    GET
    /rest/webhook/2.0/configurations?projectKey=$PROJECT&repositorySlug=$REPOSITORY

  • Response:

    CODE
    [
       {
          "id":2,
          "enabled":true,
          "name":"test",
          "destinations":[
             {
                "useUrl":false,
                "url":"http://localhost:8080/test"
             }
          ],
          "sources":[
             {
                "projectKey":"PROJECT_1",
                "repositorySlug":"rep_1"
             }
          ],
          "ignoredSources":[
             
          ],
          "users":[
             
          ],
          "ignoredUsers":[
             
          ],
          "groups":[
             
          ],
          "ignoredGroups":[
             
          ],
          "projectKey":"PROJECT_1",
          "repositorySlug":"rep_1",
          "eventTypes":[
             "TAG_CREATED",
             "BRANCH_DELETED",
             "ABSTRACT_REPOSITORY_REFS_CHANGED",
             "PULL_REQUEST_OPENED",
             "PULL_REQUEST_COMMENT",
             "PULL_REQUEST_CANCELABLE_COMMENT",
             "PULL_REQUEST_COMMENT_ACTIVITY"
          ],
          "pullRequestBranchSource":"FROM",
          "ignoreCerts":false,
          "ignoreURLValidation":false,
          "override":true,
          "skipCI":false,
          "azureDevOps":false,
          "skipPersonalProjects":false,
          "azureSource":"CLOUD",
          "httpMethod":"POST",
          "enableAuthentication":false,
          "authenticationType":"BASIC",
          "mutualAuthenticationEnabled":false,
          "type":"NOTIFICATION"
       }
    ]

  • Delete configuration by ID:

    CODE
    DELETE
    /rest/webhook/2.0/configurations/$ID

    Response:

    CODE
    {
          "id":2,
          "enabled":true,
          "name":"test",
          "destinations":[
             {
                "useUrl":false,
                "url":"http://localhost:8080/test"
             }
          ],
          "sources":[
             {
                "projectKey":"PROJECT_1",
                "repositorySlug":"rep_1"
             }
          ],
          "ignoredSources":[
             
          ],
          "users":[
             
          ],
          "ignoredUsers":[
             
          ],
          "groups":[
             
          ],
          "ignoredGroups":[
             
          ],
          "projectKey":"PROJECT_1",
          "repositorySlug":"rep_1",
          "eventTypes":[
             "TAG_CREATED",
             "BRANCH_DELETED",
             "ABSTRACT_REPOSITORY_REFS_CHANGED",
             "PULL_REQUEST_OPENED",
             "PULL_REQUEST_COMMENT",
             "PULL_REQUEST_CANCELABLE_COMMENT",
             "PULL_REQUEST_COMMENT_ACTIVITY"
          ],
          "pullRequestBranchSource":"FROM",
          "ignoreCerts":false,
          "ignoreURLValidation":false,
          "override":true,
          "skipCI":false,
          "azureDevOps":false,
          "skipPersonalProjects":false,
          "azureSource":"CLOUD",
          "httpMethod":"POST",
          "enableAuthentication":false,
          "authenticationType":"BASIC",
          "mutualAuthenticationEnabled":false,
          "type":"NOTIFICATION"
       }

  • Get configuration by ID

    CODE
    GET
    /rest/webhook/2.0/configurations/$ID

    Response:

    CODE
    {
          "id":2,
          "enabled":true,
          "name":"test",
          "destinations":[
             {
                "useUrl":false,
                "url":"http://localhost:8080/test"
             }
          ],
          "sources":[
             {
                "projectKey":"PROJECT_1",
                "repositorySlug":"rep_1"
             }
          ],
          "ignoredSources":[
             
          ],
          "users":[
             
          ],
          "ignoredUsers":[
             
          ],
          "groups":[
             
          ],
          "ignoredGroups":[
             
          ],
          "projectKey":"PROJECT_1",
          "repositorySlug":"rep_1",
          "eventTypes":[
             "TAG_CREATED",
             "BRANCH_DELETED",
             "ABSTRACT_REPOSITORY_REFS_CHANGED",
             "PULL_REQUEST_OPENED",
             "PULL_REQUEST_COMMENT",
             "PULL_REQUEST_CANCELABLE_COMMENT",
             "PULL_REQUEST_COMMENT_ACTIVITY"
          ],
          "pullRequestBranchSource":"FROM",
          "ignoreCerts":false,
          "ignoreURLValidation":false,
          "override":true,
          "skipCI":false,
          "azureDevOps":false,
          "skipPersonalProjects":false,
          "azureSource":"CLOUD",
          "httpMethod":"POST",
          "enableAuthentication":false,
          "authenticationType":"BASIC",
          "mutualAuthenticationEnabled":false,
          "type":"NOTIFICATION"
       }

  • Save configuration

    CODE
    POST
    /rest/webhook/2.0/configurations
    
    Body:
    {
          "enabled":true,
          "name":"test",
          "destinations":[
             {
                "useUrl":false,
                "url":"http://localhost:8080/test"
             }
          ],
          "sources":[
             {
                "projectKey":"PROJECT_1",
                "repositorySlug":"rep_1"
             }
          ],
          "ignoredSources":[
             
          ],
          "users":[
             
          ],
          "ignoredUsers":[
             
          ],
          "groups":[
             
          ],
          "ignoredGroups":[
             
          ],
          "projectKey":"PROJECT_1",
          "repositorySlug":"rep_1",
          "eventTypes":[
             "TAG_CREATED",
             "BRANCH_DELETED",
             "ABSTRACT_REPOSITORY_REFS_CHANGED",
             "PULL_REQUEST_OPENED",
             "PULL_REQUEST_COMMENT",
             "PULL_REQUEST_CANCELABLE_COMMENT",
             "PULL_REQUEST_COMMENT_ACTIVITY"
          ],
          "pullRequestBranchSource":"FROM",
          "ignoreCerts":false,
          "ignoreURLValidation":false,
          "override":true,
          "skipCI":false,
          "azureDevOps":false,
          "skipPersonalProjects":false,
          "azureSource":"CLOUD",
          "httpMethod":"POST",
          "enableAuthentication":false,
          "authenticationType":"BASIC",
          "mutualAuthenticationEnabled":false,
          "type":"NOTIFICATION"
       }

    Response:

    CODE
    {
          "id":2,
          "enabled":true,
          "name":"test",
          "destinations":[
             {
                "useUrl":false,
                "url":"http://localhost:8080/test"
             }
          ],
          "sources":[
             {
                "projectKey":"PROJECT_1",
                "repositorySlug":"rep_1"
             }
          ],
          "ignoredSources":[
             
          ],
          "users":[
             
          ],
          "ignoredUsers":[
             
          ],
          "groups":[
             
          ],
          "ignoredGroups":[
             
          ],
          "projectKey":"PROJECT_1",
          "repositorySlug":"rep_1",
          "eventTypes":[
             "TAG_CREATED",
             "BRANCH_DELETED",
             "ABSTRACT_REPOSITORY_REFS_CHANGED",
             "PULL_REQUEST_OPENED",
             "PULL_REQUEST_COMMENT",
             "PULL_REQUEST_CANCELABLE_COMMENT",
             "PULL_REQUEST_COMMENT_ACTIVITY"
          ],
          "pullRequestBranchSource":"FROM",
          "ignoreCerts":false,
          "ignoreURLValidation":false,
          "override":true,
          "skipCI":false,
          "azureDevOps":false,
          "skipPersonalProjects":false,
          "azureSource":"CLOUD",
          "httpMethod":"POST",
          "enableAuthentication":false,
          "authenticationType":"BASIC",
          "mutualAuthenticationEnabled":false,
          "type":"NOTIFICATION"
       }

  • Update configuration

    CODE
    PUT
    /rest/webhook/2.0/configurations/$ID
    
    Body:
    {
          "enabled":true,
          "name":"test",
          "destinations":[
             {
                "useUrl":false,
                "url":"http://localhost:8080/test"
             }
          ],
          "sources":[
             {
                "projectKey":"PROJECT_1",
                "repositorySlug":"rep_1"
             }
          ],
          "ignoredSources":[
             
          ],
          "users":[
             
          ],
          "ignoredUsers":[
             
          ],
          "groups":[
             
          ],
          "ignoredGroups":[
             
          ],
          "projectKey":"PROJECT_1",
          "repositorySlug":"rep_1",
          "eventTypes":[
             "TAG_CREATED",
             "BRANCH_DELETED",
             "ABSTRACT_REPOSITORY_REFS_CHANGED",
             "PULL_REQUEST_OPENED",
             "PULL_REQUEST_COMMENT",
             "PULL_REQUEST_CANCELABLE_COMMENT",
             "PULL_REQUEST_COMMENT_ACTIVITY"
          ],
          "pullRequestBranchSource":"FROM",
          "ignoreCerts":false,
          "ignoreURLValidation":false,
          "override":true,
          "skipCI":false,
          "azureDevOps":false,
          "skipPersonalProjects":false,
          "azureSource":"CLOUD",
          "httpMethod":"POST",
          "enableAuthentication":false,
          "authenticationType":"BASIC",
          "mutualAuthenticationEnabled":false,
          "type":"NOTIFICATION"
       }

    Response:

    CODE
    {
          "id":2,
          "enabled":true,
          "name":"test",
          "destinations":[
             {
                "useUrl":false,
                "url":"http://localhost:8080/test"
             }
          ],
          "sources":[
             {
                "projectKey":"PROJECT_1",
                "repositorySlug":"rep_1"
             }
          ],
          "ignoredSources":[
             
          ],
          "users":[
             
          ],
          "ignoredUsers":[
             
          ],
          "groups":[
             
          ],
          "ignoredGroups":[
             
          ],
          "projectKey":"PROJECT_1",
          "repositorySlug":"rep_1",
          "eventTypes":[
             "TAG_CREATED",
             "BRANCH_DELETED",
             "ABSTRACT_REPOSITORY_REFS_CHANGED",
             "PULL_REQUEST_OPENED",
             "PULL_REQUEST_COMMENT",
             "PULL_REQUEST_CANCELABLE_COMMENT",
             "PULL_REQUEST_COMMENT_ACTIVITY"
          ],
          "pullRequestBranchSource":"FROM",
          "ignoreCerts":false,
          "ignoreURLValidation":false,
          "override":true,
          "skipCI":false,
          "azureDevOps":false,
          "skipPersonalProjects":false,
          "azureSource":"CLOUD",
          "httpMethod":"POST",
          "enableAuthentication":false,
          "authenticationType":"BASIC",
          "mutualAuthenticationEnabled":false,
          "type":"NOTIFICATION"
       }

Configuration levels

Configuration level is defined by two properties in the root of the record:

CODE
"projectKey":
"repositorySlug":

  • Global level

    CODE
    "projectKey": null
    or
    "projectKey": "b555a433-6a6a-442a-8870-df97c33bb6b" //special constant

  • Project level:

    CODE
    "projectKey": "$PROJECT_KEY"

  • Repository level:

    CODE
    "projectKey": "$PROJECT_KEY",
    "repositorySlug": "$REPOSITORY_SLUG"

Configuration affections

Configuration can affect only specific projects/repositories. By default configuration affect the level at which it's specified but the scope can be narrowed by providing the “sources” property.
Example:

CODE
{
   "projectKey": null,
   "sources": []
}
  • Configuration handles the events in all projects/repositories.

CODE
{
   "projectKey": null,
   "sources": [
       {
       "projectKey": "PROJECT_1"
       },
       {
       "projectKey": "PROJECT_2",
       "repositorySlug": "rep_2"
       }
   ]
}
  • Configuration handles the events in all repositories from “PROJECT_1“ and repository “rep_2“ from the project “PROJECT_2“.

CODE
{
   "projectKey": PROJECT_1,
   "sources": [
       {
       "projectKey": "PROJECT_1",
       "repositorySlug": "rep_1"
       },
       {
       "projectKey": "PROJECT_1",
       "repositorySlug": "rep_2"
       }
   ]
}
  • Configuration handles the events from repositories “rep_1“ and “rep_2“ from the project “PROJECT_1“.


How to create a new webhook?

How to set up Azure DevOps Pipeline triggering from Bitbucket Server?

How to enable notifications from Bitbucket in Microsoft Teams?

Global Configurations for Bitbucket admins

Project Level Configurations

Repository Level Configurations

Updated:

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.