Skip to content
Start here

Create a new webhook configuration

client.ZeroTrust.Casb.Posture.Webhooks.New(ctx, params) (*CasbPostureWebhookNewResponse, error)
POST/accounts/{account_id}/data-security/posture/webhooks

Creates a new webhook configuration for sending finding notifications to external endpoints.

Security

API Token

The preferred authorization scheme for interacting with the Cloudflare API. Create a token.

Example:Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY
Accepted Permissions (at least one required)
Zero Trust Write
ParametersExpand Collapse
params CasbPostureWebhookNewParams
AccountID param.Field[string]

Path param: Cloudflare account ID for the user making the request.

AuthenticationType param.Field[CasbPostureWebhookNewParamsAuthenticationType]

Body param: Type of authentication used for the webhook.

const CasbPostureWebhookNewParamsAuthenticationTypeBasicAuth CasbPostureWebhookNewParamsAuthenticationType = "Basic Auth"
const CasbPostureWebhookNewParamsAuthenticationTypeNone CasbPostureWebhookNewParamsAuthenticationType = "None"
const CasbPostureWebhookNewParamsAuthenticationTypeBearerAuth CasbPostureWebhookNewParamsAuthenticationType = "Bearer Auth"
const CasbPostureWebhookNewParamsAuthenticationTypeStaticHeaders CasbPostureWebhookNewParamsAuthenticationType = "Static Headers"
const CasbPostureWebhookNewParamsAuthenticationTypeHmacSigning CasbPostureWebhookNewParamsAuthenticationType = "HMAC-Signing"
DestinationURL param.Field[string]

Body param: Target URL for the webhook configuration. Where resulting data will be sent.

formaturi
Label param.Field[string]

Body param: Account-specified display label for the webhook configuration.

Headers param.Field[[]CasbPostureWebhookNewParamsHeader]Optional

Body param: List of custom headers to include in webhook requests.

Key string

Header key name.

maxLength255
Value stringOptional

Header value. Required on Create and Evaluate. On Update, omit or set to null to keep existing value.

maxLength4096
SigningSecret param.Field[string]Optional

Body param: Secret key used for HMAC signing when authentication_type is “HMAC-Signing”.

ReturnsExpand Collapse
type CasbPostureWebhookNewResponse struct{…}

Webhook configuration for sending finding notifications.

ID string

Unique identifier for the specific webhook configuration.

formatuuid
AuthenticationType CasbPostureWebhookNewResponseAuthenticationType

Type of authentication used for the webhook.

One of the following:
const CasbPostureWebhookNewResponseAuthenticationTypeBasicAuth CasbPostureWebhookNewResponseAuthenticationType = "Basic Auth"
const CasbPostureWebhookNewResponseAuthenticationTypeNone CasbPostureWebhookNewResponseAuthenticationType = "None"
const CasbPostureWebhookNewResponseAuthenticationTypeBearerAuth CasbPostureWebhookNewResponseAuthenticationType = "Bearer Auth"
const CasbPostureWebhookNewResponseAuthenticationTypeStaticHeaders CasbPostureWebhookNewResponseAuthenticationType = "Static Headers"
const CasbPostureWebhookNewResponseAuthenticationTypeHmacSigning CasbPostureWebhookNewResponseAuthenticationType = "HMAC-Signing"
CreatedAt Time

Timestamp when the webhook configuration was created.

formatdate-time
DestinationURL string

Target URL for the webhook configuration. Where resulting data will be sent.

formaturi
Label string

Account-specified display label for the webhook configuration.

Status CasbPostureWebhookNewResponseStatus

Current status of the webhook configuration. If disabled, data cannot be sent through this configuration.

One of the following:
const CasbPostureWebhookNewResponseStatusEnabled CasbPostureWebhookNewResponseStatus = "enabled"
const CasbPostureWebhookNewResponseStatusDisabled CasbPostureWebhookNewResponseStatus = "disabled"
UpdatedAt Time

Timestamp when the webhook configuration was last updated.

formatdate-time
Version int64

Version number of the configuration.

formatuint32
Headers []CasbPostureWebhookNewResponseHeaderOptional

List of header keys configured for this webhook. Values are not included for security reasons.

Key stringOptional

Header key name (lowercase).

Value stringOptional

Header value. This field is never returned in API responses for security reasons.

Create a new webhook configuration

package main

import (
  "context"
  "fmt"

  "github.com/cloudflare/cloudflare-go"
  "github.com/cloudflare/cloudflare-go/option"
  "github.com/cloudflare/cloudflare-go/zero_trust"
)

func main() {
  client := cloudflare.NewClient(
    option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
  )
  webhook, err := client.ZeroTrust.Casb.Posture.Webhooks.New(context.TODO(), zero_trust.CasbPostureWebhookNewParams{
    AccountID: cloudflare.F("46148281d8a93d002ef242d8b0d5f9f6"),
    AuthenticationType: cloudflare.F(zero_trust.CasbPostureWebhookNewParamsAuthenticationTypeBearerAuth),
    DestinationURL: cloudflare.F("https://example.com/webhook"),
    Label: cloudflare.F("Send to Slack"),
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", webhook.ID)
}
{
  "errors": [
    {
      "code": 1000,
      "message": "Request processed successfully",
      "documentation_url": "https://developers.cloudflare.com/api/operations/list-findings",
      "source": {
        "pointer": "/data/attributes/name"
      }
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "Request processed successfully",
      "documentation_url": "https://developers.cloudflare.com/api/operations/list-findings",
      "source": {
        "pointer": "/data/attributes/name"
      }
    }
  ],
  "success": true,
  "result": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "authentication_type": "Bearer Auth",
    "created_at": "2024-01-15T10:30:00Z",
    "destination_url": "https://example.com/webhook",
    "label": "Send to Gmail",
    "status": "enabled",
    "updated_at": "2024-01-20T14:45:00Z",
    "version": 1,
    "headers": [
      {
        "key": "authorization"
      }
    ]
  }
}
Returns Examples
{
  "errors": [
    {
      "code": 1000,
      "message": "Request processed successfully",
      "documentation_url": "https://developers.cloudflare.com/api/operations/list-findings",
      "source": {
        "pointer": "/data/attributes/name"
      }
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "Request processed successfully",
      "documentation_url": "https://developers.cloudflare.com/api/operations/list-findings",
      "source": {
        "pointer": "/data/attributes/name"
      }
    }
  ],
  "success": true,
  "result": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "authentication_type": "Bearer Auth",
    "created_at": "2024-01-15T10:30:00Z",
    "destination_url": "https://example.com/webhook",
    "label": "Send to Gmail",
    "status": "enabled",
    "updated_at": "2024-01-20T14:45:00Z",
    "version": 1,
    "headers": [
      {
        "key": "authorization"
      }
    ]
  }
}