Skip to content

Latest commit

 

History

History
355 lines (231 loc) · 31.1 KB

File metadata and controls

355 lines (231 loc) · 31.1 KB

Webhooks

Overview

Available Operations

list

Returns a page of webhooks in the current workspace. By default, the first 20 matching webhooks are ordered by creation time, newest first. Supplied filters are combined, count reports the total number of matches before pagination, and has_more indicates whether another page is available.

Example Usage

from orq_ai_sdk import Orq
import os


with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.webhooks.list()

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
page Optional[int] ➖ One-based page number. Defaults to 1 and must be between 1 and 1,000,000.
limit Optional[int] ➖ Number of webhooks to return per page. Defaults to 20 and must be between
1 and 200.
search Optional[str] ➖ Optional case-insensitive substring matched against display name, content
type, and URL. Maximum length is 200 characters.
event Optional[str] ➖ Optional event slug that must be present in the webhook's event
subscriptions, for example llm.response. Maximum length is 200
characters.
sort Optional[str] ➖ Field used to order results. Allowed values are created, updated, and
display_name. Defaults to created.
direction Optional[str] ➖ Sort direction. Allowed values are asc and desc. Defaults to desc.
content_type Optional[str] ➖ Optional comma-separated content types to match, for example
application/json,application/x-www-form-urlencoded. A webhook matches
when its content type equals any supplied value.
enabled Optional[bool] ➖ Optional delivery status filter. When omitted, enabled and disabled
webhooks are returned.
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.ListWebhooksResponse

Errors

Error Type Status Code Content Type
models.APIDefaultError 4XX, 5XX */*

create

Creates a webhook that delivers the selected workspace events to an HTTPS endpoint. Generate a signing secret first with GET /v2/webhooks/secret.

Example Usage

from orq_ai_sdk import Orq
import os


with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.webhooks.create(id="<id>", url="https://outlying-tenement.name/", content_type="application/json", display_name="June.Hand", events=[
        "<value 1>",
        "<value 2>",
    ], secret="<value>")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
id str ✔️ Client-generated webhook ID.
url str ✔️ HTTPS endpoint that receives webhook deliveries. https://hooks.example.com/webhooks/orq
content_type models.CreateWebhookRequestContentType ✔️ Content type sent with webhook deliveries.
display_name str ✔️ Human-readable webhook name. Deployment notifications
events List[str] ✔️ One or more workspace event slugs that trigger a delivery, for example deployment.invoked or llm.response.
secret str ✔️ Signing secret returned by GET /v2/webhooks/secret. Deliveries set X-Orq-Signature to the lowercase hexadecimal HMAC-SHA256 of the exact request body bytes.
enabled Optional[bool] ➖ Whether webhook deliveries are enabled.
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.Webhook

Errors

Error Type Status Code Content Type
models.APIDefaultError 4XX, 5XX */*

count

Returns the total number of enabled and disabled webhooks in the current workspace.

Example Usage

from orq_ai_sdk import Orq
import os


with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.webhooks.count()

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.CountWebhooksResponse

Errors

Error Type Status Code Content Type
models.APIDefaultError 4XX, 5XX */*

query

Deprecated. Returns webhooks matching legacy query filters. Use GET /v2/webhooks for pagination, search, event filtering, and sorting.

⚠️ DEPRECATED: This will be removed in a future release, please migrate away from it as soon as possible.

Example Usage

from orq_ai_sdk import Orq
import os


with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.webhooks.query()

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
pagination Optional[models.QueryParamsPagination] ➖ N/A
sorting_props List[models.QueryParamsSort] ➖ N/A
query Optional[models.Query] ➖ N/A
filters List[models.Filters] ➖ N/A
included_fields Dict[str, str] ➖ N/A
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.QueryWebhooksResponse

Errors

Error Type Status Code Content Type
models.APIDefaultError 4XX, 5XX */*

generate_secret

Generates a signing secret for verifying webhook deliveries. The secret is not persisted until it is used to create or update a webhook; store it securely.

Example Usage

from orq_ai_sdk import Orq
import os


with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.webhooks.generate_secret()

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.GenerateWebhookSecretResponse

Errors

Error Type Status Code Content Type
models.APIDefaultError 4XX, 5XX */*

get

Retrieves a webhook in the current workspace by ID. The signing secret is returned masked; it is only shown in full when the webhook is created.

Example Usage

from orq_ai_sdk import Orq
import os


with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.webhooks.get(id="<id>")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
id str ✔️ N/A
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.Webhook

Errors

Error Type Status Code Content Type
models.APIDefaultError 4XX, 5XX */*

delete

Deletes a webhook in the current workspace and returns the deleted webhook ID.

Example Usage

from orq_ai_sdk import Orq
import os


with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.webhooks.delete(id="<id>")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
id str ✔️ N/A
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.DeleteWebhookResponse

Errors

Error Type Status Code Content Type
models.APIDefaultError 4XX, 5XX */*

update

Updates the supplied fields on a webhook in the current workspace. Omitted fields are unchanged. The response contains the applied fields rather than the complete webhook.

Example Usage

from orq_ai_sdk import Orq
import os


with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.webhooks.update(id="<id>", request_body={})

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
id str ✔️ N/A
request_body models.WebhookUpdateRequestBody ✔️ N/A
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.WebhookUpdateResponseBody

Errors

Error Type Status Code Content Type
models.APIDefaultError 4XX, 5XX */*