# Webhook Endpoints

## Create

`projects.webhook_endpoints.create(strproject_id, WebhookEndpointCreateParams**kwargs)  -> WebhookEndpointCreateResponse`

**post** `/projects/{projectId}/webhook-endpoints`

Register a new webhook endpoint for the project

### Parameters

- `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

  - `"*"`

  - `"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

### Returns

- `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

      - `"*"`

      - `"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

      - `"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

### Example

```python
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)
```

#### Response

```json
{
  "webhookEndpoint": {
    "id": "id",
    "createdAt": "createdAt",
    "enabled": true,
    "enabledEvents": [
      "*"
    ],
    "nbFailedCalls": 0,
    "nbTotalCalls": 0,
    "ownerId": "ownerId",
    "ownerType": "project",
    "secret": "secret",
    "updatedAt": "updatedAt",
    "url": "url",
    "description": "description"
  }
}
```

## Delete

`projects.webhook_endpoints.delete(strwebhook_endpoint_id, WebhookEndpointDeleteParams**kwargs)  -> object`

**delete** `/projects/{projectId}/webhook-endpoints/{webhookEndpointId}`

Delete a particular webhook endpoint by its Id

### Parameters

- `project_id: str`

- `webhook_endpoint_id: str`

### Returns

- `object`

### Example

```python
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.delete(
    webhook_endpoint_id="webhookEndpointId",
    project_id="projectId",
)
print(webhook_endpoint)
```

#### Response

```json
{}
```

## List

`projects.webhook_endpoints.list(strproject_id)  -> WebhookEndpointListResponse`

**get** `/projects/{projectId}/webhook-endpoints`

List the project's webhook endpoints

### Parameters

- `project_id: str`

### Returns

- `class WebhookEndpointListResponse: …`

  - `webhook_endpoints: List[WebhookEndpoint]`

    A list of the project webhooks

    - `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

      - `"*"`

      - `"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

      - `"project"`

      - `"team"`

    - `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

### Example

```python
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_endpoints = client.projects.webhook_endpoints.list(
    "projectId",
)
print(webhook_endpoints.webhook_endpoints)
```

#### Response

```json
{
  "webhookEndpoints": [
    {
      "id": "id",
      "createdAt": "createdAt",
      "enabled": true,
      "enabledEvents": [
        "*"
      ],
      "nbFailedCalls": 0,
      "nbTotalCalls": 0,
      "ownerId": "ownerId",
      "ownerType": "project",
      "updatedAt": "updatedAt",
      "url": "url",
      "description": "description"
    }
  ]
}
```

## Update

`projects.webhook_endpoints.update(strwebhook_endpoint_id, WebhookEndpointUpdateParams**kwargs)  -> WebhookEndpointUpdateResponse`

**put** `/projects/{projectId}/webhook-endpoints/{webhookEndpointId}`

Update a particular webhook endpoint for a project

### Parameters

- `project_id: str`

- `webhook_endpoint_id: str`

- `description: Optional[str]`

  A description of the webhook endpoint

- `enabled: Optional[bool]`

  Whether the webhook is enabled

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

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

  - `"*"`

  - `"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: Optional[str]`

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

### Returns

- `class WebhookEndpointUpdateResponse: …`

  - `webhook_endpoint: WebhookEndpoint`

    - `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

      - `"*"`

      - `"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

      - `"project"`

      - `"team"`

    - `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

### Example

```python
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.update(
    webhook_endpoint_id="webhookEndpointId",
    project_id="projectId",
)
print(webhook_endpoint.webhook_endpoint)
```

#### Response

```json
{
  "webhookEndpoint": {
    "id": "id",
    "createdAt": "createdAt",
    "enabled": true,
    "enabledEvents": [
      "*"
    ],
    "nbFailedCalls": 0,
    "nbTotalCalls": 0,
    "ownerId": "ownerId",
    "ownerType": "project",
    "updatedAt": "updatedAt",
    "url": "url",
    "description": "description"
  }
}
```

## Domain Types

### Webhook Endpoint Create Response

- `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

      - `"*"`

      - `"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

      - `"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

### Webhook Endpoint List Response

- `class WebhookEndpointListResponse: …`

  - `webhook_endpoints: List[WebhookEndpoint]`

    A list of the project webhooks

    - `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

      - `"*"`

      - `"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

      - `"project"`

      - `"team"`

    - `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

### Webhook Endpoint Update Response

- `class WebhookEndpointUpdateResponse: …`

  - `webhook_endpoint: WebhookEndpoint`

    - `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

      - `"*"`

      - `"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

      - `"project"`

      - `"team"`

    - `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

# Events

## List

`projects.webhook_endpoints.events.list(strwebhook_endpoint_id, EventListParams**kwargs)  -> EventListResponse`

