Skip to content
This repository was archived by the owner on Nov 30, 2026. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,23 @@ op read "op://vault/stripe/api-key" | cloud secret:create --name=STRIPE_KEY -n
| `cloud domain:delete` | Delete a domain |
| `cloud domain:verify` | Verify domain DNS |

### Webhooks

| Command | Description |
| -------------------------------------- | ------------------------------------------------- |
| `cloud webhook-endpoint:list` | List an environment's webhook endpoints |
| `cloud webhook-endpoint:get` | Get webhook endpoint details |
| `cloud webhook-endpoint:create` | Create a webhook endpoint for deployment events |
| `cloud webhook-endpoint:update` | Update a webhook endpoint's URL, events, or state |
| `cloud webhook-endpoint:delete` | Delete a webhook endpoint |
| `cloud webhook-endpoint:test` | Send a `ping` and show the delivery |
| `cloud webhook-endpoint:deliveries` | List the last 50 deliveries |
| `cloud webhook-endpoint:rotate-secret` | Generate a new signing secret |

Cloud sends a signed `POST` to the endpoint for each deployment event it subscribes to: `deployment.live`, `deployment.succeeded`, `deployment.failed`, and `deployment.post_deploy_failed`. Pass `--events` once per event or as a comma-separated list. An environment can have up to five endpoints.

The signing secret is returned only by `webhook-endpoint:create` and `webhook-endpoint:rotate-secret`. Both show it to a person; JSON output masks it unless you pass `--show-sensitive`. Rotating stops the old secret working immediately, so it asks for confirmation (or `--force`). `webhook-endpoint:test` exits non-zero when the ping fails or is blocked. Endpoints can be given by ID or by URL.

### Email (Resend)

| Command | Description |
Expand Down
6 changes: 6 additions & 0 deletions app/Client/Connector.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
use App\Client\Resources\ScheduledCommandsResource;
use App\Client\Resources\SecretsResource;
use App\Client\Resources\UsageResource;
use App\Client\Resources\WebhookEndpointsResource;
use App\Client\Resources\WebSocketApplicationsResource;
use App\Client\Resources\WebSocketClustersResource;
use App\Cloud;
Expand Down Expand Up @@ -272,6 +273,11 @@ public function usage(): UsageResource
return new UsageResource($this);
}

public function webhookEndpoints(): WebhookEndpointsResource
{
return new WebhookEndpointsResource($this);
}

