# Delete a webhook

Removes the webhook of the account. Jobs created before keep sending their events to it; new jobs do not.

`DELETE https://api.switchfile.io/v2/webhooks/{id}`

Needs an API key: `Authorization: Bearer YOUR_API_KEY`. See [Authentication](https://switchfile.io/docs/authentication).

## Example

cURL:

```bash
curl -X DELETE "https://api.switchfile.io/v2/webhooks/1a7e3c5b-9d2f-4b6a-8e0c-5f3d1b7a9c24" \
  -H "Authorization: Bearer $SWITCHFILE_API_KEY"
```

Node.js:

```js
const res = await fetch("https://api.switchfile.io/v2/webhooks/1a7e3c5b-9d2f-4b6a-8e0c-5f3d1b7a9c24", {
  method: "DELETE",
  headers: {
    Authorization: `Bearer ${process.env.SWITCHFILE_API_KEY}`,
  },
});
if (!res.ok) throw new Error(`HTTP ${res.status}: ${await res.text()}`);
console.log(res.status);
```

PHP:

```php
<?php
$ch = curl_init('https://api.switchfile.io/v2/webhooks/1a7e3c5b-9d2f-4b6a-8e0c-5f3d1b7a9c24');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'DELETE',
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('SWITCHFILE_API_KEY'),
    ],
    CURLOPT_RETURNTRANSFER => true,
]);
$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
curl_close($ch);

if ($status >= 400) {
    throw new RuntimeException("HTTP $status: $response");
}
echo $status, PHP_EOL;
```

Python:

```python
import os
import requests

res = requests.delete(
    "https://api.switchfile.io/v2/webhooks/1a7e3c5b-9d2f-4b6a-8e0c-5f3d1b7a9c24",
    headers={"Authorization": f"Bearer {os.environ['SWITCHFILE_API_KEY']}"},
)
res.raise_for_status()
print(res.status_code)
```

## Parameters

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string (uuid) | yes | ID of the webhook |

## Responses

### 204: Deleted

### 401: The API key is missing or not valid (`UNAUTHENTICATED`)

Example (application/json):

```json
{
  "message": "Missing or invalid API key.",
  "code": "UNAUTHENTICATED"
}
```

### 404: Does not exist for this account (`NOT_FOUND`)

Example (application/json):

```json
{
  "message": "Webhook not found.",
  "code": "NOT_FOUND"
}
```

### 411: The request has a body but no Content-Length header (`LENGTH_REQUIRED`)

Example (application/json):

```json
{
  "message": "A Content-Length header is required for this request.",
  "code": "LENGTH_REQUIRED"
}
```

### 413: The request or the file is too large (`PAYLOAD_TOO_LARGE`)

Example (application/json):

```json
{
  "message": "The request body is larger than the allowed maximum.",
  "code": "PAYLOAD_TOO_LARGE"
}
```

### 422: Invalid data. errors names the fields (`INVALID_DATA`)

Example (application/json):

```json
{
  "message": "id: Expected string to match 'uuid' format",
  "code": "INVALID_DATA",
  "errors": {
    "id": [
      "Expected string to match 'uuid' format"
    ]
  }
}
```

### 429: Too many requests or a daily quota is used up. See Retry-After (`RATE_LIMIT_EXCEEDED`)

Example (application/json):

```json
{
  "message": "Too many requests. Try again in 12 seconds.",
  "code": "RATE_LIMIT_EXCEEDED"
}
```

Error bodies and codes are explained in [Errors](https://switchfile.io/docs/errors).
