Skip to main content
POST
/
v1
/
webhooks
/
endpoints
PHP (SDK)
declare(strict_types=1);

require 'vendor/autoload.php';

use Spaire;
use Spaire\Models\Components;

$sdk = Spaire\Spaire::builder()
    ->setSecurity(
        '<YOUR_BEARER_TOKEN_HERE>'
    )
    ->build();

$request = new Components\WebhookEndpointCreate(
    url: 'https://webhook.site/cb791d80-f26e-4f8c-be88-6e56054192b0',
    format: Components\WebhookFormat::Slack,
    events: [
        Components\WebhookEventType::SubscriptionUncanceled,
    ],
    organizationId: '1dbfc517-0bbf-4301-9ba8-555ca42b9737',
);

$response = $sdk->webhooks->createWebhookEndpoint(
    request: $request
);

if ($response->webhookEndpoint !== null) {
    // handle response
}
{
  "created_at": "2023-11-07T05:31:56Z",
  "modified_at": "2023-11-07T05:31:56Z",
  "id": "<string>",
  "url": "<string>",
  "secret": "<string>",
  "organization_id": "<string>",
  "events": [],
  "enabled": true,
  "name": "<string>"
}

Documentation Index

Fetch the complete documentation index at: https://docs.spairehq.com/llms.txt

Use this file to discover all available pages before exploring further.

Authorizations

Authorization
string
header
required

You can generate an Organization Access Token from your organization's settings.

Body

application/json

Schema to create a webhook endpoint.

url
string<uri>
required

The URL where the webhook events will be sent.

Required string length: 1 - 2083
Example:

"https://webhook.site/cb791d80-f26e-4f8c-be88-6e56054192b0"

format
enum<string>
required

The format of the webhook payload.

Available options:
raw,
discord,
slack
events
enum<string>[]
required

The events that will trigger the webhook.

Available options:
checkout.created,
checkout.updated,
checkout.expired,
customer.created,
customer.updated,
customer.deleted,
customer.state_changed,
customer_seat.assigned,
customer_seat.claimed,
customer_seat.revoked,
member.created,
member.updated,
member.deleted,
order.created,
order.updated,
order.paid,
order.refunded,
subscription.created,
subscription.updated,
subscription.active,
subscription.canceled,
subscription.uncanceled,
subscription.revoked,
subscription.past_due,
refund.created,
refund.updated,
product.created,
product.updated,
benefit.created,
benefit.updated,
benefit_grant.created,
benefit_grant.cycled,
benefit_grant.updated,
benefit_grant.revoked,
organization.updated
name
string | null

An optional name for the webhook endpoint to help organize and identify it.

organization_id
string<uuid4> | null

The organization ID.

Example:

"1dbfc517-0bbf-4301-9ba8-555ca42b9737"

Response

Webhook endpoint created.

A webhook endpoint.

created_at
string<date-time>
required

Creation timestamp of the object.

modified_at
string<date-time> | null
required

Last modification timestamp of the object.

id
string<uuid4>
required

The ID of the object.

url
string<uri>
required

The URL where the webhook events will be sent.

Required string length: 1 - 2083
Example:

"https://webhook.site/cb791d80-f26e-4f8c-be88-6e56054192b0"

format
enum<string>
required

The format of the webhook payload.

Available options:
raw,
discord,
slack
secret
string
required

The secret used to sign the webhook events.

Example:

"spaire_whs_ovyN6cPrTv56AApvzCaJno08SSmGJmgbWilb33N2JuK"

organization_id
string<uuid4>
required

The organization ID associated with the webhook endpoint.

events
enum<string>[]
required

The events that will trigger the webhook.

Available options:
checkout.created,
checkout.updated,
checkout.expired,
customer.created,
customer.updated,
customer.deleted,
customer.state_changed,
customer_seat.assigned,
customer_seat.claimed,
customer_seat.revoked,
member.created,
member.updated,
member.deleted,
order.created,
order.updated,
order.paid,
order.refunded,
subscription.created,
subscription.updated,
subscription.active,
subscription.canceled,
subscription.uncanceled,
subscription.revoked,
subscription.past_due,
refund.created,
refund.updated,
product.created,
product.updated,
benefit.created,
benefit.updated,
benefit_grant.created,
benefit_grant.cycled,
benefit_grant.updated,
benefit_grant.revoked,
organization.updated
enabled
boolean
required

Whether the webhook endpoint is enabled and will receive events.

name
string | null

An optional name for the webhook endpoint to help organize and identify it.