> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://uploadcare.com/docs/llms.txt.

# Delete webhook

DELETE https://api.uploadcare.com/webhooks/unsubscribe/
Content-Type: application/x-www-form-urlencoded

Unsubscribe and delete a webhook.

Reference: https://uploadcare.com/docs/api/rest/webhook/unsubscribe

## Authentication

- `Authorization` header (required) — Every request made to `https://api.uploadcare.com/` MUST be signed. HTTPS SHOULD be used with any authorization scheme. Requests MUST contain the `Authorization` header defining `auth-scheme` and `auth-param`: `Authorization: auth-scheme auth-param`. Every request MUST contain the `Accept` header identifying the REST API version: `Accept: application/vnd.uploadcare-v0.7+json`. There are two available authorization schemes: * For production: `Uploadcare`, a scheme where a `signature`, not your Secret API Key MUST be specified. Signatures SHOULD be generated on backend. * For quick tests: `Uploadcare.Simple`, a simple scheme where your [Secret API Key](https://app.uploadcare.com/projects/-/api-keys/) MUST be specified in every request's `auth-param`.

## Request

### Headers

- `Accept` (string, required) — Version header.

### Body (application/x-www-form-urlencoded)

This endpoint expects an object.

- `target_url` (string, required) — A URL that is triggered by an event, for example, a file upload. A target URL MUST be unique for each `project` — `event type` combination.

## Response

### 204

Webhook successfully deleted.

## Errors

### 400 Bad Request Error

Simple HTTP Auth or webhook permission or endpoint errors.

- `WebhookUnsubscribeRequestBadRequestError`
  - simpleAuthHTTPForbidden: simpleAuthHTTPForbidden
  - cantUseWebhooksError: cantUseWebhooksError
  - webhookTargetUrlError: webhookTargetUrlError

### 401 Unauthorized Error

Authorization errors.

- `detail` (enum, optional)
  - Allowed values: `Incorrect authentication credentials.`, `Public key {public_key} not found.`, `Secret key not found.`, `Invalid signature. Please check your Secret key.`

### 406 Not Acceptable Error

Invalid version header `Accept` for this endpoint.

- `detail` (string, optional, default: Incorrect Accept header provided. Make sure to specify API version. Refer to REST API docs for details.)

### 429 Too Many Requests Error

Request was throttled.

- `detail` (string, optional)

## Types

### simpleAuthHTTPForbidden

- `detail` (string, optional, default: Simple authentication over HTTP is forbidden. Please, use HTTPS or signed requests instead.)

### cantUseWebhooksError

- `detail` (string, optional, default: You can't use webhooks)

### webhookTargetUrlError

- `detail` (string, optional, default: `target_url` is missing.) — `target_url` is missing.

## Examples

**Request**

```json
{
  "target_url": "http://example.com/hooks/receiver"
}
```

**SDK Code**

```javascript JS
import {
  deleteWebhook,
  UploadcareSimpleAuthSchema,
} from '@uploadcare/rest-client';

const uploadcareSimpleAuthSchema = new UploadcareSimpleAuthSchema({
  publicKey: 'YOUR_PUBLIC_KEY',
  secretKey: 'YOUR_SECRET_KEY',
});

const result = await deleteWebhook(
  {
    targetUrl: 'https://yourwebhook.com',
  },
  { authSchema: uploadcareSimpleAuthSchema }
)

```

```php PHP
<?php
$configuration = Uploadcare\Configuration::create((string) $_ENV['UPLOADCARE_PUBLIC_KEY'], (string) $_ENV['UPLOADCARE_SECRET_KEY']);

$api = (new Uploadcare\Api($configuration))->webhook();
$result = $api->deleteWebhook('https://yourwebhook.com');
echo $result ? 'Webhook has been deleted' : 'Webhook is not deleted, something went wrong';

```

```python Python
from pyuploadcare import Uploadcare, Webhook
uploadcare = Uploadcare(public_key='YOUR_PUBLIC_KEY', secret_key='YOUR_SECRET_KEY')

webhook_id = 1473151
uploadcare.delete_webhook(webhook_id)

```

```ruby Ruby
require 'uploadcare'
Uploadcare.config.public_key = 'YOUR_PUBLIC_KEY'
Uploadcare.config.secret_key = 'YOUR_SECRET_KEY'

puts Uploadcare::Webhook.delete('https://yourwebhook.com')

```

```swift Swift
import Uploadcare

let uploadcare = Uploadcare(withPublicKey: "YOUR_PUBLIC_KEY", secretKey: "YOUR_SECRET_KEY")

let url = URL(string: "https://yourwebhook.com")!
try await uploadcare.deleteWebhook(forTargetUrl: url)

```

```kotlin Kotlin
import com.uploadcare.android.library.api.UploadcareClient

val uploadcare = UploadcareClient(publicKey = "YOUR_PUBLIC_KEY", secretKey = "YOUR_SECRET_KEY")

val url = URI("https://yourwebhook.com")
uploadcare.deleteWebhook(url)

```

```go
package main

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

func main() {

	url := "https://api.uploadcare.com/webhooks/unsubscribe/"

	req, _ := http.NewRequest("DELETE", url, nil)

	req.Header.Add("Accept", "application/vnd.uploadcare-v0.7+json")
	req.Header.Add("Authorization", "<apiKey>")
	req.Header.Add("Content-Type", "application/x-www-form-urlencoded")

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

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

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.delete("https://api.uploadcare.com/webhooks/unsubscribe/")
  .header("Accept", "application/vnd.uploadcare-v0.7+json")
  .header("Authorization", "<apiKey>")
  .header("Content-Type", "application/x-www-form-urlencoded")
  .asString();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.uploadcare.com/webhooks/unsubscribe/");
var request = new RestRequest(Method.DELETE);
request.AddHeader("Accept", "application/vnd.uploadcare-v0.7+json");
request.AddHeader("Authorization", "<apiKey>");
request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
IRestResponse response = client.Execute(request);
```