# Create or Update Webhook Rule

put ` https://app.mk.io/api/v1/projects/:project_name/webhook/rules/:rule_name`

Create or Update Webhook Rule.

RBAC Capability Required: `webhooks.config.create` or `webhooks.config.update`

## Authentication

Authorization Bearer

Bearer authentication of the form `Bearer <token>`, where token is your
auth token.

## Path parameters

- **project_name**: string (Required)
- **rule_name**: string (Required)

## Request

This endpoint expects an object.

- **spec**: object [WebhookRuleSpecSchema](https://docs.mediakind.com/api-reference/management-api/schemas/webhookrulespecschema) (Required)
    
  Webhook rule spec.

- **authentication**: object [AuthenticationSchema](https://docs.mediakind.com/api-reference/management-api/schemas/authenticationschema) (Optional)
  
   Authentication details.  
  
  - **headers**: map from strings to string (Optional)
  
   Authentication headers.
   
  - **queryParams**: map from strings to string (Optional)
  
   Authentication query parameters.
  
- **enabled**: boolean (Required)

Indicates whether the webhook is enabled.
  
- **events**: list of enums (Required)
  
  List of events that trigger the webhook.
  
- **headers**: map from strings to string (Optional)
  
  Headers to include in the webhook request.
  
- **queryParams**: map from strings to string (Optional)
  
  Query parameters to include in the webhook request.
  
- **url**: string (Required)
  
  The URL the webhook should call.

## Response

### 200

Webhook Rule was updated

- **metadata**: object [WebhookRuleMetadataSchema](https://docs.mediakind.com/api-reference/management-api/schemas/webhookrulemetadataschema) (Required)
    
  Webhook rule metadata.
   
  - **id**: string (Required, format: uuid)
  
    The ID of the webhook.
   
  - **name**: string (Required)
  
    The name of the webhook. Unique within a project.

### 201

Webhook Rule was created

## Errors

### 400 Bad Request

- **error**: object [ErrorDetail](https://docs.mediakind.com/api-reference/management-api/schemas/errordetail) (Required)
    
  Pertinent information about the error
   
  - **code**: string (Required)
   
  - **detail**: string (Required)
   
  - **extraDetail**: map from strings to any (Optional)
   
  - **ref**: string (Required)
    
  - **status**: integer (Required)

### 401 Unauthorized

- **error**: object [ErrorDetail](https://docs.mediakind.com/api-reference/management-api/schemas/errordetail) (Required)
    
- **403 Forbidden**

- **404 Not Found**

- **429 Too Many Requests**

- **500 Internal Server Error**

all have similar structures as mentioned in 400 with appropriate codes and messages.
