Skip to main content

PHP SDK

PHP 8.1+ with curl and json.

Initialize + verify

HTTP under the hood:

Verify response (JSON)

$keverd->verify() returns an associative array matching POST /v2/verify:

Laravel

Browser → your route (JSON):

Webhooks

Inbound JSON matches the webhook envelope. Verify signature on the raw body.
You can also call Keverd\Webhooks::constructEvent(...).

Errors

All SDK failures extend Keverd\KeverdError. Catch the specific subclass when you need different handling.

Keverd\KeverdError

Base exception for client-side failures before a successful API response, or when the request never completes. Thrown when
  • Missing config (e.g. no secretKey)
  • Invalid arguments (e.g. empty eventId)
  • Network failures
  • Request timeouts

Keverd\KeverdApiError

Thrown when the API returns a non-2xx HTTP status. Extends KeverdError. Thrown when
  • Auth fails (401 / 403)
  • Bad request (400)
  • Quota exceeded (402)
  • Server errors (5xx)
Inspect the status code and response body on the exception to decide whether to retry or surface an error.

Keverd\KeverdSignatureError

Thrown by $keverd->webhooks->constructEvent(...) when webhook signature verification fails. Extends KeverdError. Thrown when
  • Missing X-Keverd-Signature or webhook secret
  • Malformed signature header
  • Timestamp outside the 300s tolerance
  • HMAC mismatch (wrong secret, or body was parsed/modified before verify)
  • Payload is not valid JSON
Treat these as untrusted requests — return 400 and do not process the event. See Webhooks.