Get Webhook Subscriptions
Description
Get a list of registered webhook subscriptions.
Endpoint
Method: GET
/api/v2/callbacks/subscriptions/
Sample Code
- C#
- Response
Get Subscriptions Example
using Microsoft.Extensions.DependencyInjection;
internal static class GetSubscription
{
internal static async Task GetSubscriptionsAsync()
{
var services = new ServiceCollection();
services.AddHttpClient("MyApiClient", client =>
{
client.BaseAddress = new Uri("http://paymentadminapistage.svea.com/api/");
});
var serviceProvider = services.BuildServiceProvider();
var httpClientFactory = serviceProvider.GetRequiredService<IHttpClientFactory>();
var httpClient = httpClientFactory.CreateClient("MyApiClient");
var apiUrl = string.Format("v2/callbacks/subscriptions/");
// Add authorization header
Authentication.CreateAuthenticationToken(out string token, out string timestamp);
httpClient.DefaultRequestHeaders.Add("Authorization", token);
httpClient.DefaultRequestHeaders.Add("Timestamp", timestamp);
try
{
HttpResponseMessage response = await httpClient.GetAsync(apiUrl);
// Check if the request was successful
if (response.IsSuccessStatusCode)
{
string responseData = await response.Content.ReadAsStringAsync();
Console.WriteLine("Response: " + responseData);
}
else
{
Console.WriteLine("Failed to retrieve data. Status code: " + response.StatusCode);
}
}
catch (HttpRequestException ex)
{
Console.WriteLine("Error: " + ex.Message);
}
}
}
Get Subscription Response
[
{
"SubscriptionId": "fbb6c74a-cc06-4ab7-100e-08daa861c517",
"CallbackUri": "<webhook url>",
"Events": [
"CheckoutOrder.CreditSucceeded",
"CheckoutOrder.CreditFailed",
"CheckoutOrder.Created",
"CheckoutOrder.Delivered"
],
"Verified": true
}
]
Response
Name | Description | Type |
---|---|---|
SubscriptionId | A unique identifier for the subscription. | GUID |
CallbackUri | The merchant callback endpoint. | String |
Events | List of events. | Events |
Verified | Indicates if CallbackUri is verified or not. | Boolean |
Response Code
Code | HttpStatusCode | Description |
---|---|---|
200 | Ok | Webhook URL valid and verified. |
403 | Forbidden | Merchant is not authorized to retrieve information. |
401 | Unauthorized | Merchant is not authorized to retrieve information. |