Claude Platform Docs

Unwrap

$client->beta->webhooks->unwrap(string body, array<string,string | list<string>> headers, ?string secret): BetaWebhookEvent
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
body: string

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

headers: array<string,string | list<string>>

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

secret: optional string

The webhook signing key. Defaults to the client's webhookKey option.

Returns
class BetaWebhookEvent { $type = 'event'; $id; $createdAt; $data; }
"event" type

Object type. Always event for webhook payloads.

string id

Unique event identifier for idempotency.

\Datetime createdAt

RFC 3339 timestamp when the event occurred.

Unwrap
<?php

require_once dirname(__DIR__) . '/vendor/autoload.php';

use Anthropic\Client;

$client = new Client(apiKey: 'my-anthropic-api-key');

// $body is the raw body of the incoming webhook request and $headers are its HTTP headers.
$event = $client->beta->webhooks->unwrap($body, $headers);

var_dump($event);