Page options
Biocompile webhooks for runs and contributions
Last updated
On this page
Biocompile webhooks tell your system when something happens in your organization, so it
does not have to poll. Biocompile sends a signed HTTPS POST to an endpoint you choose when a
Run finishes or a contribution is submitted or decided. Your endpoint checks the signature
and answers quickly.
Organization owners and admins manage webhooks under Organization → Webhooks, or through
the API with the webhooks:manage scope. A service account cannot manage webhooks, because
deciding where your organization’s events go stays with a person.
Events
Each event is sent once to each subscription that asked for it:
| Event | Sent when |
|---|---|
run.completed | A Run finished successfully. |
run.failed | A Run failed, timed out or was cancelled. data.status says which. |
contribution.submitted | Drafts were contributed from a workbench. contribution.decided follows at once. |
contribution.decided | A contribution was decided: applied when it merged, or conflicted or withdrawn when it did not. |
webhook.ping | You sent a test event. |
The body names the event and the resource: IDs, status, project and the API path to fetch it. It never contains secrets, file contents, Run inputs or e-mail addresses.
Add a webhook
In the app, open Organization → Webhooks and choose Add webhook. Enter the Endpoint URL, tick the Events and save. Through the API, an admin’s token creates the same subscription:
curl -s --request POST "https://app.biocompile.com/api/v1/organizations/$ORG_ID/webhooks" \
-H "Authorization: Bearer $ACCESS_TOKEN" -H "Content-Type: application/json" \
-d '{"url": "https://lims.example.com/biocompile/events", "events": ["run.completed", "run.failed"]}'
The answer contains the signing secret, which starts with whsec_ and is shown once. Keep it
in your secret manager. If you lose it, rotate it, and the old secret stops working at once.
The endpoint must meet these rules:
- It uses
httpson port 443, with a host name rather than an IP address. - The host resolves only to public addresses.
- The URL holds no user name or password and no fragment. A path and a query are fine.
- It answers directly, because redirects are not followed.
Verify the signature
Deliveries follow the Standard Webhooks specification. Each request carries three headers:
webhook-id, webhook-timestamp and webhook-signature. The signature is an HMAC-SHA256 of
the ID, the timestamp and the raw body, keyed with your secret. This Python function checks it:
import base64
import hashlib
import hmac
import time
TOLERANCE_SECONDS = 5 * 60
def verify(secret: str, headers: dict[str, str], body: bytes) -> bool:
"""True when the request was signed with the secret in the last 5 minutes."""
message_id = headers["webhook-id"]
timestamp = headers["webhook-timestamp"]
if abs(time.time() - int(timestamp)) > TOLERANCE_SECONDS:
return False # too old or from the future, so refuse replays
key = base64.b64decode(secret.removeprefix("whsec_"))
signed = f"{message_id}.{timestamp}.".encode() + body
expected = base64.b64encode(hmac.new(key, signed, hashlib.sha256).digest()).decode()
# The header may list several signatures, separated by spaces.
for candidate in headers["webhook-signature"].split():
version, _, signature = candidate.partition(",")
if version == "v1" and hmac.compare_digest(signature, expected):
return True
return False
Verify against the raw request body, before you parse the JSON. Any Standard Webhooks library
performs the same check. Use webhook-id to skip a delivery you have already processed,
because retries and redeliveries keep the same ID.
Answer, retries and disabling
Answer with any 2xx status within 10 seconds, and do the work afterwards. Anything else, a
timeout or a refused connection counts as a failed attempt.
Biocompile retries a failed delivery about 5 seconds, 5 minutes, 30 minutes, 2 hours, 5 hours,
10 hours and 10 hours later. That makes 8 attempts over about a day. A 410 Gone answer
disables the subscription at once. So do 8 deliveries in a row that fail every attempt.
Re-enable a disabled subscription once your endpoint works again. Send test event sends a
webhook.ping, and the delivery log shows every attempt for 30 days with its status code and
the start of your answer. A finished delivery can be sent again with its original ID.
Limitations
Webhooks have fixed limits per organization:
| What is limited | Limit | What to do instead |
|---|---|---|
| Webhooks per organization | 20 | Send several event types to one endpoint |
| Test events and redeliveries | 10 a minute per webhook, 30 a minute per organization | Wait for Retry-After seconds |
| Deliveries waiting to be sent | 1,000 per organization | Redeliver the cancelled events once the queue drains |
| Delivery log history | 30 days | Store the events you need on your side |
| Time to answer | 10 seconds | Answer first, then process the event |
Common questions
How do I check that a webhook came from Biocompile?
Verify the webhook-signature header with your whsec_ secret, against the raw body. Refuse
deliveries whose webhook-timestamp is more than 5 minutes away from your clock.
What happens when my endpoint is down?
Biocompile retries each delivery 8 times over about a day. After 8 deliveries in a row fail every attempt, the subscription is disabled until an admin enables it again.
Can a service account manage webhooks?
No. Only organization owners and admins manage webhooks, in the app or with their own token.
Related
Was this page helpful?
Something wrong or missing?