Webhooks

$envless->webhooks->getDelivery()

Read one delivery attempt with its response body

php
/** @return WebhookDeliveryDetailResource */
public function getDelivery(
    string $id,
    string $deliveryId,
    int|float|null $timeout = null,
): array

Returns one delivery attempt in full, including responseBody, which is what your receiver actually wrote back, truncated at 4000 characters. That field is the only thing this adds over the list rows, and it is normally what tells you why a receiver rejected the call.

Both ids must line up. A real delivery id passed under the wrong endpoint id is 404 webhook.delivery_not_found, not the delivery, so swapping the two arguments fails as a lookup rather than as validation.

error is populated for anything the worker treated as a failure, which includes a receiver that answered 3xx, since redirects are never followed, and one that took longer than the 10 second timeout. After 5 attempts the delivery is terminal and will not move again on its own.

Example

php
use Envless\Envless;

$envless = new Envless();

$delivery = $envless->webhooks->getDelivery(
    '0194f2b1-9c3a-7c21-8f0e-2b6d4a1c5e90',
    '0194f2c8-11ad-7a03-b6c2-9d70f4e8a112',
);

echo "{$delivery['attempts']} {$delivery['responseStatus']}", PHP_EOL;
echo $delivery['responseBody'], PHP_EOL;

Parameters

ParameterTypeRequiredDescription
$idstringYesEndpoint id that owns the delivery.
$deliveryIdstringYesDelivery id from a list call or from the Envless-Delivery header your receiver saw.
$timeoutint|floatNoSeconds each attempt of this call may take, the response body included, before it throws Envless\Exception\NetworkException with isTimeout() true. Overrides the client's timeout for this call, and 0 turns the limit off.

Returns

WebhookDeliveryDetailResource, the list row plus responseBody.

Worth knowing

  • The first argument is the endpoint id and the second is the delivery id.
  • responseBody is null when the attempt never got a response at all, such as a timeout or a DNS failure.

Required scopes

webhooks:read

Underlying endpoint

GET /webhooks/{id}/deliveries/{deliveryId}

Request and response schema, every error code, and a live playground.

In TypeScript

envless.webhooks.getDelivery()

The same method in @goenvless/sdk, with the same request, retries and errors.