Skip to content

Latest commit

 

History

History
378 lines (246 loc) · 22.2 KB

File metadata and controls

378 lines (246 loc) · 22.2 KB

Webhooks

(webhooks)

Overview

Available Operations

list_webhook_endpoints

List webhook endpoints.

Scopes: webhooks:read webhooks:write

Example Usage

from polar_sdk import Polar


with Polar(
    access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:

    res = polar.webhooks.list_webhook_endpoints(organization_id="1dbfc517-0bbf-4301-9ba8-555ca42b9737", page=1, limit=10)

    while res is not None:
        # Handle items

        res = res.next()

Parameters

Parameter Type Required Description
organization_id OptionalNullable[models.QueryParamOrganizationID] Filter by organization ID.
page Optional[int] Page number, defaults to 1.
limit Optional[int] Size of a page, defaults to 10. Maximum is 100.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.WebhooksListWebhookEndpointsResponse

Errors

Error Type Status Code Content Type
models.HTTPValidationError 422 application/json
models.SDKError 4XX, 5XX */*

create_webhook_endpoint

Create a webhook endpoint.

Scopes: webhooks:write

Example Usage

import polar_sdk
from polar_sdk import Polar


with Polar(
    access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:

    res = polar.webhooks.create_webhook_endpoint(request={
        "url": "https://webhook.site/cb791d80-f26e-4f8c-be88-6e56054192b0",
        "format_": polar_sdk.WebhookFormat.SLACK,
        "events": [
            polar_sdk.WebhookEventType.SUBSCRIPTION_UNCANCELED,
        ],
        "organization_id": "1dbfc517-0bbf-4301-9ba8-555ca42b9737",
    })

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
request models.WebhookEndpointCreate ✔️ The request object to use for the request.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.WebhookEndpoint

Errors

Error Type Status Code Content Type
models.HTTPValidationError 422 application/json
models.SDKError 4XX, 5XX */*

get_webhook_endpoint

Get a webhook endpoint by ID.

Scopes: webhooks:read webhooks:write

Example Usage

from polar_sdk import Polar


with Polar(
    access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:

    res = polar.webhooks.get_webhook_endpoint(id="<value>")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
id str ✔️ The webhook endpoint ID.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.WebhookEndpoint

Errors

Error Type Status Code Content Type
models.ResourceNotFound 404 application/json
models.HTTPValidationError 422 application/json
models.SDKError 4XX, 5XX */*

update_webhook_endpoint

Update a webhook endpoint.

Scopes: webhooks:write

Example Usage

from polar_sdk import Polar


with Polar(
    access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:

    res = polar.webhooks.update_webhook_endpoint(id="<value>", webhook_endpoint_update={
        "url": "https://webhook.site/cb791d80-f26e-4f8c-be88-6e56054192b0",
    })

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
id str ✔️ The webhook endpoint ID.
webhook_endpoint_update models.WebhookEndpointUpdate ✔️ N/A
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.WebhookEndpoint

Errors

Error Type Status Code Content Type
models.ResourceNotFound 404 application/json
models.HTTPValidationError 422 application/json
models.SDKError 4XX, 5XX */*

delete_webhook_endpoint

Delete a webhook endpoint.

Scopes: webhooks:write

Example Usage

from polar_sdk import Polar


with Polar(
    access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:

    polar.webhooks.delete_webhook_endpoint(id="<value>")

    # Use the SDK ...

Parameters

Parameter Type Required Description
id str ✔️ The webhook endpoint ID.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Errors

Error Type Status Code Content Type
models.ResourceNotFound 404 application/json
models.HTTPValidationError 422 application/json
models.SDKError 4XX, 5XX */*

reset_webhook_endpoint_secret

Regenerate a webhook endpoint secret.

Scopes: webhooks:write

Example Usage

from polar_sdk import Polar


with Polar(
    access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:

    res = polar.webhooks.reset_webhook_endpoint_secret(id="<value>")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
id str ✔️ The webhook endpoint ID.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.WebhookEndpoint

Errors

Error Type Status Code Content Type
models.ResourceNotFound 404 application/json
models.HTTPValidationError 422 application/json
models.SDKError 4XX, 5XX */*

list_webhook_deliveries

List webhook deliveries.

Deliveries are all the attempts to deliver a webhook event to an endpoint.

Scopes: webhooks:read webhooks:write

Example Usage

from polar_sdk import Polar


with Polar(
    access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:

    res = polar.webhooks.list_webhook_deliveries(page=1, limit=10)

    while res is not None:
        # Handle items

        res = res.next()

Parameters

Parameter Type Required Description
endpoint_id OptionalNullable[models.EndpointID] Filter by webhook endpoint ID.
start_timestamp date Filter deliveries after this timestamp.
end_timestamp date Filter deliveries before this timestamp.
succeeded OptionalNullable[bool] Filter by delivery success status.
query OptionalNullable[str] Query to filter webhook deliveries.
http_code_class OptionalNullable[models.HTTPCodeClass] Filter by HTTP response code class (2xx, 3xx, 4xx, 5xx).
event_type OptionalNullable[models.QueryParamEventType] Filter by webhook event type.
page Optional[int] Page number, defaults to 1.
limit Optional[int] Size of a page, defaults to 10. Maximum is 100.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.WebhooksListWebhookDeliveriesResponse

Errors

Error Type Status Code Content Type
models.HTTPValidationError 422 application/json
models.SDKError 4XX, 5XX */*

redeliver_webhook_event

Schedule the re-delivery of a webhook event.

Scopes: webhooks:write

Example Usage

from polar_sdk import Polar


with Polar(
    access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:

    res = polar.webhooks.redeliver_webhook_event(id="<value>")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
id str ✔️ The webhook event ID.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

Any

Errors

Error Type Status Code Content Type
models.ResourceNotFound 404 application/json
models.HTTPValidationError 422 application/json
models.SDKError 4XX, 5XX */*