# Update Webhook (PUT)

Update a webhook's name, message template, or activity status.

## Endpoint

```
PUT https://api.pocketalert.app/v1/webhooks/{tid}
```

## Authentication

> **Info: Required**
>
> Include one of these headers in your request:
> - `Token: <your-api-key>` — Get it from [API Keys](https://pocketalert.app/account/apikeys)
> - `Authorization: Bearer <jwt-token>` — From [Login](https://info.pocketalert.app/api/user/login.md)

## Request

### Path Parameters

| Parameter | Type | Required | Description |
|-----------|------|:--------:|-------------|
| `tid` | string | ✅ | Webhook unique identifier |

### Headers

| Header | Required | Description |
|--------|:--------:|-------------|
| `Token` | ✅ | Your API key |
| `Authorization` | ✅ | `Bearer <jwt-token>` |

### Body Parameters

| Parameter | Type | Required | Description |
|-----------|------|:--------:|-------------|
| `name` | string | ❌ | New name |
| `message` | string | ❌ | New message template |
| `is_active` | boolean | ❌ | Enable/Disable webhook |
| `application_id` | string | ❌ | New application TID |
| `device_id` | string | ❌ | New device TID |

> **Warning: Disabling a webhook**
>
> A webhook with `is_active: false` still accepts incoming requests and answers `200`, but no alert is created. Those calls are recorded in [Webhook History](https://info.pocketalert.app/api/webhooks/history.md) with `error_code: inactive`.

### Example Request

**cURL**

```bash
curl -X PUT "https://api.pocketalert.app/v1/webhooks/kblf7mh9j8jjyeh4fx" \
  -H "Token: your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "GitHub Push (Inactive)",
    "is_active": false
  }'
```

**JavaScript**

```javascript
const tid = 'kblf7mh9j8jjyeh4fx';
const response = await fetch(`https://api.pocketalert.app/v1/webhooks/${tid}`, {
  method: 'PUT',
  headers: {
    'Token': 'your-api-key',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    name: 'GitHub Push (Inactive)',
    is_active: false
  })
});
```

**Python**

```python
import requests

tid = 'kblf7mh9j8jjyeh4fx'
response = requests.put(
    f'https://api.pocketalert.app/v1/webhooks/{tid}',
    headers={'Token': 'your-api-key'},
    json={'name': 'GitHub Push (Inactive)', 'is_active': False}
)
print(response.json())
```

**PHP**

```php
$tid = 'kblf7mh9j8jjyeh4fx';
$response = Http::withHeaders([
    'Token' => 'your-api-key',
])->put('https://api.pocketalert.app/v1/webhooks/'.$tid, [
    'name' => 'GitHub Push (Inactive)',
    'is_active' => false,
]);

return $response->json();
```

## Response

### Success Response

> **Tip: 200 OK**
>
> Webhook updated successfully

```json
{
  "data": "success"
}
```

### Error Responses

| Status | Description |
|:------:|-------------|
| `401` | Unauthorized — Invalid or missing token |
| `404` | Not Found — Webhook does not exist |
