## Update a webhook

### PUT /v0/webhooks/{id}

Try it

### cURL

```bash
curl --request PUT \
  --url https://demo-api.gable.ai/v0/webhooks/{id} \
  --header 'Content-Type: application/json' \
  --header 'X-API-KEY: <api-key>' \
  --data '
{
  "url": "<string>",
  "name": "<string>",
  "headers": {}
}
'```

### Python

```python
import requests

url = "https://demo-api.gable.ai/v0/webhooks/{id}"

payload = {
    "url": "<string>",
    "name": "<string>",
    "headers": {}
}
headers = {
    "X-API-KEY": "<api-key>",
    "Content-Type": "application/json"
}

response = requests.put(url, json=payload, headers=headers)

print(response.text)
```

### JavaScript (Fetch)

```javascript
const options = {
  method: 'PUT',
  headers: {'X-API-KEY': '<api-key>', 'Content-Type': 'application/json'},
  body: JSON.stringify({url: '<string>', name: '<string>', headers: {}})
};

fetch('https://demo-api.gable.ai/v0/webhooks/{id}', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
```

### PHP

```php
$curl = curl_init();

curl_setopt_array($curl, [\
  CURLOPT_URL => "https://demo-api.gable.ai/v0/webhooks/{id}",\
  CURLOPT_RETURNTRANSFER => true,\
  CURLOPT_ENCODING => "",\
  CURLOPT_MAXREDIRS => 10,\
  CURLOPT_TIMEOUT => 30,\
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,\
  CURLOPT_CUSTOMREQUEST => "PUT",\
  CURLOPT_POSTFIELDS => json_encode([\
    'url' => '<string>',\
    'name' => '<string>',\
    'headers' => [\
\
    ]\
  ]),\
  CURLOPT_HTTPHEADER => [\
    "Content-Type: application/json",\
    "X-API-KEY: <api-key>"\
  ],\
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
```

### Go

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

url := "https://demo-api.gable.ai/v0/webhooks/{id}"

payload := strings.NewReader("{\n  \"url\": \"<string>\",\n  \"name\": \"<string>\",\n  \"headers\": {}\n}")

req, _ := http.NewRequest("PUT", url, payload)

req.Header.Add("X-API-KEY", "<api-key>")
	req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))
}
```

### Java (Unirest)

```java
HttpResponse<String> response = Unirest.put("https://demo-api.gable.ai/v0/webhooks/{id}")
  .header("X-API-KEY", "<api-key>")
  .header("Content-Type", "application/json")
  .body("{\n  \"url\": \"<string>\",\n  \"name\": \"<string>\",\n  \"headers\": {}\n}")
  .asString();
```

### Ruby

```ruby
require 'uri'
require 'net/http'

url = URI("https://demo-api.gable.ai/v0/webhooks/{id}")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Put.new(url)
request["X-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"url\": \"<string>\",\n  \"name\": \"<string>\",\n  \"headers\": {}\n}"

response = http.request(request)
puts response.read_body
```

### Response Codes

- **200**: Webhook was successfully updated
- **404**: Not found
- **500**: Server error

### Response Body

#### Success Response
```json
{
  "id": "<string>",
  "url": "<string>",
  "name": "<string>",
  "headers": {}
}
```

#### Error Response
```json
{
  "message": "<string>",
  "id": 123,
  "title": "<string>"
}
```

### Authorizations

- **X-API-KEY**
  - Type: string
  - Location: header
  - Required: true

### Path Parameters

- **id**
  - Type: string (UUID)
  - Required: true
  - Description: The UUID of the webhook

### Body

- **url**
  - Type: string
  - Required: true
  - Description: The URL that the webhooks will be sent to
- **name**
  - Type: string
  - Required: true
  - Description: The webhook name
- **headers**
  - Type: object
  - Description: A map of headers
