General
Core API
- Checkout
- Checkout Links
- Custom Checkout Fields
- Customers
- Subscriptions
- Orders
- Discounts
- Refunds
- Products
- Events
- Meters
- Benefits
- Customer Meters
- License Keys
- Files
- Organizations
- Metrics
Customer Portal API
- GETGet Customer
- GETGet Organization
- Sessions
- Subscriptions
- Orders
- License Keys
- File Downloads
Webhook Events
- Customer Events
- Billing Events
- Organization Events
Integrations
- OpenID Connect
- OAuth 2.0 Clients
- Webhooks
Webhooks
Create Webhook Endpoint
Create a webhook endpoint.
Scopes: webhooks:write
POST
/
v1
/
webhooks
/
endpoints
Copy
Ask AI
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,
Secret: "f_z6mfSpxkjogyw3FkA2aH2gYE5huxruNf34MpdWMcA",
Events: []components.WebhookEventType{
components.WebhookEventTypeSubscriptionUncanceled,
},
OrganizationID: polargo.String("1dbfc517-0bbf-4301-9ba8-555ca42b9737"),
})
if err != nil {
log.Fatal(err)
}
if res.WebhookEndpoint != nil {
// handle response
}
}
Copy
Ask AI
{
"created_at": "2023-11-07T05:31:56Z",
"modified_at": "2023-11-07T05:31:56Z",
"id": "<string>",
"url": "https://webhook.site/cb791d80-f26e-4f8c-be88-6e56054192b0",
"format": "raw",
"organization_id": "<string>",
"events": [
"checkout.created"
]
}
Authorizations
You can generate an Organization Access Token from your organization's settings.
Body
application/json
Schema to create a webhook endpoint.
Response
201
application/json
Webhook endpoint created.
A webhook endpoint.
Was this page helpful?
Copy
Ask AI
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,
Secret: "f_z6mfSpxkjogyw3FkA2aH2gYE5huxruNf34MpdWMcA",
Events: []components.WebhookEventType{
components.WebhookEventTypeSubscriptionUncanceled,
},
OrganizationID: polargo.String("1dbfc517-0bbf-4301-9ba8-555ca42b9737"),
})
if err != nil {
log.Fatal(err)
}
if res.WebhookEndpoint != nil {
// handle response
}
}
Copy
Ask AI
{
"created_at": "2023-11-07T05:31:56Z",
"modified_at": "2023-11-07T05:31:56Z",
"id": "<string>",
"url": "https://webhook.site/cb791d80-f26e-4f8c-be88-6e56054192b0",
"format": "raw",
"organization_id": "<string>",
"events": [
"checkout.created"
]
}
Assistant
Responses are generated using AI and may contain mistakes.