Appearance
@gethook/php — SDK Reference
About 1117 wordsAbout 4 min
Installation
composer require gethook/gethook-phpSetup
<?php
require_once 'vendor/autoload.php';
$config = Gethook\Configuration::getDefaultConfiguration()
->setHost('https://api.gethook.to')
->setApiKey('ApiKeyAuth', 'hk_your_api_key');
$client = new GuzzleHttp\Client();Error handling
use Gethook\ApiException;
try {
$sources = (new Gethook\Api\SourcesApi($client, $config))->listSources();
} catch (ApiException $e) {
echo "Error " . $e->getCode() . ": " . $e->getResponseBody();
}Health
(new Gethook\Api\HealthApi($client, $config))->healthz()
Liveness check.
Returns: object
$result = (new Gethook\Api\HealthApi($client, $config))->healthz()(new Gethook\Api\HealthApi($client, $config))->readyz()
Readiness check.
Returns: object
$result = (new Gethook\Api\HealthApi($client, $config))->readyz()Accounts
(new Gethook\Api\AccountsApi($client, $config))->createAccount($body)
Create account.
Creates a new account and returns a bootstrap API key. No authentication required.
Parameters:
bodyCreateAccountRequest— Request body
Returns: AccountBootstrapData
$body = new Gethook\Model\CreateAccountRequest([
'name' => "My Company",
]);
$result = (new Gethook\Api\AccountsApi($client, $config))->createAccount($body)Auth
(new Gethook\Api\AuthApi($client, $config))->login($body)
Login with email and password.
Authenticates with email/password and returns a fresh API key on success.
Parameters:
bodyLoginRequest— Request body
Returns: AccountBootstrapData
$body = new Gethook\Model\LoginRequest([
'email' => "admin@example.com",
'password' => "supersecret",
]);
$result = (new Gethook\Api\AuthApi($client, $config))->login($body)(new Gethook\Api\AuthApi($client, $config))->register($body)
Register with email and password.
Creates a new account with email/password credentials and returns a bootstrap API key.
Parameters:
bodyRegisterRequest— Request body
Returns: AccountBootstrapData
$body = new Gethook\Model\RegisterRequest([
'email' => "admin@example.com",
'name' => "My Company",
'password' => "supersecret",
]);
$result = (new Gethook\Api\AuthApi($client, $config))->register($body)API Keys
(new Gethook\Api\ApiKeysApi($client, $config))->listApiKeys()
List API keys.
Returns: APIKey[]
$result = (new Gethook\Api\ApiKeysApi($client, $config))->listApiKeys()(new Gethook\Api\ApiKeysApi($client, $config))->createApiKey($body)
Create API key.
Creates a new API key for the authenticated account. The full key is only returned once.
Parameters:
bodyCreateAPIKeyRequest— Request body
Returns: APIKeyWithSecret
$body = new Gethook\Model\CreateAPIKeyRequest([
'name' => "production",
]);
$result = (new Gethook\Api\ApiKeysApi($client, $config))->createApiKey($body)(new Gethook\Api\ApiKeysApi($client, $config))->deleteApiKey("<id>")
Revoke API key.
Parameters:
id— API key UUID
Returns: void
(new Gethook\Api\ApiKeysApi($client, $config))->deleteApiKey("<id>")Sources
(new Gethook\Api\SourcesApi($client, $config))->listSources()
List sources.
Returns: Source[]
$result = (new Gethook\Api\SourcesApi($client, $config))->listSources()(new Gethook\Api\SourcesApi($client, $config))->createSource($body)
Create source.
Creates a new webhook source endpoint. Returns an ingest_url to share with the event sender.
Parameters:
bodyCreateSourceRequest— Request body
Returns: Source
$body = new Gethook\Model\CreateSourceRequest([
'name' => "Stripe webhooks",
]);
$result = (new Gethook\Api\SourcesApi($client, $config))->createSource($body)(new Gethook\Api\SourcesApi($client, $config))->getSource("<id>")
Get source.
Parameters:
id— Source UUID
Returns: Source
$result = (new Gethook\Api\SourcesApi($client, $config))->getSource("<id>")Destinations
(new Gethook\Api\DestinationsApi($client, $config))->listDestinations()
List destinations.
Returns: Destination[]
$result = (new Gethook\Api\DestinationsApi($client, $config))->listDestinations()(new Gethook\Api\DestinationsApi($client, $config))->createDestination($body)
Create destination.
Creates a new webhook delivery destination. The signing_secret is encrypted at rest and never returned.
Parameters:
bodyCreateDestinationRequest— Request body
Returns: Destination
$body = new Gethook\Model\CreateDestinationRequest([
'name' => "My endpoint",
'url' => "https://example.com/webhooks",
]);
$result = (new Gethook\Api\DestinationsApi($client, $config))->createDestination($body)(new Gethook\Api\DestinationsApi($client, $config))->getDestination("<id>")
Get destination.
Parameters:
id— Destination UUID
Returns: Destination
$result = (new Gethook\Api\DestinationsApi($client, $config))->getDestination("<id>")(new Gethook\Api\DestinationsApi($client, $config))->updateDestination("<id>", $body)
Update destination.
Parameters:
id— Destination UUIDbodyUpdateDestinationRequest— Request body
Returns: Destination
$body = new Gethook\Model\UpdateDestinationRequest([
'active' => true,
'auth_config' => "...",
'custom_headers' => "...",
]);
$result = (new Gethook\Api\DestinationsApi($client, $config))->updateDestination("<id>", $body)Routes
(new Gethook\Api\RoutesApi($client, $config))->listRoutes()
List routes.
Returns: Route[]
$result = (new Gethook\Api\RoutesApi($client, $config))->listRoutes()(new Gethook\Api\RoutesApi($client, $config))->createRoute($body)
Create route.
Creates a routing rule that forwards matching events from a source to a destination.
Parameters:
bodyCreateRouteRequest— Request body
Returns: Route
$body = new Gethook\Model\CreateRouteRequest([
'destination_id' => "uuid",
]);
$result = (new Gethook\Api\RoutesApi($client, $config))->createRoute($body)Stats
(new Gethook\Api\StatsApi($client, $config))->getStats()
Get dashboard stats.
Returns: StatsData
$result = (new Gethook\Api\StatsApi($client, $config))->getStats()Ingest
(new Gethook\Api\IngestApi($client, $config))->ingest()
Ingest webhook event.
Accepts an inbound webhook. The path token authenticates the source — no Bearer header required.
Returns: void
(new Gethook\Api\IngestApi($client, $config))->ingest()Events (Inbound)
(new Gethook\Api\EventsApi($client, $config))->listEvents(limit: ..., offset: ...)
List inbound events.
Parameters:
limitinteger— Max results (default 25, max 200) (optional)offsetinteger— Pagination offset (optional)
Returns: EventListData
$result = (new Gethook\Api\EventsApi($client, $config))->listEvents(limit: ..., offset: ...)(new Gethook\Api\EventsApi($client, $config))->getEvent("<id>")
Get inbound event.
Parameters:
id— Event UUID
Returns: EventDetailData
$result = (new Gethook\Api\EventsApi($client, $config))->getEvent("<id>")(new Gethook\Api\EventsApi($client, $config))->replayEvent("<id>")
Replay inbound event.
Creates a new queued copy of the event for re-delivery.
Parameters:
id— Event UUID
Returns: void
(new Gethook\Api\EventsApi($client, $config))->replayEvent("<id>")Events (Outbound)
(new Gethook\Api\OutboundEventsApi($client, $config))->listOutboundEvents(limit: ..., offset: ...)
List outbound events.
Parameters:
limitinteger— Max results (default 25, max 200) (optional)offsetinteger— Pagination offset (optional)
Returns: EventListData
$result = (new Gethook\Api\OutboundEventsApi($client, $config))->listOutboundEvents(limit: ..., offset: ...)(new Gethook\Api\OutboundEventsApi($client, $config))->publishOutboundEvent($body)
Publish outbound event.
Queues a new outbound event for delivery to all matching route destinations.
Parameters:
bodyPublishOutboundEventRequest— Request body
Returns: PublishOutboundData
$body = new Gethook\Model\PublishOutboundEventRequest([
'payload' => "{"order_id":"123"}",
]);
$result = (new Gethook\Api\OutboundEventsApi($client, $config))->publishOutboundEvent($body)(new Gethook\Api\OutboundEventsApi($client, $config))->getOutboundEvent("<id>")
Get outbound event.
Parameters:
id— Event UUID
Returns: EventDetailData
$result = (new Gethook\Api\OutboundEventsApi($client, $config))->getOutboundEvent("<id>")(new Gethook\Api\OutboundEventsApi($client, $config))->replayOutboundEvent("<id>")
Replay outbound event.
Parameters:
id— Event UUID
Returns: void
(new Gethook\Api\OutboundEventsApi($client, $config))->replayOutboundEvent("<id>")Brand & White-Labeling
(new Gethook\Api\BrandApi($client, $config))->getBrandSettings()
Get brand settings.
Returns: BrandSettings
$result = (new Gethook\Api\BrandApi($client, $config))->getBrandSettings()(new Gethook\Api\BrandApi($client, $config))->upsertBrandSettings($body)
Upsert brand settings.
Creates or replaces white-label brand settings for the account.
Parameters:
bodyUpsertBrandSettingsRequest— Request body
Returns: BrandSettings
$body = new Gethook\Model\UpsertBrandSettingsRequest([
'company_name' => "Acme Corp",
'docs_title' => "Acme Webhooks",
'logo_url' => "https://example.com/logo.png",
]);
$result = (new Gethook\Api\BrandApi($client, $config))->upsertBrandSettings($body)Custom Domains
(new Gethook\Api\CustomDomainsApi($client, $config))->listCustomDomains()
List custom domains.
Returns: CustomDomain[]
$result = (new Gethook\Api\CustomDomainsApi($client, $config))->listCustomDomains()(new Gethook\Api\CustomDomainsApi($client, $config))->createCustomDomain($body)
Create custom domain.
Parameters:
bodyCreateCustomDomainRequest— Request body
Returns: CustomDomain
$body = new Gethook\Model\CreateCustomDomainRequest([
'domain' => "webhooks.example.com",
]);
$result = (new Gethook\Api\CustomDomainsApi($client, $config))->createCustomDomain($body)