Job webhooks
Pass a webhook URL with /run and Apipods will POST the finished job to it as soon as it reaches a terminal state, so you never have to poll.
Add a webhook to a job
curl -X POST https://run.apipods.com/v1/ep_4n8wq2zt/run \
-H "Authorization: Bearer $APIPODS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"input": {
"prompt": "a lighthouse on a cliff at dusk, 35mm photo",
"steps": 4
},
"webhook": "https://api.example.com/hooks/apipods"
}'The URL must be HTTPS and publicly reachable. These are per-job webhooks; for account-wide events such as pod.exited or job.failed across all endpoints, use webhook subscriptions.
Payload
The body is the job object, identical to what /status returns, sent for COMPLETED, FAILED, CANCELLED and TIMED_OUT.
POST /hooks/apipods HTTP/1.1
Content-Type: application/json
User-Agent: Apipods-Webhooks/1.0
Apipods-Signature: t=1763460136,v1=5f1c0d3c9a6b2e8f47d1a0c3b9e2f6a8d4c7b1e0f3a2d5c8b7e6f9a1c4d2b8e0
{
"id": "job_3x9wq2mt",
"status": "COMPLETED",
"delayTime": 812,
"executionTime": 1934,
"workerId": "wrk_8q3m2x9k",
"output": {
"imageUrl": "https://s3.eu-nl-1.apipods.com/vol_c7d2h4ke/outputs/job_3x9wq2mt.png",
"seed": 1730299
},
"createdAt": "2026-11-18T10:02:13Z",
"completedAt": "2026-11-18T10:02:16Z",
"endpointId": "ep_4n8wq2zt"
}Verify signatures
Every delivery carries an Apipods-Signature header with a Unix timestamp t and a signature v1. The signature is the hex HMAC-SHA256 of {t}.{rawBody}, keyed with the endpoint's webhook signing secret (whsec_…, shown in the endpoint's settings in the console and returned once as webhookSecret when the endpoint is created). Reject deliveries whose timestamp is more than 300 seconds from your clock.
import hashlib
import hmac
import os
import time
from flask import Flask, abort, request
app = Flask(__name__)
SECRET = os.environ["APIPODS_WEBHOOK_SECRET"].encode()
def verify(header: str, body: bytes) -> bool:
parts = dict(p.split("=", 1) for p in header.split(","))
timestamp, signature = parts.get("t", "0"), parts.get("v1", "")
if abs(time.time() - int(timestamp)) > 300:
return False
expected = hmac.new(SECRET, timestamp.encode() + b"." + body, hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, signature)
@app.post("/hooks/apipods")
def apipods_webhook():
if not verify(request.headers.get("Apipods-Signature", ""), request.get_data()):
abort(400)
job = request.get_json()
save_result(job["id"], job["status"], job.get("output"), job.get("error"))
return "", 204Delivery and retries
- Any 2xx response within 10 seconds counts as delivered. Redirects are not followed.
- Other responses and timeouts are retried with exponential backoff for up to 24 hours (8 attempts in total).
- Deliveries can arrive more than once or out of order. Deduplicate on the job
idandstatus. - A failed delivery never changes the job: its result is still available on
/statusduring the retention period.
Best practices
- Respond quickly and process the job asynchronously, for example by putting it on your own queue.
- Keep large outputs out of the payload: return a network-volume path or object URL from your handler instead.
- Rotate the signing secret from the endpoint settings. During rotation, both the old and new secret are valid for 24 hours, and the header carries two
v1entries.