Skip to content

Latest commit

 

History

History
284 lines (195 loc) · 26 KB

File metadata and controls

284 lines (195 loc) · 26 KB

Webhooks

(webhook.webhooks)

Overview

Available Operations

  • list - List webhook subscriptions
  • create - Create webhook subscription
  • get - Get webhook subscription
  • update - Update webhook subscription
  • delete - Delete webhook subscription

list

List all webhook subscriptions

Example Usage

from apideck_unify import Apideck
import os


with Apideck(
    app_id="dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
    api_key=os.getenv("APIDECK_API_KEY", ""),
) as apideck:

    res = apideck.webhook.webhooks.list(limit=20)

    while res is not None:
        # Handle items

        res = res.next()

Parameters

Parameter Type Required Description Example
app_id Optional[str] The ID of your Unify application dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX
cursor OptionalNullable[str] Cursor to start from. You can find cursors for next/previous pages in the meta.cursors property of the response.
limit Optional[int] Number of results to return. Minimum 1, Maximum 200, Default 20
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.WebhookWebhooksAllResponse

Errors

Error Type Status Code Content Type
models.BadRequestResponse 400 application/json
models.UnauthorizedResponse 401 application/json
models.PaymentRequiredResponse 402 application/json
models.NotFoundResponse 404 application/json
models.UnprocessableResponse 422 application/json
models.APIError 4XX, 5XX */*

create

Create a webhook subscription to receive events.

Delivery URL Validation: The provided delivery_url will be validated synchronously by sending an HTTP POST request with an HMAC signature. If validation fails (network error, timeout, non-2xx response), the webhook will still be created but with status: "disabled" and disabled_reason: "delivery_url_validation_failed".

Important: Always check the status and disabled_reason fields in the response to ensure the webhook is active.

Example Usage

import apideck_unify
from apideck_unify import Apideck
import os


with Apideck(
    app_id="dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
    api_key=os.getenv("APIDECK_API_KEY", ""),
) as apideck:

    res = apideck.webhook.webhooks.create(unified_api=apideck_unify.UnifiedAPIID.CRM, status=apideck_unify.Status.ENABLED, delivery_url="https://example.com/my/webhook/endpoint", events=[
        apideck_unify.WebhookEventType.VAULT_CONNECTION_CREATED,
        apideck_unify.WebhookEventType.VAULT_CONNECTION_UPDATED,
    ], description="A description")

    assert res.create_webhook_response is not None

    # Handle response
    print(res.create_webhook_response)

Parameters

Parameter Type Required Description Example
unified_api models.UnifiedAPIID ✔️ Name of Apideck Unified API crm
status models.Status ✔️ The status of the webhook. enabled
delivery_url str ✔️ The delivery url of the webhook endpoint. https://example.com/my/webhook/endpoint
events List[models.WebhookEventType] ✔️ The list of subscribed events for this webhook. [*] indicates that all events are enabled. [
"vault.connection.created",
"vault.connection.updated"
]
app_id Optional[str] The ID of your Unify application dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX
description OptionalNullable[str] A description of the object. A description
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.WebhookWebhooksAddResponse

Errors

Error Type Status Code Content Type
models.BadRequestResponse 400 application/json
models.UnauthorizedResponse 401 application/json
models.PaymentRequiredResponse 402 application/json
models.NotFoundResponse 404 application/json
models.UnprocessableResponse 422 application/json
models.APIError 4XX, 5XX */*

get

Get the webhook subscription details

Example Usage

from apideck_unify import Apideck
import os


with Apideck(
    app_id="dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
    api_key=os.getenv("APIDECK_API_KEY", ""),
) as apideck:

    res = apideck.webhook.webhooks.get(id="<id>")

    assert res.get_webhook_response is not None

    # Handle response
    print(res.get_webhook_response)

Parameters

Parameter Type Required Description Example
id str ✔️ JWT Webhook token that represents the unifiedApi and applicationId associated to the event source.
app_id Optional[str] The ID of your Unify application dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.WebhookWebhooksOneResponse

Errors

Error Type Status Code Content Type
models.BadRequestResponse 400 application/json
models.UnauthorizedResponse 401 application/json
models.PaymentRequiredResponse 402 application/json
models.NotFoundResponse 404 application/json
models.UnprocessableResponse 422 application/json
models.APIError 4XX, 5XX */*

update

Update a webhook subscription.

Delivery URL Validation: When updating the delivery_url, it will be validated synchronously by sending an HTTP POST request with an HMAC signature. If validation fails (network error, timeout, non-2xx response), the webhook will still be updated but with status: "disabled" and disabled_reason: "delivery_url_validation_failed". Validation only occurs when the URL is changed.

Important: Always check the status and disabled_reason fields in the response to ensure the webhook is active.

Example Usage

import apideck_unify
from apideck_unify import Apideck
import os


with Apideck(
    app_id="dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
    api_key=os.getenv("APIDECK_API_KEY", ""),
) as apideck:

    res = apideck.webhook.webhooks.update(id="<id>", description="A description", status=apideck_unify.Status.ENABLED, delivery_url="https://example.com/my/webhook/endpoint", events=[
        apideck_unify.WebhookEventType.VAULT_CONNECTION_CREATED,
        apideck_unify.WebhookEventType.VAULT_CONNECTION_UPDATED,
    ])

    assert res.update_webhook_response is not None

    # Handle response
    print(res.update_webhook_response)

Parameters

Parameter Type Required Description Example
id str ✔️ JWT Webhook token that represents the unifiedApi and applicationId associated to the event source.
app_id Optional[str] The ID of your Unify application dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX
description OptionalNullable[str] A description of the object. A description
status Optional[models.Status] The status of the webhook. enabled
delivery_url Optional[str] The delivery url of the webhook endpoint. https://example.com/my/webhook/endpoint
events List[models.WebhookEventType] The list of subscribed events for this webhook. [*] indicates that all events are enabled. [
"vault.connection.created",
"vault.connection.updated"
]
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.WebhookWebhooksUpdateResponse

Errors

Error Type Status Code Content Type
models.BadRequestResponse 400 application/json
models.UnauthorizedResponse 401 application/json
models.PaymentRequiredResponse 402 application/json
models.NotFoundResponse 404 application/json
models.UnprocessableResponse 422 application/json
models.APIError 4XX, 5XX */*

delete

Delete a webhook subscription

Example Usage

from apideck_unify import Apideck
import os


with Apideck(
    app_id="dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
    api_key=os.getenv("APIDECK_API_KEY", ""),
) as apideck:

    res = apideck.webhook.webhooks.delete(id="<id>")

    assert res.delete_webhook_response is not None

    # Handle response
    print(res.delete_webhook_response)

Parameters

Parameter Type Required Description Example
id str ✔️ JWT Webhook token that represents the unifiedApi and applicationId associated to the event source.
app_id Optional[str] The ID of your Unify application dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.WebhookWebhooksDeleteResponse

Errors

Error Type Status Code Content Type
models.BadRequestResponse 400 application/json
models.UnauthorizedResponse 401 application/json
models.PaymentRequiredResponse 402 application/json
models.NotFoundResponse 404 application/json
models.UnprocessableResponse 422 application/json
models.APIError 4XX, 5XX */*