# Create

Launch stage: GA

`POST /api/2.0/mlflow/registry-webhooks/create`

**NOTE:** This endpoint is in Public Preview.
 Creates a registry webhook.

API scopes: mlflow

## Request body

- `model_name` (string, optional)
  If model name is not specified, a registry-wide webhook is created that listens for the specified events across all versions of all registered models.
  Example: `registered-model-1`
- `events` (array of string, optional)
  Events that can trigger a registry webhook:
   * `MODEL_VERSION_CREATED`: A new model version was created for the associated model.
   
   * `MODEL_VERSION_TRANSITIONED_STAGE`: A model version’s stage was changed.
   
   * `TRANSITION_REQUEST_CREATED`: A user requested a model version’s stage be transitioned.
   
   * `COMMENT_CREATED`: A user wrote a comment on a registered model.
   
   * `REGISTERED_MODEL_CREATED`: A new registered model was created. This event type can only be specified for a registry-wide webhook, which can be created by not specifying a model name in the create request.
   
   * `MODEL_VERSION_TAG_SET`: A user set a tag on the model version.
   
   * `MODEL_VERSION_TRANSITIONED_TO_STAGING`: A model version was transitioned to staging.
   
   * `MODEL_VERSION_TRANSITIONED_TO_PRODUCTION`: A model version was transitioned to production.
   
   * `MODEL_VERSION_TRANSITIONED_TO_ARCHIVED`: A model version was archived.
   
   * `TRANSITION_REQUEST_TO_STAGING_CREATED`: A user requested a model version be transitioned to staging.
   
   * `TRANSITION_REQUEST_TO_PRODUCTION_CREATED`: A user requested a model version be transitioned to production.
   
   * `TRANSITION_REQUEST_TO_ARCHIVED_CREATED`: A user requested a model version be archived.
  Possible values: `MODEL_VERSION_CREATED`, `MODEL_VERSION_TRANSITIONED_STAGE`, `TRANSITION_REQUEST_CREATED`, `COMMENT_CREATED`, `REGISTERED_MODEL_CREATED`, `MODEL_VERSION_TAG_SET`, `MODEL_VERSION_TRANSITIONED_TO_STAGING`, `MODEL_VERSION_TRANSITIONED_TO_PRODUCTION`, `MODEL_VERSION_TRANSITIONED_TO_ARCHIVED`, `TRANSITION_REQUEST_TO_STAGING_CREATED`, `TRANSITION_REQUEST_TO_PRODUCTION_CREATED`, `TRANSITION_REQUEST_TO_ARCHIVED_CREATED`
- `description` (string, optional)
  User-specified description for the webhook.
  Example: `Webhook for comment creation`
- `status` (string, optional)
  Enable or disable triggering the webhook, or put the webhook into test mode. The default is `ACTIVE`:
   * `ACTIVE`: Webhook is triggered when an associated event happens.
   
   * `DISABLED`: Webhook is not triggered.
   
   * `TEST_MODE`: Webhook can be triggered through the test endpoint, but is not triggered on a real event.
  Possible values: `ACTIVE`, `DISABLED`, `TEST_MODE`
  Default: `ACTIVE`
- `http_url_spec` (object, optional)
  External HTTPS URL called on event trigger (by using a POST request).
  - `url` (string, optional)
    External HTTPS URL called on event trigger (by using a POST request).
    Example: `https://hooks.slack.com/services/...`
  - `enable_ssl_verification` (boolean, optional)
    Enable/disable SSL certificate validation. Default is true. For self-signed certificates, this field must be false AND the destination server must disable certificate validation as well. For security purposes, it is encouraged to perform secret validation with the HMAC-encoded portion of the payload and acknowledge the risk associated with disabling hostname validation whereby it becomes more likely that requests can be maliciously routed to an unintended host.
    Default: `true`
  - `secret` (string, optional)
    Shared secret required for HMAC encoding payload. The HMAC-encoded payload will be sent in the header as: { "X-Databricks-Signature": $encoded_payload }.
    Example: `anyRandomString`
  - `authorization` (string, optional)
    Value of the authorization header that should be sent in the request sent by the wehbook. It should be of the form `"<auth type> <credentials>"`. If set to an empty string, no authorization header will be included in the request.
    Example: `Bearer <access_token>`
- `job_spec` (object, optional)
  ID of the job that the webhook runs.
  - `job_id` (string, optional)
    ID of the job that the webhook runs.
    Example: `1`
  - `workspace_url` (string, optional)
    URL of the workspace containing the job that this webhook runs. If not specified, the job’s workspace URL is assumed to be the same as the workspace where the webhook is created.
  - `access_token` (string, optional)
    The personal access token used to authorize webhook's job runs.

## Returns

