Page cover

๐Ÿ’พWebhooks

List webhooks for a workspace

GET /2.0/workspaces/{workspace}/hooks

Returns a paginated list of webhooks installed on this workspace.

package main

import (
	"context"
	"fmt"
	"github.com/ctreminiom/go-atlassian/bitbucket"
	"log"
	"os"
)

func main() {

	token := os.Getenv("BITBUCKET_TOKEN")

	instance, err := bitbucket.New(nil, "")
	if err != nil {
		log.Fatal(err)
	}

	instance.Auth.SetBearerToken(token)
	instance.Auth.SetUserAgent("curl/7.54.0")

	hooks, response, err := instance.Workspace.Hook.Gets(context.TODO(), "ctreminiom")
	if err != nil {

		log.Println(response.Endpoint)
		log.Println(response.Bytes.String())
		log.Fatal(err)
	}

	for _, hook := range hooks.Values {
		fmt.Println(hook.UUID, hook.Description, hook.Events, hook.URL)
	}
}

Create webhook for a workspace

POST /2.0/workspaces/{workspace}/hooks

Creates a new webhook on the specified workspace. Workspace webhooks are fired for events from all repositories contained by that workspace.

Update webhook for a workspace

PUT /2.0/workspaces/{workspace}/hooks/{uid}

Updates the specified webhook subscription.

Get webhook for a workspace

GET /2.0/workspaces/{workspace}/hooks/{uid}

Returns the webhook with the specified id installed on the given workspace.

Delete webhook for a workspace

DELETE /2.0/workspaces/{workspace}/hooks/{uid}

Deletes the specified webhook subscription from the given workspace.

Last updated

Was this helpful?