Webhooks
https://api.byecap.org/api/v1/createTaskInstead of polling, ByeCap can POST a task's final result directly to your server. Account webhook endpoints configured in Dashboard → Webhooks can also subscribe to account events such as low balance alerts, completed deposits, refunds, and expiring API keys or quota packages.
Two Ways to Receive Webhooks
| Aspect | Per-Task Callback | Account Endpoint (Dashboard) |
|---|---|---|
| Setup | Pass webhook_url or callbackUrl inside POST /createTask. | Add an endpoint URL in Dashboard → Webhooks and toggle the events you want. |
| Events | That task's final result (task.solved / task.failed or flat getTaskResult payload). | task.solved, task.failed, plus account & billing events (balance.low, payment.*, key.expiring). |
| Signed With | Your account's default webhook signing secret. | The endpoint's dedicated secret (whsec_...). |
Per-Task Callbacks
Attach webhook_url (or callbackUrl for CapSolver/Anti-Captcha compatibility) when creating a task. Passing null or an empty string disables the callback. Invalid URLs are rejected immediately at task creation with zero charge.
curl -X POST https://api.byecap.org/api/v1/createTask \
-H "Content-Type: application/json" \
-d '{
"clientKey": "YOUR_API_KEY",
"callbackUrl": "https://api.myapp.io/webhooks/byecap",
"task": {
"type": "RecaptchaV2TaskProxyless",
"websiteURL": "https://example.com/login",
"websiteKey": "6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-"
}
}'Account Endpoints & Delivery History
Configure up to 10 webhook endpoints in Dashboard → Webhooks. Each endpoint has its own whsec_... signing secret, independent event subscriptions, and 1-click webhook.test delivery.
Delivery logs (HTTP status, latency, attempt count) are retained for 7 days. Any endpoint failing continuously for 24 hours is automatically paused and can be re-enabled from the Dashboard once healthy.
Webhook Events
Account events are only delivered to subscribed Dashboard endpoints—never to per-task callbackUrl receivers. Always ignore unrecognized event types and respond with 2xx so future event additions never break your handler.
| Event | Triggered When | data Payload |
|---|---|---|
| task.solved | A captcha task finished with a verified solution | Full task object identical to POST /getTaskResult (id, type, status, solution, cost) |
| task.failed | A task ended without a solution (100% auto-refunded) | Task object with status: "failed" and error details explaining the cause |
| balance.low | Wallet balance drops below your configured alert threshold | balance, threshold, currency |
| payment.succeeded | A wallet top-up (Bank QR, USDT, or Card) settles and credits your balance | id, amount, currency, created_at, credited_at (alias: deposit.completed) |
| payment.refunded | A top-up refund is completed | id, payment_id, amount, currency, refunded_at |
| payment.disputed | A payment dispute / chargeback is opened on a top-up | id, payment_id, amount, currency, opened_at |
| key.expiring | An API key with an expiration date expires within 7 days (or quota package within 48h) | id, name, prefix, last4, mode, expires_at (package alias: package.expiring) |
| webhook.test | You click "Send Test Event" on an endpoint in Dashboard → Webhooks | endpoint_id and test confirmation message |
Event Body Formats
{
"type": "task.solved",
"timestamp": "2026-12-05T08:00:07.456Z",
"data": {
"id": "7259140378796032",
"type": "RecaptchaV2TaskProxyless",
"status": "ready",
"solution": {
"gRecaptchaResponse": "03AFcWeA..."
},
"error": null,
"cost": { "amount": "0.000800", "currency": "USD" },
"created_at": "2026-12-05T08:00:01.120Z",
"completed_at": "2026-12-05T08:00:07.456Z"
}
}// balance.low
{
"type": "balance.low",
"timestamp": "2026-12-05T08:00:07.456Z",
"data": {
"balance": "4.500000",
"threshold": "5.000000",
"currency": "USD"
}
}
// payment.succeeded
{
"type": "payment.succeeded",
"timestamp": "2026-12-05T08:00:07.456Z",
"data": {
"id": "tp_3k9x0q2m8w1v7c5b4n6z",
"amount": "20.000000",
"currency": "USD",
"created_at": "2026-12-05T07:58:40.120Z",
"credited_at": "2026-12-05T08:00:07.456Z"
}
}Headers & Signature Verification
| Header | Description |
|---|---|
| webhook-id | Unique message ID. Remains identical across every retry and manual resend (e.g. msg_t7259140378796032, msg_t..._cb, msg_test_...). |
| webhook-timestamp | Unix timestamp in seconds when this delivery attempt was sent. |
| webhook-signature | One or more space-separated v1,<base64-signature> entries (multiple entries appear during secret rotation grace periods). |
| Content-Type | application/json |
- Read the raw request body bytes before parsing JSON—never re-serialize.
- Build the signed string:
<webhook-id>.<webhook-timestamp>.<raw body>. - Strip the
whsec_prefix from your secret and Base64-decode it to get the signing key. - Compute
base64(HMAC-SHA256(key, signed))and compare in constant time against everyv1,<sig>entry inwebhook-signature. - Reject requests whose
webhook-timestampdrifts more than 5 minutes (300s) from your server clock to prevent replay attacks.
whsec_... secrets to source control. After rotating a secret in the Dashboard, both the new and previous secrets sign requests for 24 hours so you can roll out the updated secret without dropping events.import base64, hashlib, hmac, time
def verify_webhook(secret: str, headers: dict, raw_body: bytes, tolerance: int = 300) -> bool:
"""secret: "whsec_..."; headers: lower-cased header dict; raw_body: raw request bytes."""
msg_id = headers.get("webhook-id", "")
timestamp = headers.get("webhook-timestamp", "")
try:
if abs(time.time() - int(timestamp)) > tolerance:
return False
except ValueError:
return False
key = base64.b64decode(secret.removeprefix("whsec_"))
signed = f"{msg_id}.{timestamp}.".encode("utf-8") + raw_body
expected = base64.b64encode(hmac.new(key, signed, hashlib.sha256).digest()).decode("ascii")
for entry in headers.get("webhook-signature", "").split():
version, _, sig = entry.partition(",")
if version == "v1" and hmac.compare_digest(sig.encode(), expected.encode()):
return True
return False- Any 2xx HTTP status within 5 seconds acknowledges delivery; redirects are not followed.
- Task events retry at
5s, 25s, 60s, 150s, 300s(±10%) up to the 10-minute result retention window. - Account events retry up to 8 times over 24 hours (
5s, 5m, 30m, 1h, 2h, 4h, 8h, 8h). - Deliveries are at-least-once and may arrive out of order: deduplicate on
webhook-idand make handlers idempotent ondata.id.
- Scheme must be
https(recommended) orhttpon ports80, 443, 8080, 8443. - Maximum length 2,048 bytes; embedded credentials (
user:pass@) and#fragmentsare rejected. - Host must resolve strictly to public IP addresses—private, loopback (
127.0.0.1), and link-local ranges are blocked at both creation and delivery time. - The legacy 2Captcha
pingbackfield is not supported—usewebhook_urlorcallbackUrl.