Skip to content
Get started

Create

projects.webhook_endpoints.create(strproject_id, WebhookEndpointCreateParams**kwargs) -> WebhookEndpointCreateResponse
POST/projects/{projectId}/webhook-endpoints

Register a new webhook endpoint for the project

ParametersExpand Collapse
project_id: str
enabled_events: List[Literal["*", "asset.download.completed", "asset.download.created", 16 more]]

The events that trigger the webhook. [’*’] indicates that all events are enabled

One of the following:
"*"
"asset.download.completed"
"asset.download.created"
"asset.download.failed"
"generation.completed"
"generation.created"
"generation.failed"
"inference.cancelled"
"inference.completed"
"inference.created"
"inference.failed"
"model.download.completed"
"model.download.created"
"model.download.failed"
"model.training.cancelled"
"model.training.completed"
"model.training.failed"
"model.training.started"
"team.credit.threshold.crossed"
url: str

The URL of the webhook endpoint. Must be an absolute http(s) URL

description: Optional[str]

A description of the webhook endpoint

ReturnsExpand Collapse
class WebhookEndpointCreateResponse: …
webhook_endpoint: WebhookEndpoint

The creation response, and the only one that carries the secret: it is generated once and never returned again, so a client that loses it has to recreate the endpoint.

id: str

The ID of the webhook endpoint

created_at: str

The date and time the webhook endpoint was created

enabled: bool

Whether the webhook is enabled

enabled_events: List[Literal["*", "asset.download.completed", "asset.download.created", 16 more]]

The events that trigger the webhook. [’*’] indicates that all events are enabled

One of the following:
"*"
"asset.download.completed"
"asset.download.created"
"asset.download.failed"
"generation.completed"
"generation.created"
"generation.failed"
"inference.cancelled"
"inference.completed"
"inference.created"
"inference.failed"
"model.download.completed"
"model.download.created"
"model.download.failed"
"model.training.cancelled"
"model.training.completed"
"model.training.failed"
"model.training.started"
"team.credit.threshold.crossed"
nb_failed_calls: float

The number of calls to the webhook endpoint that have failed

nb_total_calls: float

The number of calls to the webhook endpoint

owner_id: str

The ID of the owner of the webhook endpoint: a project id for job lifecycle events, a team id for alert events

owner_type: Literal["project", "team"]

Whether the owner is a project or a team. Required to tell them apart: a project created before the team/project split shares its team’s id

One of the following:
"project"
"team"
secret: str

The endpoint’s secret, used to generate webhook signatures

updated_at: str

The date and time the webhook endpoint was updated

url: str

The URL of the webhook endpoint

description: Optional[str]

A description of the webhook endpoint

Create

import os
from scenario_sdk import Scenario

client = Scenario(
    api_key=os.environ.get("SCENARIO_SDK_API_KEY"),  # This is the default and can be omitted
    api_secret=os.environ.get("SCENARIO_SDK_API_SECRET"),  # This is the default and can be omitted
)
webhook_endpoint = client.projects.webhook_endpoints.create(
    project_id="projectId",
    enabled_events=["*"],
    url="url",
)
print(webhook_endpoint.webhook_endpoint)
{
  "webhookEndpoint": {
    "id": "id",
    "createdAt": "createdAt",
    "enabled": true,
    "enabledEvents": [
      "*"
    ],
    "nbFailedCalls": 0,
    "nbTotalCalls": 0,
    "ownerId": "ownerId",
    "ownerType": "project",
    "secret": "secret",
    "updatedAt": "updatedAt",
    "url": "url",
    "description": "description"
  }
}
Returns Examples
{
  "webhookEndpoint": {
    "id": "id",
    "createdAt": "createdAt",
    "enabled": true,
    "enabledEvents": [
      "*"
    ],
    "nbFailedCalls": 0,
    "nbTotalCalls": 0,
    "ownerId": "ownerId",
    "ownerType": "project",
    "secret": "secret",
    "updatedAt": "updatedAt",
    "url": "url",
    "description": "description"
  }
}