**get** `/projects/{projectId}/webhook-endpoints/{webhookEndpointId}/events`

List the project's webhook events

### Parameters

- `project_id: str`

- `webhook_endpoint_id: str`

- `pagination_token: Optional[str]`

  A token you received in a previous request to query the next page of items

### Returns

- `class EventListResponse: …`

  - `items: List[Item]`

    A list of the project webhook events

    - `id: str`

    - `endpoint_id: str`

    - `status: Literal["created", "failed", "retrying", "success"]`

      - `"created"`

      - `"failed"`

      - `"retrying"`

      - `"success"`

    - `type: Literal["*", "asset.download.completed", "asset.download.created", 16 more]`

      Every event a webhook endpoint can subscribe to: a project endpoint takes the
      job lifecycle events, a team endpoint takes the alert events.

      - `"*"`

      - `"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"`

    - `updated_at: str`

  - `next_pagination_token: Optional[str]`

    A token to query the next page of events

### Example

```python
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
)
events = client.projects.webhook_endpoints.events.list(
    webhook_endpoint_id="webhookEndpointId",
    project_id="projectId",
)
print(events.items)
```

#### Response

```json
{
  "items": [
    {
      "id": "id",
      "endpointId": "endpointId",
      "status": "created",
      "type": "*",
      "updatedAt": "updatedAt"
    }
  ],
  "nextPaginationToken": "nextPaginationToken"
}
```

## Retrieve

`projects.webhook_endpoints.events.retrieve(strevent_id, EventRetrieveParams**kwargs)  -> EventRetrieveResponse`

**get** `/projects/{projectId}/webhook-endpoints/{webhookEndpointId}/events/{eventId}`

Retrieve one delivery event of one of the project's webhook endpoints

### Parameters

- `project_id: str`

- `webhook_endpoint_id: str`

- `event_id: str`

### Returns

- `class EventRetrieveResponse: …`

  - `webhook_event: WebhookEvent`

    - `id: str`

    - `attempts: List[WebhookEventAttempt]`

      - `response_status_code: float`

      - `sent_at: str`

    - `created_at: str`

    - `endpoint_id: str`

    - `payload: object`

    - `sent_at: str`

    - `status: Literal["created", "failed", "retrying", "success"]`

      - `"created"`

      - `"failed"`

      - `"retrying"`

      - `"success"`

    - `type: Literal["*", "asset.download.completed", "asset.download.created", 16 more]`

      Every event a webhook endpoint can subscribe to: a project endpoint takes the
      job lifecycle events, a team endpoint takes the alert events.

      - `"*"`

      - `"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"`

    - `updated_at: str`

### Example

```python
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
)
event = client.projects.webhook_endpoints.events.retrieve(
    event_id="eventId",
    project_id="projectId",
    webhook_endpoint_id="webhookEndpointId",
)
print(event.webhook_event)
```

#### Response

```json
{
  "webhookEvent": {
    "id": "id",
    "attempts": [
      {
        "responseStatusCode": 0,
        "sentAt": "sentAt"
      }
    ],
    "createdAt": "createdAt",
    "endpointId": "endpointId",
    "payload": {},
    "sentAt": "sentAt",
    "status": "created",
    "type": "*",
    "updatedAt": "updatedAt"
  }
}
```

## Domain Types

### Event List Response

- `class EventListResponse: …`

  - `items: List[Item]`

    A list of the project webhook events

    - `id: str`

    - `endpoint_id: str`

    - `status: Literal["created", "failed", "retrying", "success"]`

      - `"created"`

      - `"failed"`

      - `"retrying"`

      - `"success"`

    - `type: Literal["*", "asset.download.completed", "asset.download.created", 16 more]`

      Every event a webhook endpoint can subscribe to: a project endpoint takes the
      job lifecycle events, a team endpoint takes the alert events.

      - `"*"`

      - `"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"`

    - `updated_at: str`

  - `next_pagination_token: Optional[str]`

    A token to query the next page of events

### Event Retrieve Response

- `class EventRetrieveResponse: …`

  - `webhook_event: WebhookEvent`

    - `id: str`

    - `attempts: List[WebhookEventAttempt]`

      - `response_status_code: float`

      - `sent_at: str`

    - `created_at: str`

    - `endpoint_id: str`

    - `payload: object`

    - `sent_at: str`

    - `status: Literal["created", "failed", "retrying", "success"]`

      - `"created"`

      - `"failed"`

      - `"retrying"`

      - `"success"`

    - `type: Literal["*", "asset.download.completed", "asset.download.created", 16 more]`

      Every event a webhook endpoint can subscribe to: a project endpoint takes the
      job lifecycle events, a team endpoint takes the alert events.

      - `"*"`

      - `"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"`

    - `updated_at: str`
