Claude Platform Docs

Unwrap

client.Beta.Webhooks.Unwrap(payload, headers) (*UnwrapWebhookEvent, error)
Function

Verifies the webhook signature from the webhook-id, webhook-timestamp and webhook-signature headers using your webhook signing key, then parses the payload into an event. Fails if the signature is missing or invalid.

Parameters
payload []byte

The body of the incoming webhook request, exactly as received: the signature is computed over these bytes.

headers http.Header

The HTTP headers of the incoming webhook request. Verification reads webhook-id, webhook-timestamp and webhook-signature.

Returns
type UnwrapWebhookEvent struct { Type: "event"; ID; CreatedAt; Data }
Type Event

Object type. Always event for webhook payloads.

ID string

Unique event identifier for idempotency.

CreatedAt Time

RFC 3339 timestamp when the event occurred.

formatdate-time
One of the following:
Unwrap
package main

import (
	"fmt"

	"github.com/anthropics/anthropic-sdk-go/v2"
	"github.com/anthropics/anthropic-sdk-go/v2/option"
)

func main() {
	client := anthropic.NewClient(
		option.WithAPIKey("my-anthropic-api-key"),
	)
	// payload is the raw body of the incoming webhook request and headers are its HTTP headers (an http.Header).
	event, err := client.Beta.Webhooks.Unwrap(payload, headers)
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", event)
}