POST
/
v1
/
webhooks
/
endpoints
Typescript (SDK)
import { Polar } from "@polar-sh/sdk";

const polar = new Polar({
  accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
});

async function run() {
  const result = await polar.webhooks.createWebhookEndpoint({
    url: "https://webhook.site/cb791d80-f26e-4f8c-be88-6e56054192b0",
    format: "slack",
    events: [
      "subscription.uncanceled",
    ],
    organizationId: "1dbfc517-0bbf-4301-9ba8-555ca42b9737",
  });

  console.log(result);
}

run();
{
  "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",
  "secret": "polar_whs_ovyN6cPrTv56AApvzCaJno08SSmGJmgbWilb33N2JuK",
  "organization_id": "<string>",
  "events": [
    "checkout.created"
  ]
}

Authorizations

Authorization
string
header
required

You can generate an Organization Access Token from your organization's settings.

Body

application/json

Schema to create a webhook endpoint.

url
string<uri>
required

The URL where the webhook events will be sent.

Required string length: 1 - 2083
Examples:

"https://webhook.site/cb791d80-f26e-4f8c-be88-6e56054192b0"

format
enum<string>
required

The format of the webhook payload.

Available options:
raw,
discord,
slack
events
enum<string>[]
required

The events that will trigger the webhook.

secret
string | null
deprecated

The secret used to sign the webhook events.

Minimum length: 32
Examples:

"polar_whs_ovyN6cPrTv56AApvzCaJno08SSmGJmgbWilb33N2JuK"

organization_id
string<uuid4> | null

The organization ID associated with the webhook endpoint. Required unless you use an organization token. The organization ID.

Examples:

"1dbfc517-0bbf-4301-9ba8-555ca42b9737"

Response

Webhook endpoint created.

A webhook endpoint.

created_at
string<date-time>
required

Creation timestamp of the object.

modified_at
string<date-time> | null
required

Last modification timestamp of the object.

id
string<uuid4>
required

The ID of the object.

url
string<uri>
required

The URL where the webhook events will be sent.

Required string length: 1 - 2083
Examples:

"https://webhook.site/cb791d80-f26e-4f8c-be88-6e56054192b0"

format
enum<string>
required

The format of the webhook payload.

Available options:
raw,
discord,
slack
secret
string
required

The secret used to sign the webhook events.

Examples:

"polar_whs_ovyN6cPrTv56AApvzCaJno08SSmGJmgbWilb33N2JuK"

organization_id
string<uuid4>
required

The organization ID associated with the webhook endpoint.

events
enum<string>[]
required

The events that will trigger the webhook.