List the webhooks of the project. The list is paginated.
from moderation_api import ModerationAPI
import os
with ModerationAPI(
secret_key=os.getenv("MODAPI_SECRET_KEY", ""),
) as ma_client:
res = ma_client.webhooks.list(page=1, page_size=20)
while res is not None:
# Handle items
res = res.next()
| Parameter |
Type |
Required |
Description |
page |
Optional[int] |
➖ |
N/A |
page_size |
Optional[int] |
➖ |
N/A |
project_id |
Optional[str] |
➖ |
The project to act on, by ID or name. Required with an organization key unless the key reaches only one project; list projects with GET /projects. A project key acts on its own project and needs no value: naming another one is an error. |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
models.ListWebhooksResponse
| Error Type |
Status Code |
Content Type |
| errors.AuthenticationError |
401 |
application/json |
| errors.RateLimitError |
429 |
application/json |
| errors.ModerationAPIDefaultError |
4XX, 5XX |
*/* |
Create a webhook subscribed to one or more event types. Deliveries use the v2 envelope and are signed with the project signing secret (see the signing secret endpoint).
from moderation_api import ModerationAPI
import os
with ModerationAPI(
secret_key=os.getenv("MODAPI_SECRET_KEY", ""),
) as ma_client:
res = ma_client.webhooks.create(name="Moderation events", url="https://example.com/webhooks/moderation", event_types=[
"QUEUE_ITEM_REJECTED",
"AUTHOR_BLOCKED",
])
# Handle response
print(res)
| Parameter |
Type |
Required |
Description |
name |
str |
✔️ |
The webhook's name, used to identify it in the dashboard |
url |
str |
✔️ |
The webhook's URL. We'll call this URL when an event occurs. |
event_types |
List[models.CreateWebhookEventTypeRequest] |
✔️ |
Event types this webhook subscribes to. One webhook URL receives all events you list here. |
project_id |
Optional[str] |
➖ |
The project to act on, by ID or name. Required with an organization key unless the key reaches only one project; list projects with GET /projects. A project key acts on its own project and needs no value: naming another one is an error. |
description |
OptionalNullable[str] |
➖ |
The webhook's description |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
models.CreateWebhookResponse
| Error Type |
Status Code |
Content Type |
| errors.BadRequestError |
400 |
application/json |
| errors.AuthenticationError |
401 |
application/json |
| errors.RateLimitError |
429 |
application/json |
| errors.ModerationAPIDefaultError |
4XX, 5XX |
*/* |
Get a webhook by ID.
from moderation_api import ModerationAPI
import os
with ModerationAPI(
secret_key=os.getenv("MODAPI_SECRET_KEY", ""),
) as ma_client:
res = ma_client.webhooks.retrieve(id="<id>")
# Handle response
print(res)
| Parameter |
Type |
Required |
Description |
id |
str |
✔️ |
The ID of the webhook to get. |
project_id |
Optional[str] |
➖ |
The project to act on, by ID or name. Required with an organization key unless the key reaches only one project; list projects with GET /projects. A project key acts on its own project and needs no value: naming another one is an error. |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
models.GetWebhookResponse
| Error Type |
Status Code |
Content Type |
| errors.AuthenticationError |
401 |
application/json |
| errors.NotFoundError |
404 |
application/json |
| errors.RateLimitError |
429 |
application/json |
| errors.ModerationAPIDefaultError |
4XX, 5XX |
*/* |
Update a webhook. Legacy v1 webhooks are read-only: delete them and create a new webhook instead.
from moderation_api import ModerationAPI
import os
with ModerationAPI(
secret_key=os.getenv("MODAPI_SECRET_KEY", ""),
) as ma_client:
res = ma_client.webhooks.update(id="<id>")
# Handle response
print(res)
| Parameter |
Type |
Required |
Description |
id |
str |
✔️ |
The ID of the webhook to update. |
project_id |
Optional[str] |
➖ |
The project to act on, by ID or name. Required with an organization key unless the key reaches only one project; list projects with GET /projects. A project key acts on its own project and needs no value: naming another one is an error. |
name |
Optional[str] |
➖ |
The webhook's name, used to identify it in the dashboard |
description |
OptionalNullable[str] |
➖ |
The webhook's description |
url |
Optional[str] |
➖ |
The webhook's URL. We'll call this URL when an event occurs. |
event_types |
List[models.UpdateWebhookEventTypeRequest] |
➖ |
Event types this webhook subscribes to. One webhook URL receives all events you list here. |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
models.UpdateWebhookResponse
| Error Type |
Status Code |
Content Type |
| errors.BadRequestError |
400 |
application/json |
| errors.AuthenticationError |
401 |
application/json |
| errors.NotFoundError |
404 |
application/json |
| errors.RateLimitError |
429 |
application/json |
| errors.ModerationAPIDefaultError |
4XX, 5XX |
*/* |
Delete a webhook.
from moderation_api import ModerationAPI
import os
with ModerationAPI(
secret_key=os.getenv("MODAPI_SECRET_KEY", ""),
) as ma_client:
res = ma_client.webhooks.delete(id="<id>")
# Handle response
print(res)
| Parameter |
Type |
Required |
Description |
id |
str |
✔️ |
The ID of the webhook to delete. |
project_id |
Optional[str] |
➖ |
The project to act on, by ID or name. Required with an organization key unless the key reaches only one project; list projects with GET /projects. A project key acts on its own project and needs no value: naming another one is an error. |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
models.DeleteWebhookResponse
| Error Type |
Status Code |
Content Type |
| errors.AuthenticationError |
401 |
application/json |
| errors.NotFoundError |
404 |
application/json |
| errors.RateLimitError |
429 |
application/json |
| errors.ModerationAPIDefaultError |
4XX, 5XX |
*/* |