Skip to main content

Get Webhook Subscriptions

Description

Get a list of registered webhook subscriptions.

Endpoint​

Method: GET
/api/v2/callbacks/subscriptions/

Sample Code​

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("https://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);
}
}
}

Response​

NameDescriptionType
SubscriptionIDA unique identifier for the subscription.GUID
CallbackUriThe merchant callback endpoint.String
EventsList of events.Events
VerifiedIndicates if CallbackUri is verified or not.Boolean

Response Code​

CodeHttpStatusCodeDescription
200OkWebhook URL valid and verified.
403ForbiddenMerchant does not have permission to access this resource.
401UnauthorizedMerchant is not authorized to retrieve information.