- ListWebhookEndpoints - List Webhook Endpoints
- CreateWebhookEndpoint - Create Webhook Endpoint
- GetWebhookEndpoint - Get Webhook Endpoint
- DeleteWebhookEndpoint - Delete Webhook Endpoint
- UpdateWebhookEndpoint - Update Webhook Endpoint
- ResetWebhookEndpointSecret - Reset Webhook Endpoint Secret
- ListWebhookDeliveries - List Webhook Deliveries
- RedeliverWebhookEvent - Redeliver Webhook Event
List webhook endpoints.
Scopes: webhooks:read webhooks:write
package main
import(
"context"
"os"
polargo "github.com/polarsource/polar-go"
"github.com/polarsource/polar-go/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := polargo.New(
polargo.WithSecurity(os.Getenv("POLAR_ACCESS_TOKEN")),
)
res, err := s.Webhooks.ListWebhookEndpoints(ctx, polargo.Pointer(operations.CreateQueryParamOrganizationIDStr(
"1dbfc517-0bbf-4301-9ba8-555ca42b9737",
)), polargo.Pointer[int64](1), polargo.Pointer[int64](10))
if err != nil {
log.Fatal(err)
}
if res.ListResourceWebhookEndpoint != nil {
for {
// handle items
res, err = res.Next()
if err != nil {
// handle error
}
if res == nil {
break
}
}
}
}| Parameter | Type | Required | Description |
|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
organizationID |
*operations.QueryParamOrganizationID | ➖ | Filter by organization ID. |
page |
*int64 |
➖ | Page number, defaults to 1. |
limit |
*int64 |
➖ | Size of a page, defaults to 10. Maximum is 100. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.WebhooksListWebhookEndpointsResponse, error
| Error Type | Status Code | Content Type |
|---|---|---|
| apierrors.HTTPValidationError | 422 | application/json |
| apierrors.APIError | 4XX, 5XX | */* |
Create a webhook endpoint.
Scopes: webhooks:write
package main
import(
"context"
"os"
polargo "github.com/polarsource/polar-go"
"github.com/polarsource/polar-go/models/components"
"log"
)
func main() {
ctx := context.Background()
s := polargo.New(
polargo.WithSecurity(os.Getenv("POLAR_ACCESS_TOKEN")),
)
res, err := s.Webhooks.CreateWebhookEndpoint(ctx, components.WebhookEndpointCreate{
URL: "https://webhook.site/cb791d80-f26e-4f8c-be88-6e56054192b0",
Format: components.WebhookFormatSlack,
Events: []components.WebhookEventType{
components.WebhookEventTypeSubscriptionUncanceled,
},
OrganizationID: polargo.Pointer("1dbfc517-0bbf-4301-9ba8-555ca42b9737"),
})
if err != nil {
log.Fatal(err)
}
if res.WebhookEndpoint != nil {
// handle response
}
}| Parameter | Type | Required | Description |
|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
components.WebhookEndpointCreate | ✔️ | The request object to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.WebhooksCreateWebhookEndpointResponse, error
| Error Type | Status Code | Content Type |
|---|---|---|
| apierrors.HTTPValidationError | 422 | application/json |
| apierrors.APIError | 4XX, 5XX | */* |
Get a webhook endpoint by ID.
Scopes: webhooks:read webhooks:write
package main
import(
"context"
"os"
polargo "github.com/polarsource/polar-go"
"log"
)
func main() {
ctx := context.Background()
s := polargo.New(
polargo.WithSecurity(os.Getenv("POLAR_ACCESS_TOKEN")),
)
res, err := s.Webhooks.GetWebhookEndpoint(ctx, "<value>")
if err != nil {
log.Fatal(err)
}
if res.WebhookEndpoint != nil {
// handle response
}
}| Parameter | Type | Required | Description |
|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
id |
string |
✔️ | The webhook endpoint ID. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.WebhooksGetWebhookEndpointResponse, error
| Error Type | Status Code | Content Type |
|---|---|---|
| apierrors.ResourceNotFound | 404 | application/json |
| apierrors.HTTPValidationError | 422 | application/json |
| apierrors.APIError | 4XX, 5XX | */* |
Delete a webhook endpoint.
Scopes: webhooks:write
package main
import(
"context"
"os"
polargo "github.com/polarsource/polar-go"
"log"
)
func main() {
ctx := context.Background()
s := polargo.New(
polargo.WithSecurity(os.Getenv("POLAR_ACCESS_TOKEN")),
)
res, err := s.Webhooks.DeleteWebhookEndpoint(ctx, "<value>")
if err != nil {
log.Fatal(err)
}
if res != nil {
// handle response
}
}| Parameter | Type | Required | Description |
|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
id |
string |
✔️ | The webhook endpoint ID. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.WebhooksDeleteWebhookEndpointResponse, error
| Error Type | Status Code | Content Type |
|---|---|---|
| apierrors.ResourceNotFound | 404 | application/json |
| apierrors.HTTPValidationError | 422 | application/json |
| apierrors.APIError | 4XX, 5XX | */* |
Update a webhook endpoint.
Scopes: webhooks:write
package main
import(
"context"
"os"
polargo "github.com/polarsource/polar-go"
"github.com/polarsource/polar-go/models/components"
"log"
)
func main() {
ctx := context.Background()
s := polargo.New(
polargo.WithSecurity(os.Getenv("POLAR_ACCESS_TOKEN")),
)
res, err := s.Webhooks.UpdateWebhookEndpoint(ctx, "<value>", components.WebhookEndpointUpdate{
URL: polargo.Pointer("https://webhook.site/cb791d80-f26e-4f8c-be88-6e56054192b0"),
})
if err != nil {
log.Fatal(err)
}
if res.WebhookEndpoint != nil {
// handle response
}
}| Parameter | Type | Required | Description |
|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
id |
string |
✔️ | The webhook endpoint ID. |
webhookEndpointUpdate |
components.WebhookEndpointUpdate | ✔️ | N/A |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.WebhooksUpdateWebhookEndpointResponse, error
| Error Type | Status Code | Content Type |
|---|---|---|
| apierrors.ResourceNotFound | 404 | application/json |
| apierrors.HTTPValidationError | 422 | application/json |
| apierrors.APIError | 4XX, 5XX | */* |
Regenerate a webhook endpoint secret.
Scopes: webhooks:write
package main
import(
"context"
"os"
polargo "github.com/polarsource/polar-go"
"log"
)
func main() {
ctx := context.Background()
s := polargo.New(
polargo.WithSecurity(os.Getenv("POLAR_ACCESS_TOKEN")),
)
res, err := s.Webhooks.ResetWebhookEndpointSecret(ctx, "<value>")
if err != nil {
log.Fatal(err)
}
if res.WebhookEndpoint != nil {
// handle response
}
}| Parameter | Type | Required | Description |
|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
id |
string |
✔️ | The webhook endpoint ID. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.WebhooksResetWebhookEndpointSecretResponse, error
| Error Type | Status Code | Content Type |
|---|---|---|
| apierrors.ResourceNotFound | 404 | application/json |
| apierrors.HTTPValidationError | 422 | application/json |
| apierrors.APIError | 4XX, 5XX | */* |
List webhook deliveries.
Deliveries are all the attempts to deliver a webhook event to an endpoint.
Scopes: webhooks:read webhooks:write
package main
import(
"context"
"os"
polargo "github.com/polarsource/polar-go"
"github.com/polarsource/polar-go/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := polargo.New(
polargo.WithSecurity(os.Getenv("POLAR_ACCESS_TOKEN")),
)
res, err := s.Webhooks.ListWebhookDeliveries(ctx, operations.WebhooksListWebhookDeliveriesRequest{})
if err != nil {
log.Fatal(err)
}
if res.ListResourceWebhookDelivery != nil {
for {
// handle items
res, err = res.Next()
if err != nil {
// handle error
}
if res == nil {
break
}
}
}
}| Parameter | Type | Required | Description |
|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
operations.WebhooksListWebhookDeliveriesRequest | ✔️ | The request object to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.WebhooksListWebhookDeliveriesResponse, error
| Error Type | Status Code | Content Type |
|---|---|---|
| apierrors.HTTPValidationError | 422 | application/json |
| apierrors.APIError | 4XX, 5XX | */* |
Schedule the re-delivery of a webhook event.
Scopes: webhooks:write
package main
import(
"context"
"os"
polargo "github.com/polarsource/polar-go"
"log"
)
func main() {
ctx := context.Background()
s := polargo.New(
polargo.WithSecurity(os.Getenv("POLAR_ACCESS_TOKEN")),
)
res, err := s.Webhooks.RedeliverWebhookEvent(ctx, "<value>")
if err != nil {
log.Fatal(err)
}
if res.Any != nil {
// handle response
}
}| Parameter | Type | Required | Description |
|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
id |
string |
✔️ | The webhook event ID. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.WebhooksRedeliverWebhookEventResponse, error
| Error Type | Status Code | Content Type |
|---|---|---|
| apierrors.ResourceNotFound | 404 | application/json |
| apierrors.HTTPValidationError | 422 | application/json |
| apierrors.APIError | 4XX, 5XX | */* |