Skip to content
Get started

Create

client.teams.webhookEndpoints.create(stringteamID, WebhookEndpointCreateParams { enabledEvents, url, description } body, RequestOptionsoptions?): WebhookEndpointCreateResponse { webhookEndpoint }
POST/teams/{teamId}/webhook-endpoints

Register a new webhook endpoint for the team, at most 10 of them. The response carries the secret, which is never returned again

ParametersExpand Collapse
teamID: string
body: WebhookEndpointCreateParams { enabledEvents, url, description }
enabledEvents: Array<"*" | "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: string

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

description?: string

A description of the webhook endpoint

ReturnsExpand Collapse
WebhookEndpointCreateResponse { webhookEndpoint }
webhookEndpoint: WebhookEndpoint { id, createdAt, enabled, 9 more }

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: string

The ID of the webhook endpoint

createdAt: string

The date and time the webhook endpoint was created

enabled: boolean

Whether the webhook is enabled

enabledEvents: Array<"*" | "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"
nbFailedCalls: number

The number of calls to the webhook endpoint that have failed

nbTotalCalls: number

The number of calls to the webhook endpoint

ownerId: string

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

ownerType: "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: string

The endpoint’s secret, used to generate webhook signatures

updatedAt: string

The date and time the webhook endpoint was updated

url: string

The URL of the webhook endpoint

description?: string

A description of the webhook endpoint

Create

import Scenario from '@scenario-labs/sdk';

const client = new Scenario({
  apiKey: process.env['SCENARIO_SDK_API_KEY'], // This is the default and can be omitted
  apiSecret: process.env['SCENARIO_SDK_API_SECRET'], // This is the default and can be omitted
});

const webhookEndpoint = await client.teams.webhookEndpoints.create('teamId', {
  enabledEvents: ['*'],
  url: 'url',
});

console.log(webhookEndpoint.webhookEndpoint);
{
  "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"
  }
}