public function cliAuth(): CliAuthResource
{
return new CliAuthResource(self::unauthenticated());
Expand Down
10 changes: 10 additions & 0 deletions app/Client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,16 @@ $data = $response->json();
- `UpdateWebSocketApplicationRequest` - Update an application
- `DeleteWebSocketApplicationRequest` - Delete an application

#### Webhook Endpoints
- `ListWebhookEndpointsRequest` - List webhook endpoints for an environment
- `GetWebhookEndpointRequest` - Get a specific webhook endpoint
- `CreateWebhookEndpointRequest` - Create a webhook endpoint (the response holds its only copy of the signing secret)
- `UpdateWebhookEndpointRequest` - Update a webhook endpoint's URL, events, or enabled state
- `DeleteWebhookEndpointRequest` - Delete a webhook endpoint
- `TestWebhookEndpointRequest` - Send a `ping` event and return the delivery
- `ListWebhookDeliveriesRequest` - List the last 50 deliveries to a webhook endpoint
- `RotateWebhookEndpointSecretRequest` - Generate a new signing secret (the old one stops working immediately)

#### Meta
- `GetOrganizationRequest` - Get the authenticated organization
- `ListRegionsRequest` - List available regions
Expand Down
27 changes: 27 additions & 0 deletions app/Client/Requests/CreateWebhookEndpointRequestData.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace App\Client\Requests;

class CreateWebhookEndpointRequestData extends RequestData
{
/**
* @param list<string> $events
*/
public function __construct(
public readonly string $environmentId,
public readonly string $url,
public readonly array $events,
public readonly ?bool $enabled = null,
) {
//
}

public function toRequestData(): array
{
return $this->filter([
'url' => $this->url,
'events' => $this->events,
'enabled' => $this->enabled,
]);
}
}
27 changes: 27 additions & 0 deletions app/Client/Requests/UpdateWebhookEndpointRequestData.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace App\Client\Requests;

class UpdateWebhookEndpointRequestData extends RequestData
{
/**
* @param list<string>|null $events
*/
public function __construct(
public readonly string $webhookEndpointId,
public readonly ?string $url = null,
public readonly ?array $events = null,
public readonly ?bool $enabled = null,
) {
//
}

public function toRequestData(): array
{
return $this->filter([
'url' => $this->url,
'events' => $this->events,
'enabled' => $this->enabled,
]);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace App\Client\Resources\WebhookEndpoints;

use App\Client\Requests\CreateWebhookEndpointRequestData;
use App\Dto\WebhookEndpoint;
use Saloon\Contracts\Body\HasBody;
use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;
use Saloon\Traits\Body\HasJsonBody;

class CreateWebhookEndpointRequest extends Request implements HasBody
{
use HasJsonBody;

protected Method $method = Method::POST;

public function __construct(
protected CreateWebhookEndpointRequestData $data,
) {
//
}

public function resolveEndpoint(): string
{
return "/environments/{$this->data->environmentId}/webhook-endpoints";
}

protected function defaultBody(): array
{
return $this->data->toRequestData();
}

public function createDtoFromResponse(Response $response): mixed
{
return WebhookEndpoint::createFromResponse($response->json());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace App\Client\Resources\WebhookEndpoints;

use Saloon\Enums\Method;
use Saloon\Http\Request;

class DeleteWebhookEndpointRequest extends Request
{
protected Method $method = Method::DELETE;

public function __construct(
protected string $webhookEndpointId,
) {
//
}

public function resolveEndpoint(): string
{
return "/webhook-endpoints/{$this->webhookEndpointId}";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace App\Client\Resources\WebhookEndpoints;

use App\Client\Resources\Concerns\AcceptsInclude;
use App\Dto\WebhookEndpoint;
use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;

class GetWebhookEndpointRequest extends Request
{
use AcceptsInclude;

protected Method $method = Method::GET;

public function __construct(
protected string $webhookEndpointId,
) {
//
}

public function resolveEndpoint(): string
{
return "/webhook-endpoints/{$this->webhookEndpointId}";
}

public function createDtoFromResponse(Response $response): mixed
{
return WebhookEndpoint::createFromResponse($response->json());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace App\Client\Resources\WebhookEndpoints;

use App\Dto\WebhookDelivery;
use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;
use Saloon\PaginationPlugin\Contracts\Paginatable;

class ListWebhookDeliveriesRequest extends Request implements Paginatable
{
protected Method $method = Method::GET;

public function __construct(
protected string $webhookEndpointId,
) {
//
}

public function resolveEndpoint(): string
{
return "/webhook-endpoints/{$this->webhookEndpointId}/deliveries";
}

public function createDtoFromResponse(Response $response): mixed
{
return array_map(
fn ($delivery) => WebhookDelivery::createFromResponse(['data' => $delivery]),
$response->json('data'),
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

namespace App\Client\Resources\WebhookEndpoints;

use App\Client\Resources\Concerns\AcceptsInclude;
use App\Dto\WebhookEndpoint;
use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;
use Saloon\PaginationPlugin\Contracts\Paginatable;

class ListWebhookEndpointsRequest extends Request implements Paginatable
{
use AcceptsInclude;

protected Method $method = Method::GET;

public function __construct(
protected string $environmentId,
) {
//
}

public function resolveEndpoint(): string
{
return "/environments/{$this->environmentId}/webhook-endpoints";
}

public function createDtoFromResponse(Response $response): mixed
{
return array_map(fn ($endpoint) => WebhookEndpoint::createFromResponse([
'data' => $endpoint,
'included' => $response->json('included', []),
]), $response->json('data'));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace App\Client\Resources\WebhookEndpoints;

use App\Dto\WebhookEndpoint;
use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;

class RotateWebhookEndpointSecretRequest extends Request
{
protected Method $method = Method::POST;

public function __construct(
protected string $webhookEndpointId,
) {
//
}

public function resolveEndpoint(): string
{
return "/webhook-endpoints/{$this->webhookEndpointId}/secret";
}

public function createDtoFromResponse(Response $response): mixed
{
return WebhookEndpoint::createFromResponse($response->json());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace App\Client\Resources\WebhookEndpoints;

use App\Dto\WebhookDelivery;
use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;

class TestWebhookEndpointRequest extends Request
{
protected Method $method = Method::POST;

public function __construct(
protected string $webhookEndpointId,
) {
//
}

public function resolveEndpoint(): string
{
return "/webhook-endpoints/{$this->webhookEndpointId}/test";
}

public function createDtoFromResponse(Response $response): mixed
{
return WebhookDelivery::createFromResponse($response->json());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace App\Client\Resources\WebhookEndpoints;

use App\Client\Requests\UpdateWebhookEndpointRequestData;
use App\Dto\WebhookEndpoint;
use Saloon\Contracts\Body\HasBody;
use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;
use Saloon\Traits\Body\HasJsonBody;

class UpdateWebhookEndpointRequest extends Request implements HasBody
{
use HasJsonBody;

protected Method $method = Method::PATCH;

public function __construct(
protected UpdateWebhookEndpointRequestData $data,
) {
//
}

public function resolveEndpoint(): string
{
return "/webhook-endpoints/{$this->data->webhookEndpointId}";
}

protected function defaultBody(): array
{
return $this->data->toRequestData();
}

public function createDtoFromResponse(Response $response): mixed
{
return WebhookEndpoint::createFromResponse($response->json());
}
}
Loading