Overview
Thewebhooks sub-client lets you create, list, and delete webhook endpoints. When events occur (e.g. a grant is created or revoked), Grantex sends an HTTP POST to your registered URLs with a signed payload.
webhooks.create()
Create a new webhook endpoint. The response includes asecret for verifying payload signatures — store it securely, as it is only returned once.
Parameters
string
required
The HTTPS URL to receive webhook events.
WebhookEventType[]
required
The events to subscribe to.
Event types
Response: WebhookEndpointWithSecret
string
Unique webhook endpoint identifier.
string
The registered URL.
WebhookEventType[]
The subscribed event types.
string
The HMAC signing secret. Only returned on creation.
string
ISO 8601 creation timestamp.
webhooks.list()
List all webhook endpoints for your organization.Response: ListWebhooksResponse
WebhookEndpoint[]
Array of webhook endpoint objects (without secrets).
webhooks.delete()
Delete a webhook endpoint.Parameters
string
required
The webhook endpoint ID to delete.
Response
Returnsvoid.
Verifying webhook signatures
The SDK exports averifyWebhookSignature() function to verify that incoming webhook payloads were sent by Grantex. The function uses HMAC-SHA256 with timing-safe comparison.
Import
Usage
Parameters
string | Buffer
required
The raw request body as received from Grantex.
string
required
The value of the
X-Grantex-Signature header.string
required
The webhook secret returned when the endpoint was created.
Response
Returnstrue if the signature is valid, false otherwise.