IWebhookSubscriptionsApi webhookSubscriptionsApi = client.WebhookSubscriptionsApi;
WebhookSubscriptionsApi
- List Webhook Event Types
- List Webhook Subscriptions
- Create Webhook Subscription
- Delete Webhook Subscription
- Retrieve Webhook Subscription
- Update Webhook Subscription
- Update Webhook Subscription Signature Key
- Test Webhook Subscription
Lists all webhook event types that can be subscribed to.
ListWebhookEventTypesAsync(
string apiVersion = null)
Parameter | Type | Tags | Description |
---|---|---|---|
apiVersion |
string |
Query, Optional | The API version for which to list event types. Setting this field overrides the default version used by the application. |
Task<Models.ListWebhookEventTypesResponse>
try
{
ListWebhookEventTypesResponse result = await webhookSubscriptionsApi.ListWebhookEventTypesAsync();
}
catch (ApiException e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
Lists all webhook subscriptions owned by your application.
ListWebhookSubscriptionsAsync(
string cursor = null,
bool? includeDisabled = false,
string sortOrder = null,
int? limit = null)
Parameter | Type | Tags | Description |
---|---|---|---|
cursor |
string |
Query, Optional | A pagination cursor returned by a previous call to this endpoint. Provide this to retrieve the next set of results for your original query. For more information, see Pagination. |
includeDisabled |
bool? |
Query, Optional | Includes disabled Subscriptions. By default, all enabled Subscriptions are returned. Default: false |
sortOrder |
string |
Query, Optional | Sorts the returned list by when the Subscription was created with the specified order. This field defaults to ASC. |
limit |
int? |
Query, Optional | The maximum number of results to be returned in a single page. It is possible to receive fewer results than the specified limit on a given page. The default value of 100 is also the maximum allowed value. Default: 100 |
Task<Models.ListWebhookSubscriptionsResponse>
bool? includeDisabled = false;
try
{
ListWebhookSubscriptionsResponse result = await webhookSubscriptionsApi.ListWebhookSubscriptionsAsync(
null,
includeDisabled
);
}
catch (ApiException e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
Creates a webhook subscription.
CreateWebhookSubscriptionAsync(
Models.CreateWebhookSubscriptionRequest body)
Parameter | Type | Tags | Description |
---|---|---|---|
body |
CreateWebhookSubscriptionRequest |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
Task<Models.CreateWebhookSubscriptionResponse>
CreateWebhookSubscriptionRequest body = new CreateWebhookSubscriptionRequest.Builder(
new WebhookSubscription.Builder()
.Name("Example Webhook Subscription")
.EventTypes(
new List<string>
{
"payment.created",
"payment.updated",
})
.NotificationUrl("https://example-webhook-url.com")
.ApiVersion("2021-12-15")
.Build()
)
.IdempotencyKey("63f84c6c-2200-4c99-846c-2670a1311fbf")
.Build();
try
{
CreateWebhookSubscriptionResponse result = await webhookSubscriptionsApi.CreateWebhookSubscriptionAsync(body);
}
catch (ApiException e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
Deletes a webhook subscription.
DeleteWebhookSubscriptionAsync(
string subscriptionId)
Parameter | Type | Tags | Description |
---|---|---|---|
subscriptionId |
string |
Template, Required | [REQUIRED] The ID of the Subscription to delete. |
Task<Models.DeleteWebhookSubscriptionResponse>
string subscriptionId = "subscription_id0";
try
{
DeleteWebhookSubscriptionResponse result = await webhookSubscriptionsApi.DeleteWebhookSubscriptionAsync(subscriptionId);
}
catch (ApiException e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
Retrieves a webhook subscription identified by its ID.
RetrieveWebhookSubscriptionAsync(
string subscriptionId)
Parameter | Type | Tags | Description |
---|---|---|---|
subscriptionId |
string |
Template, Required | [REQUIRED] The ID of the Subscription to retrieve. |
Task<Models.RetrieveWebhookSubscriptionResponse>
string subscriptionId = "subscription_id0";
try
{
RetrieveWebhookSubscriptionResponse result = await webhookSubscriptionsApi.RetrieveWebhookSubscriptionAsync(subscriptionId);
}
catch (ApiException e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
Updates a webhook subscription.
UpdateWebhookSubscriptionAsync(
string subscriptionId,
Models.UpdateWebhookSubscriptionRequest body)
Parameter | Type | Tags | Description |
---|---|---|---|
subscriptionId |
string |
Template, Required | [REQUIRED] The ID of the Subscription to update. |
body |
UpdateWebhookSubscriptionRequest |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
Task<Models.UpdateWebhookSubscriptionResponse>
string subscriptionId = "subscription_id0";
UpdateWebhookSubscriptionRequest body = new UpdateWebhookSubscriptionRequest.Builder()
.Subscription(
new WebhookSubscription.Builder()
.Name("Updated Example Webhook Subscription")
.Enabled(false)
.Build())
.Build();
try
{
UpdateWebhookSubscriptionResponse result = await webhookSubscriptionsApi.UpdateWebhookSubscriptionAsync(
subscriptionId,
body
);
}
catch (ApiException e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
Updates a webhook subscription by replacing the existing signature key with a new one.
UpdateWebhookSubscriptionSignatureKeyAsync(
string subscriptionId,
Models.UpdateWebhookSubscriptionSignatureKeyRequest body)
Parameter | Type | Tags | Description |
---|---|---|---|
subscriptionId |
string |
Template, Required | [REQUIRED] The ID of the Subscription to update. |
body |
UpdateWebhookSubscriptionSignatureKeyRequest |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
Task<Models.UpdateWebhookSubscriptionSignatureKeyResponse>
string subscriptionId = "subscription_id0";
UpdateWebhookSubscriptionSignatureKeyRequest body = new UpdateWebhookSubscriptionSignatureKeyRequest.Builder()
.IdempotencyKey("ed80ae6b-0654-473b-bbab-a39aee89a60d")
.Build();
try
{
UpdateWebhookSubscriptionSignatureKeyResponse result = await webhookSubscriptionsApi.UpdateWebhookSubscriptionSignatureKeyAsync(
subscriptionId,
body
);
}
catch (ApiException e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
Tests a webhook subscription by sending a test event to the notification URL.
TestWebhookSubscriptionAsync(
string subscriptionId,
Models.TestWebhookSubscriptionRequest body)
Parameter | Type | Tags | Description |
---|---|---|---|
subscriptionId |
string |
Template, Required | [REQUIRED] The ID of the Subscription to test. |
body |
TestWebhookSubscriptionRequest |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
Task<Models.TestWebhookSubscriptionResponse>
string subscriptionId = "subscription_id0";
TestWebhookSubscriptionRequest body = new TestWebhookSubscriptionRequest.Builder()
.EventType("payment.created")
.Build();
try
{
TestWebhookSubscriptionResponse result = await webhookSubscriptionsApi.TestWebhookSubscriptionAsync(
subscriptionId,
body
);
}
catch (ApiException e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}