Webhooks
Instead of asking for results, let them come to you. Give a job a webhook and we send each result, or the finished job, to your server as an HTTPS POST – signed, so you know it is from us, and retried until your server confirms it.
Set it up
Add webhook when you create a job:
{
"requests": [
"…"
],
"webhook": {
"url": "https://example.com/hooks/virginproxy",
"events": [
"item",
"done"
]
}
}| Field | Meaning |
|---|---|
url | A public https:// address. Addresses in private networks are refused with invalid_webhook. |
events | item: one call per finished request. done: one call when the whole job is done. Default ["done"]. |
Events
job.item
Sent once per item when it succeeded or failed. response is exactly what POST /v1/requests would have returned, echo included; on failure there is error instead.
{
"id": "evt_3nR8wQ2kXp5mLz7cTe1B",
"type": "job.item",
"job_id": "job_8fK2pQ7wLz3nVd0sXa4T",
"index": 0,
"status": "succeeded",
"response": {
"id": "req_Qm4tY8bN2xLs0Pd7Wk3e",
"status": 200,
"extracted": { "price": 129 },
"echo": { "sku": "TR-1" },
"…": "…"
}
}job.done
Sent once when the job is done or canceled, with its final state as in GET /v1/jobs/{id}.
{
"id": "evt_9bT4yH6vNc1sQd8eRw2M",
"type": "job.done",
"job": {
"id": "job_8fK2pQ7wLz3nVd0sXa4T",
"status": "done",
"total": 3,
"succeeded": 2,
"failed": 1,
"canceled": 0,
"pending": 0,
"credits": 2,
"…": "…"
}
}Headers
| Header | Meaning |
|---|---|
X-VP-Signature | t=<unix time>,v1=<signature>; during a secret rotation with a grace period a second v1 follows. See below. |
X-VP-Event | job.item or job.done. |
X-VP-Delivery | The id of this event, evt_…, the same as id in the body. It stays the same across retries: use it to ignore duplicates. |
User-Agent | VirginProxy-Webhooks/1. |
Deliveries come from changing addresses. Do not allow them by IP address; check the signature instead.
Verify the signature
Every account has a webhook secret starting with whsec_. You find it in the dashboard under API keys → Webhooks, where you can also renew it. The signature is the hex HMAC-SHA256 of t + "." + body with that secret, where body is the raw request body exactly as received.
- Split
X-VP-Signatureintotand thev1values – one, or two while a secret rotation runs. - Reject the call if
tis more than 5 minutes away from your clock: that stops replays of old calls. - Compute the HMAC over the raw body – before any JSON parsing – and compare it with each
v1in constant time. Accept the call when one matches.
import crypto from "node:crypto";
import http from "node:http";
const SECRET = process.env.VP_WEBHOOK_SECRET; // whsec_… from the dashboard
function verify(header, rawBody) {
const pairs = header.split(",").map((p) => p.split("="));
const t = pairs.find(([k]) => k === "t")?.[1];
// One v1, or two while a secret rotation's grace period runs: any one may match.
const signatures = pairs.filter(([k]) => k === "v1").map(([, v]) => v);
const age = Math.abs(Date.now() / 1000 - Number(t));
if (!t || !signatures.length || age > 300) return false; // older than 5 minutes
const expected = Buffer.from(crypto.createHmac("sha256", SECRET)
.update(t + "." + rawBody).digest("hex"));
return signatures.some((sig) => {
const b = Buffer.from(sig);
return b.length === expected.length && crypto.timingSafeEqual(expected, b);
});
}
http.createServer((req, res) => {
let raw = "";
req.on("data", (chunk) => (raw += chunk));
req.on("end", () => {
if (!verify(req.headers["x-vp-signature"] || "", raw)) {
res.writeHead(400).end();
return;
}
const event = JSON.parse(raw);
res.writeHead(200).end(); // answer fast, work afterwards
if (event.type === "job.item") console.log(event.index, event.status);
if (event.type === "job.done") console.log("job finished", event.job.id);
});
}).listen(8080);import hashlib, hmac, json, os, time
from flask import Flask, request, abort
SECRET = os.environ["VP_WEBHOOK_SECRET"].encode() # whsec_… from the dashboard
app = Flask(__name__)
def verify(header, raw_body):
pairs = [p.split("=", 1) for p in header.split(",") if "=" in p]
t = next((v for k, v in pairs if k == "t"), None)
# One v1, or two while a secret rotation's grace period runs: any one may match.
signatures = [v for k, v in pairs if k == "v1"]
if not t or not signatures or abs(time.time() - int(t)) > 300: # older than 5 minutes
return False
expected = hmac.new(SECRET, t.encode() + b"." + raw_body, hashlib.sha256).hexdigest()
return any(hmac.compare_digest(expected, sig) for sig in signatures)
@app.post("/hooks/virginproxy")
def hook():
if not verify(request.headers.get("X-VP-Signature", ""), request.get_data()):
abort(400)
event = json.loads(request.get_data())
if event["type"] == "job.item":
print(event["index"], event["status"])
elif event["type"] == "job.done":
print("job finished", event["job"]["id"])
return "", 200Warning
Compute the signature over the bytes you received. Parsing the JSON and serialising it again changes spaces and order, and the signature no longer matches.
Check a signature here
While you build your receiver, paste a delivery from your logs or the delivery log: the secret, the X-VP-Signature header and the raw body. The check runs locally in your browser with the Web Crypto API – nothing is sent anywhere, and the secret is not stored.
Runs locally, nothing is sent. A textarea turns line breaks into \n: a body with \r\n or trailing spaces may not match here although your server sees the right bytes.
Retries
A delivery counts as successful when your server answers with any 2xx status within 10 seconds. Otherwise we try again, up to 6 attempts in total:
| Attempt | When |
|---|---|
| 1 | Right away |
| 2 | 10 seconds later |
| 3 | 1 minute later |
| 4 | 5 minutes later |
| 5 | 30 minutes later |
| 6 | 2 hours later |
Tip
Answer with 200 first and do the work afterwards, for example in a queue. A slow handler turns into timeouts and repeated deliveries.
Secret, deliveries and a test delivery through the API
Everything the dashboard shows about webhooks is also available to your own tools. These calls need a live key without its own credit limit and with the manage permission (see Manage keys through the API).
| Call | What it does |
|---|---|
GET /v1/webhooks | Your webhook secret (whsec_…) and the latest deliveries with status, response code and attempts (?limit=1..100). |
POST /v1/webhooks/secret | Makes a new secret. {"grace": "now" | "1h" | "24h" | "7d"}: with now (the default) the old one stops verifying at once; with a grace period deliveries carry a second signature made with the previous secret until previous_until. See Change the secret without downtime. |
GET /v1/webhooks/deliveries | Deliveries of the last 7 days, newest first, filtered by status, event (job.item, job.done, alert or one alert.… event) and job, page by page with before = the next of the previous page. |
GET /v1/webhooks/deliveries/{id} | One delivery: its body while it is kept (72 hours after the last attempt) and every attempt with time, duration, status code or error, the headers we sent and the start of your server's answer (at most 2 KB). |
POST /v1/webhooks/test | Sends one signed sample event to your URL now and answers with the outcome. event is webhook.test, job.done, job.item (default webhook.test). |
POST /v1/webhooks/deliveries/{id}/redeliver | Sends a finished delivery again (same id and body, current secret), up to 72 hours after its last attempt. See Send a delivery again. |
curl https://api.virginproxy.com/v1/webhooks/test \
-H "Authorization: Bearer $VP_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://example.com/hooks/virginproxy",
"event": "job.done"
}'import os, requests
r = requests.post(
"https://api.virginproxy.com/v1/webhooks/test",
headers={"Authorization": "Bearer " + os.environ["VP_KEY"]},
json={
"url": "https://example.com/hooks/virginproxy",
"event": "job.done",
},
timeout=30,
)
data = r.json()
if not r.ok:
raise SystemExit(data["error"]["code"] + ": " + data["error"]["message"])
print(data["delivered"], data["status_code"])const res = await fetch("https://api.virginproxy.com/v1/webhooks/test", {
method: "POST",
headers: { Authorization: "Bearer " + process.env.VP_KEY, "Content-Type": "application/json" },
body: JSON.stringify({
url: "https://example.com/hooks/virginproxy",
event: "job.done",
}),
signal: AbortSignal.timeout(30_000),
});
const data = await res.json();
if (!res.ok) throw new Error(data.error.code + ": " + data.error.message);
console.log(data.delivered, data.status_code);from virginproxy import VirginProxy # docs.virginproxy.com/sdk/virginproxy.py
vp = VirginProxy() # reads VP_KEY
data = vp.call("POST", "/v1/webhooks/test", {
"url": "https://example.com/hooks/virginproxy",
"event": "job.done",
})
print(data)import { VirginProxy } from "./virginproxy.mjs"; // docs.virginproxy.com/sdk/virginproxy.mjs
const vp = new VirginProxy(); // reads VP_KEY
const data = await vp.call("POST", "/v1/webhooks/test", { body: {
url: "https://example.com/hooks/virginproxy",
event: "job.done",
} });
console.log(data);<?php
$ch = curl_init("https://api.virginproxy.com/v1/webhooks/test");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer " . getenv("VP_KEY"),
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode([
"url" => "https://example.com/hooks/virginproxy",
"event" => "job.done",
], JSON_UNESCAPED_SLASHES),
]);
$data = json_decode(curl_exec($ch), true);
if (isset($data["error"])) {
exit($data["error"]["code"] . ": " . $data["error"]["message"] . PHP_EOL);
}
echo $data["delivered"], " ", $data["status_code"], PHP_EOL;package main
import (
"bytes"
"encoding/json"
"fmt"
"log"
"net/http"
"os"
"time"
)
func main() {
payload := []byte(`{
"url": "https://example.com/hooks/virginproxy",
"event": "job.done"
}`)
req, err := http.NewRequest("POST", "https://api.virginproxy.com/v1/webhooks/test", bytes.NewReader(payload))
if err != nil {
log.Fatal(err)
}
req.Header.Set("Authorization", "Bearer "+os.Getenv("VP_KEY"))
req.Header.Set("Content-Type", "application/json")
client := &http.Client{Timeout: 30 * time.Second}
res, err := client.Do(req)
if err != nil {
log.Fatal(err)
}
defer res.Body.Close()
var data map[string]any
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
log.Fatal(err)
}
if res.StatusCode >= 300 {
e := data["error"].(map[string]any)
log.Fatalf("%v: %v", e["code"], e["message"])
}
fmt.Println(data["delivered"], data["status_code"])
}require "json"
require "net/http"
uri = URI("https://api.virginproxy.com/v1/webhooks/test")
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer " + ENV.fetch("VP_KEY")
req["Content-Type"] = "application/json"
req.body = JSON.generate({
"url" => "https://example.com/hooks/virginproxy",
"event" => "job.done",
})
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true, read_timeout: 30) { |http| http.request(req) }
data = JSON.parse(res.body)
abort(data["error"]["code"] + ": " + data["error"]["message"]) unless res.is_a?(Net::HTTPSuccess)
puts [data["delivered"], data["status_code"]].join(" ")import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;
public class Main {
public static void main(String[] args) throws Exception {
String payload = """
{
"url": "https://example.com/hooks/virginproxy",
"event": "job.done"
}
""";
HttpRequest req = HttpRequest.newBuilder(URI.create("https://api.virginproxy.com/v1/webhooks/test"))
.header("Authorization", "Bearer " + System.getenv("VP_KEY"))
.header("Content-Type", "application/json")
.timeout(Duration.ofSeconds(30))
.POST(HttpRequest.BodyPublishers.ofString(payload))
.build();
HttpResponse<String> res = HttpClient.newHttpClient().send(req, HttpResponse.BodyHandlers.ofString());
if (res.statusCode() >= 300) {
System.err.println(res.statusCode() + " " + res.body()); // the error object: code, message
System.exit(1);
}
System.out.println(res.body()); // JSON: read it with the JSON library of your choice
}
}using System.Net.Http.Headers;
using System.Text;
using System.Text.Json;
using var http = new HttpClient { Timeout = TimeSpan.FromSeconds(30) };
http.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("VP_KEY"));
var payload = """
{
"url": "https://example.com/hooks/virginproxy",
"event": "job.done"
}
""";
var req = new HttpRequestMessage(HttpMethod.Post, "https://api.virginproxy.com/v1/webhooks/test");
req.Content = new StringContent(payload, Encoding.UTF8, "application/json");
var res = await http.SendAsync(req);
using var data = JsonDocument.Parse(await res.Content.ReadAsStringAsync());
if (!res.IsSuccessStatusCode)
{
var e = data.RootElement.GetProperty("error");
Console.Error.WriteLine(e.GetProperty("code") + ": " + e.GetProperty("message"));
Environment.Exit(1);
}
Console.WriteLine(data.RootElement.GetProperty("delivered") + " " + data.RootElement.GetProperty("status_code"));/v1/webhooks/test{
"id": "evt_6TqL2mXv9KpR0sNc4WbY",
"event": "job.done",
"url": "https://example.com/hooks/virginproxy",
"delivered": true,
"status_code": 200,
"duration_ms": 184
}The test body carries "test": true and is signed exactly like a real delivery, so it checks your signature code too. It is not stored and not retried. Up to 10 test deliveries per minute.
Change the secret without downtime
Rotate the secret with a grace period – in the dashboard or with POST /v1/webhooks/secret and {"grace": "24h"}. Until it ends, every delivery carries two signatures in one header, the new secret's first:
X-VP-Signature: t=1795400000,v1=5f2b…(new secret),v1=9ac4…(previous secret)Your receiver accepts the call when any v1 matches the secret it holds. So: rotate with a grace period, put the new secret into your receiver whenever it suits you within that time, done. Receivers that still hold the previous secret keep working until the grace period ends. The official SDKs and the examples on this page check every v1; if your own code accepts only one signature, update it before you rotate with a grace period. Without a grace period there is only one v1, as before. A second rotation during a grace period drops the oldest secret.
The delivery log
Each attempt is logged with its time, duration, status code or error, the headers we sent (the signature, never the secret) and at most the first 2 KB of your server's answer – useful to see why a delivery failed. The log keeps deliveries for 7 days; their content 72 hours after the last attempt. In the dashboard you can filter it by status, event and job, open one delivery with its attempts, send it again and download the filtered list as CSV.
Delivery log
Every delivery is logged for 7 days with its status, your server's response code and the number of attempts. You find it on each job in the dashboard's Jobs page and under API keys › Webhooks. A webhook that never arrived does not lose data: the results stay available through GET /v1/jobs/{id}/results for 24 hours.
Send a delivery again
The content of a delivery is kept for 72 hours after its last attempt, compressed, and then deleted; the log line itself stays for the 7 days. Within those 72 hours a delivery that was delivered or given up can be sent again: with Redeliver in the dashboard, or with POST /v1/webhooks/deliveries/{id}/redeliver. It goes out with the same id and body (so your server can recognise a repeat), signed with the current secret, and gets the full retry schedule again. A delivery that is still being retried answers delivery_pending (409); an older one answers delivery_expired (410).
The dashboard's Send test button under API keys › Webhooks sends a signed sample event to a URL you enter and shows your server's answer at once, like POST /v1/webhooks/test.
Account alerts
Besides job results, your account can send its alerts to a webhook: set an https address under Settings › Alerts. Each alert is one POST, signed with the same secret and the same X-VP-Signature header as job webhooks, retried on the same schedule, listed in the delivery log (with job_id null) and redeliverable for 72 hours. The address is checked like a job webhook's: https only, a public address, no credentials. Send test next to it sends alert.test at once.
| Event | When | data |
|---|---|---|
alert.credits_threshold | One of your credit thresholds was passed (once per period). | pct, used, total |
alert.credits_runway | At the pace of the last 7 days the credits run out within the days you chose. | days, empty_at, left, per_day |
alert.daily_cap | The daily cap of the account or the daily limit of a key was reached. | scope, cap, key, name |
alert.error_rate | Your error-rate alert started (at most once an hour). | share, rate, failed, total, window_minutes, http_counted |
alert.error_rate_recovered | It is over: the share fell under half of your threshold. | share, total, window_minutes |
alert.security | A new browser signed in, two-step sign-in was turned off, the password was changed, a key was made or revoked through the API, an app was connected. | kind, device, ip (last part left out), name |
{
"id": "evt_…",
"type": "alert.error_rate",
"created_at": "2026-11-23T10:15:00.000Z",
"data": { "share": 35, "rate": 30, "failed": 14, "total": 40, "window_minutes": 10, "http_counted": false }
}
Slack: a Slack incoming webhook only takes its own body shape. Tick Slack format and each alert is sent as {"text": "…"} – one line in your account language with a link to the dashboard – instead of the body above.
Was this page helpful?
Last updated