Skip to main content

Overview

Webhook types enable integration with external services like Slack for security notifications.

Webhook

Represents a webhook configuration.
type Webhook struct {
    ID        string      `json:"id"`
    ProjectID string      `json:"-"`
    Kind      WebhookKind `json:"kind"`
    Name      string      `json:"name"`
    URL       string      `json:"url"`
    CreatedAt time.Time   `json:"created_at"`
}
id
string
required
Unique webhook identifier
kind
WebhookKind
required
Webhook type: slack
name
string
required
Human-readable webhook name
url
string
required
Webhook URL endpoint
created_at
time.Time
required
When the webhook was created

WebhookKind

Type of webhook integration.
type WebhookKind string

const (
    WebhookKindSlack WebhookKind = "slack"
)

Methods

  • String() string - Returns string representation
  • IsValid() bool - Checks if the kind is valid

WebhookCreate

Request to create a new webhook.
type WebhookCreate struct {
    Kind WebhookKind `json:"kind"`
    Name string      `json:"name"`
    URL  string      `json:"url"`
}

Methods

  • Validate() error - Validates all fields

Validation Rules

  • Kind must be valid
  • Name cannot be empty
  • URL must be a valid HTTP/HTTPS URL with scheme and host

WebhookCreated

Response after creating a webhook.
type WebhookCreated struct {
    ID   string      `json:"id"`
    Kind WebhookKind `json:"kind"`
    Name string      `json:"name"`
    URL  string      `json:"url"`
}
id
string
required
The created webhook’s ID
kind
WebhookKind
required
Webhook type
name
string
required
Webhook name
url
string
required
Webhook URL

WebhookUpdate

Request to update an existing webhook.
type WebhookUpdate struct {
    Name *string      `json:"name,omitempty"`
    Kind *WebhookKind `json:"kind,omitempty"`
    URL  *string      `json:"url,omitempty"`
}

Methods

  • Validate() error - Validates update fields

Validation Rules

  • At least one field must be provided
  • If provided, name cannot be empty
  • If provided, URL must be valid
  • If provided, kind must be valid

WebhookUpdated

Response after updating a webhook.
type WebhookUpdated struct {
    ID        string      `json:"id"`
    Kind      WebhookKind `json:"kind"`
    Name      string      `json:"name"`
    URL       string      `json:"url"`
    UpdatedAt time.Time   `json:"updated_at"`
}
id
string
required
Webhook ID
kind
WebhookKind
required
Updated webhook kind
name
string
required
Updated webhook name
url
string
required
Updated webhook URL
updated_at
time.Time
required
When the webhook was updated

WebhookList

Request to list webhooks.
type WebhookList struct {
    PageArgs
}
Uses standard pagination parameters. See Pagination Types for details.

Example Usage

Create a Slack Webhook

webhook := types.WebhookCreate{
    Kind: types.WebhookKindSlack,
    Name: "Security Alerts",
    URL:  "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXX",
}

if err := webhook.Validate(); err != nil {
    // Handle validation error
}

// Create webhook via API client
// created, err := client.Webhooks.Create(ctx, webhook)

Update a Webhook

newName := "Critical Security Alerts"
update := types.WebhookUpdate{
    Name: &newName,
}

if err := update.Validate(); err != nil {
    // Handle validation error
}

// Update webhook via API client
// updated, err := client.Webhooks.Update(ctx, webhookID, update)

List Webhooks

perPage := 20
page := 1
listReq := types.WebhookList{
    PageArgs: types.PageArgs{
        Page:    &page,
        PerPage: &perPage,
    },
}

// List webhooks via API client
// webhooks, err := client.Webhooks.List(ctx, listReq)

Webhook Triggers

Webhooks are triggered for security events based on project settings. See Project Setting Types for configuring which issue classes trigger webhooks. By default, all issue classes trigger webhook notifications:
  • Network exfiltration attempts
  • Crypto miner detections
  • Network anomalies

Error Constants

const (
    ErrWebhookNotFound           = errs.NotFoundError("webhook not found")
    ErrUnauthorizedWebhookAccess = errs.UnauthorizedError("permission denied for webhook access")
    ErrWebHookInvalidKind        = errs.InvalidArgumentError("invalid webhook kind")
)

Build docs developers (and LLMs) love