- `webhook` (object, optional)
  - `id` (string, optional)
    Webhook ID
    Example: `124323`
  - `events` (array of string, optional)
    Events that can trigger a registry webhook:
     * `MODEL_VERSION_CREATED`: A new model version was created for the associated model.
     
     * `MODEL_VERSION_TRANSITIONED_STAGE`: A model version’s stage was changed.
     
     * `TRANSITION_REQUEST_CREATED`: A user requested a model version’s stage be transitioned.
     
     * `COMMENT_CREATED`: A user wrote a comment on a registered model.
     
     * `REGISTERED_MODEL_CREATED`: A new registered model was created. This event type can only be specified for a registry-wide webhook, which can be created by not specifying a model name in the create request.
     
     * `MODEL_VERSION_TAG_SET`: A user set a tag on the model version.
     
     * `MODEL_VERSION_TRANSITIONED_TO_STAGING`: A model version was transitioned to staging.
     
     * `MODEL_VERSION_TRANSITIONED_TO_PRODUCTION`: A model version was transitioned to production.
     
     * `MODEL_VERSION_TRANSITIONED_TO_ARCHIVED`: A model version was archived.
     
     * `TRANSITION_REQUEST_TO_STAGING_CREATED`: A user requested a model version be transitioned to staging.
     
     * `TRANSITION_REQUEST_TO_PRODUCTION_CREATED`: A user requested a model version be transitioned to production.
     
     * `TRANSITION_REQUEST_TO_ARCHIVED_CREATED`: A user requested a model version be archived.
    Possible values: `MODEL_VERSION_CREATED`, `MODEL_VERSION_TRANSITIONED_STAGE`, `TRANSITION_REQUEST_CREATED`, `COMMENT_CREATED`, `REGISTERED_MODEL_CREATED`, `MODEL_VERSION_TAG_SET`, `MODEL_VERSION_TRANSITIONED_TO_STAGING`, `MODEL_VERSION_TRANSITIONED_TO_PRODUCTION`, `MODEL_VERSION_TRANSITIONED_TO_ARCHIVED`, `TRANSITION_REQUEST_TO_STAGING_CREATED`, `TRANSITION_REQUEST_TO_PRODUCTION_CREATED`, `TRANSITION_REQUEST_TO_ARCHIVED_CREATED`
  - `creation_timestamp` (int64, optional)
    Creation time of the object, as a Unix timestamp in milliseconds.
    Example: `1594437249910`
  - `last_updated_timestamp` (int64, optional)
    Time of the object at last update, as a Unix timestamp in milliseconds.
    Example: `1594437549910`
  - `description` (string, optional)
    User-specified description for the webhook.
    Example: `Webhook for comment creation`
  - `status` (string, optional)
    Possible values: `ACTIVE`, `DISABLED`, `TEST_MODE`
  - `http_url_spec` (object, optional)
    - `url` (string, optional)
      External HTTPS URL called on event trigger (by using a POST request).
      Example: `https://hooks.slack.com/services/...`
    - `enable_ssl_verification` (boolean, optional)
      Enable/disable SSL certificate validation. Default is true. For self-signed certificates, this field must be false AND the destination server must disable certificate validation as well. For security purposes, it is encouraged to perform secret validation with the HMAC-encoded portion of the payload and acknowledge the risk associated with disabling hostname validation whereby it becomes more likely that requests can be maliciously routed to an unintended host.
      Default: `true`
    - `secret` (string, optional)
      Shared secret required for HMAC encoding payload. The HMAC-encoded payload will be sent in the header as: { "X-Databricks-Signature": $encoded_payload }.
      Example: `anyRandomString`
    - `authorization` (string, optional)
      Value of the authorization header that should be sent in the request sent by the wehbook. It should be of the form `"<auth type> <credentials>"`. If set to an empty string, no authorization header will be included in the request.
      Example: `Bearer <access_token>`
  - `job_spec` (object, optional)
    - `job_id` (string, optional)
      ID of the job that the webhook runs.
      Example: `1`
    - `workspace_url` (string, optional)
      URL of the workspace containing the job that this webhook runs. If not specified, the job’s workspace URL is assumed to be the same as the workspace where the webhook is created.
    - `access_token` (string, optional)
      The personal access token used to authorize webhook's job runs.
  - `model_name` (string, optional)
    Name of the model whose events would trigger this webhook.
    Example: `registered-model-1`

## Response

### HTTPRegistryWebhookExample

```json
{
  "webhook": {
    "creation_timestamp": 1594437249910,
    "description": "Webhook for comment creation",
    "events": [
      "MODEL_VERSION_CREATED",
      "MODEL_VERSION_TRANSITIONED_TO_STAGING",
      "COMMENT_CREATED"
    ],
    "http_url_spec": {
      "enable_ssl_verification": true,
      "url": "https://hooks.slack.com/services/..."
    },
    "id": "124323",
    "last_updated_timestamp": 1594437549910,
    "model_name": "registered-model-1",
    "status": "ACTIVE"
  }
}
```

### JobRegistryWebhookExample

```json
{
  "webhook": {
    "creation_timestamp": 1594437248910,
    "description": "Webhook for comment creation",
    "events": [
      "MODEL_VERSION_CREATED",
      "MODEL_VERSION_TRANSITIONED_TO_STAGING",
      "COMMENT_CREATED"
    ],
    "id": "126324",
    "job_spec": {
      "job_id": "1",
      "workspace_url": "http://.."
    },
    "last_updated_timestamp": 1594437549915,
    "model_name": "registered-model-1",
    "status": "ACTIVE"
  }
}
```

