Unsubscribe from a webhook
This is a V1 legacy endpoint. It uses a different path /rest/v1 and may return different error codes and response formats compared to V2. While it remains functional, consider handling errors accordingly.
Use this endpoint to stop receiving webhook notifications for a specific event and target URL.
Unsubscribing deletes any events still queued for the subscription. If your target URL has been unavailable or you may have a large queue of pending events, set safe to true. This checks for queued events and keeps the subscription active if any are found.
Woodpecker retries failed webhook deliveries. See webhook error handling for details.
Request
Endpoint
POST https://api.woodpecker.co/rest/v1/webhooks/unsubscribe
Headers
x-api-key: {YOUR_API_KEY}
Content-type: application/json
For details on how to authenticate your requests, please see the authentication guide.
Body
Specify both target_url and event. The request selects every subscription for that URL that includes the event. Removing a subscription that covers multiple events stops delivery for all of them.
{
"target_url": "https://receiving-url.com/unique_target_url",
"event": "EVENT_NAME",
"safe": true
}
Body schema
| Field | Type | Required | Description |
|---|---|---|---|
target_url | string | Yes | Webhook URL as registered in the subscription |
event | string | Yes | Available event, matched case-insensitively |
safe | boolean | No | When true, checks the selected subscriptions for queued events before removing them. Defaults to false |
Request samples
Unsubscribe from a webhook
These examples check for queued events before unsubscribing.
- cURL
- Python
- Java
- Node.js
- PHP
curl --request POST \
--url "https://api.woodpecker.co/rest/v1/webhooks/unsubscribe" \
--header "Content-Type: application/json" \
--header "x-api-key: {YOUR_API_KEY}" \
--data '{
"target_url": "https://receiving-url.com/unique_target_url",
"event": "EVENT_NAME",
"safe": true
}'
import requests
def unsubscribe_webhook():
url = "https://api.woodpecker.co/rest/v1/webhooks/unsubscribe"
headers = {
"Content-Type": "application/json",
"x-api-key": "{YOUR_API_KEY}"
}
payload = {
"target_url": "https://receiving-url.com/unique_target_url",
"event": "EVENT_NAME",
"safe": True
}
response = requests.post(url, headers=headers, json=payload)
if response.status_code == 200:
return "Successfully unsubscribed"
else:
raise Exception(f"POST request failed: {response.status_code}, {response.text}")
if __name__ == "__main__":
try:
data = unsubscribe_webhook()
print("POST response:", data)
except Exception as e:
print("Error:", e)
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class WoodpeckerApiClient {
private static final String API_KEY = "{YOUR_API_KEY}";
private static final String URL = "https://api.woodpecker.co/rest/v1/webhooks/unsubscribe";
public static void main(String[] args) {
try {
HttpClient client = HttpClient.newHttpClient();
String jsonPayload = "{\"target_url\": \"https://receiving-url.com/unique_target_url\", \"event\": \"EVENT_NAME\", \"safe\": true}";
HttpRequest request = HttpRequest.newBuilder()
.uri(new URI(URL))
.header("Content-Type", "application/json")
.header("x-api-key", API_KEY)
.POST(HttpRequest.BodyPublishers.ofString(jsonPayload))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() == 200) {
System.out.println("POST response: " + response.body());
} else {
System.err.println("POST request failed: " + response.statusCode());
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
const axios = require('axios');
async function unsubscribeWebhook() {
const url = 'https://api.woodpecker.co/rest/v1/webhooks/unsubscribe';
const headers = {
'Content-Type': 'application/json',
'x-api-key': '{YOUR_API_KEY}'
};
const data = {
"target_url": "https://receiving-url.com/unique_target_url",
"event": "EVENT_NAME",
"safe": true
};
try {
const response = await axios.post(url, data, { headers });
console.log('POST response:', response.data);
} catch (error) {
console.error('POST request failed:', error.response ? error.response.status : error.message);
}
}
unsubscribeWebhook();
<?php
require 'vendor/autoload.php';
use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;
$client = new Client([
'base_uri' => 'https://api.woodpecker.co/rest/v1/',
'headers' => [
'x-api-key' => getenv('WOODPECKER_API_KEY'),
'Content-Type' => 'application/json',
],
]);
try {
$response = $client->post('webhooks/unsubscribe', [
'json' => [
'target_url' => 'https://receiving-url.com/unique_target_url',
'event' => 'EVENT_NAME',
'safe' => true,
],
]);
echo $response->getStatusCode(), "\n";
echo $response->getBody(), "\n";
} catch (RequestException $e) {
echo "Error: ", $e->getMessage(), "\n";
if ($e->hasResponse()) {
echo $e->getResponse()->getBody(), "\n";
}
}
Response
Response examples
- 200
- 204
- 400
- 401
- 404
- 409
- 422
- 500
The request removed the matching subscriptions.
Body: empty
No subscription matched the request, or the supplied event name was unrecognized.
Body: empty
Check that the request body is a JSON object and includes target_url as a string.
{
"status": {
"status": "ERROR",
"code": "E_WRONG_PARAM",
"msg": "Invalid target_url."
}
}
Body schema
| Field | Type | Description |
|---|---|---|
status | object | Contains error details |
└─status | string | Overall status, set to ERROR |
└─code | string |
|
└─msg | string | Error description |
The API key is missing or invalid. Review the authentication guide.
{
"status": {
"status": "ERROR",
"code": "E_SESSION",
"msg": "The API key you've entered is incorrect or no longer valid. Check if you pasted the key correctly. You can generate a new key in Woodpecker: Settings -> API Keys."
}
}
Body schema
| Field | Type | Description |
|---|---|---|
status | object | Contains error details |
└─status | string | Overall status, set to ERROR |
└─code | string | Error category |
└─msg | string | Error description |
The request URL does not match an endpoint. Check the endpoint path.
{
"status": {
"status": "ERROR",
"code": "E_URL_NOT_FOUND",
"msg": "URL not found: /rest/v1/webhooks/unknown"
}
}
Body schema
| Field | Type | Description |
|---|---|---|
status | object | Contains error details |
└─status | string | Overall status, set to ERROR |
└─code | string | Error category |
└─msg | string | Error description |
Too many concurrent requests. Retry the request later.
{
"status": {
"status": "ERROR",
"code": "E_TOO_MANY_REQUESTS",
"msg": "Too many requests in one time"
}
}
Body schema
| Field | Type | Description |
|---|---|---|
status | object | Contains error details |
└─status | string | Overall status, set to ERROR |
└─code | string | Error category |
└─msg | string | Error description |
With safe: true, queued events prevent removal. The subscription remains active. Retry after the queued events have been processed.
{
"status": {
"status": "ERROR",
"code": "E_INV_STATUS",
"msg": "Webhook cannot be removed while events are queued"
},
"queued_events_count": 12
}
Body schema
| Field | Type | Description |
|---|---|---|
status | object | Contains error details |
└─status | string | Overall status, set to ERROR |
└─code | string | Error category |
└─msg | string | Error description |
queued_events_count | integer | Number of queued events across the selected subscriptions, including other events they cover |
An unexpected server error occurred. The code and message can vary.
{
"status": {
"status": "ERROR",
"code": "E_UNNOWN",
"msg": "Unknown error."
}
}
Body schema
| Field | Type | Description |
|---|---|---|
status | object | Contains error details |
└─status | string | Overall status, set to ERROR |
└─code | string | Error category |
└─msg | string | Error description |