Sign in Get started

Webhooks

Register an HTTPS endpoint for signed, retried workflow events, verify each delivery's HMAC signature, and inspect or replay the delivery log.

View as Markdown
On this page
  • The endpoint must be a public HTTPS URL (not a private, loopback or metadata address).
  • Creating, changing, testing, rotating, replaying and deleting need an admin key.
  • Python and the CLI name an endpoint by its URL, exactly as registered (or its id). REST names it by its name (the URL’s host, unless you set one) or its id.

event_types

The event types you can subscribe to.

Source: Webhooks.event_types

print(client.webhooks.event_types())
# ['workflow_run.completed', 'workflow_run.events', 'workflow_run.failed', 'workflow_stream.ended', 'workflow_stream.events']
pictograph webhooks event-types
curl -s "https://api.pictograph.io/api/v1/developer/webhooks/event-types" \
  -H "X-API-Key: $PICTOGRAPH_API_KEY"

Returns list[str]

Event Fires when
workflow_run.completed A workflow run finishes (payload)
workflow_run.events Events a video run’s webhook output picked occur (payload)
workflow_run.failed A workflow run fails (payload)
workflow_stream.events Events a stream’s webhook output picked occur (payload)
workflow_stream.ended A workflow stream ends, with final line and zone counts (payload)

create

Register an endpoint; it returns the endpoint and its signing secret (shown again in the app under Settings → Webhooks). auth_headers, for an endpoint behind your own proxy, are sent on every delivery and kept encrypted; only their names are returned.

Source: Webhooks.create

Arg Type Default Notes
url str required Public HTTPS URL to POST to
description str | None None Label for the endpoint
event_types list[str] | None None Events to send; None sends every event, including future ones
auth_headers dict[str, str] | None None Headers sent with every delivery, e.g. {"Authorization": "Bearer ..."}
created = client.webhooks.create(
    url="https://example.com/hooks/pictograph",
    description="Prod ingestion",
    event_types=["workflow_run.completed", "workflow_run.failed"],
)
print(created.endpoint.id)
print(created.secret)   # whsec_...
pictograph webhooks create https://example.com/hooks/pictograph \
  --description "Prod ingestion" \
  --event workflow_run.completed --event workflow_run.failed
curl -s -X POST "https://api.pictograph.io/api/v1/developer/webhooks/endpoints" \
  -H "X-API-Key: $PICTOGRAPH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com/hooks/pictograph", "description": "Prod ingestion", "event_types": ["workflow_run.completed", "workflow_run.failed"]}'

Returns CreatedWebhookEndpoint

CreatedWebhookEndpoint · 2 fields
class CreatedWebhookEndpoint(BaseModel):
    """An endpoint and its signing secret (from create or a rotation)."""
    endpoint: WebhookEndpoint
    # The signing secret; the app shows it again under Settings → Webhooks.
    secret: str

list

Every endpoint in your organization; secrets aren’t returned.

Source: Webhooks.list

for ep in client.webhooks.list():
    print(ep.id, ep.url, ep.enabled, ep.event_types)
pictograph webhooks list
curl -s "https://api.pictograph.io/api/v1/developer/webhooks/endpoints" \
  -H "X-API-Key: $PICTOGRAPH_API_KEY"

Returns Sequence[WebhookEndpoint]

WebhookEndpoint · 13 fields
class WebhookEndpoint(BaseModel):
    """A registered outbound webhook destination."""
    id: str
    organization_id: str
    url: str
    description: str | None = None
    # The events it's sent; empty means every event.
    event_types: list[str] = []
    # Whether it's sent deliveries; turned off after many failures.
    enabled: bool = True
    # Goes up by one at each rotation.
    secret_version: int = 1
    # The secret's first characters.
    secret_prefix: str | None = None
    # Failed deliveries in a row; 0 after a success.
    consecutive_failures: int = 0
    # Why it was turned off.
    disabled_reason: str | None = None
    # The names of its custom headers (their values are never returned).
    auth_header_names: list[str] | None = None
    # When it was last sent a delivery.
    last_delivery_at: datetime | None = None
    created_at: datetime | None = None
Field Meaning
event_types The events it’s sent; empty means every event
enabled Whether it receives deliveries; turned off after many failures in a row
secret_version Increases by one at each rotation
secret_prefix The secret’s first characters
consecutive_failures Failed deliveries in a row; 0 after a success
disabled_reason Why it was turned off
auth_header_names Names of its auth_headers
last_delivery_at When it last received a delivery

get

One endpoint.

Source: Webhooks.get

Arg Type Default Notes
endpoint str required Endpoint URL or id
ep = client.webhooks.get(endpoint="https://example.com/hooks/pictograph")
print(ep.url, ep.enabled)
pictograph webhooks get https://example.com/hooks/pictograph
curl -s "https://api.pictograph.io/api/v1/developer/webhooks/endpoints/$ENDPOINT" \
  -H "X-API-Key: $PICTOGRAPH_API_KEY"

Returns WebhookEndpoint

WebhookEndpoint · 13 fields
class WebhookEndpoint(BaseModel):
    """A registered outbound webhook destination."""
    id: str
    organization_id: str
    url: str
    description: str | None = None
    # The events it's sent; empty means every event.
    event_types: list[str] = []
    # Whether it's sent deliveries; turned off after many failures.
    enabled: bool = True
    # Goes up by one at each rotation.
    secret_version: int = 1
    # The secret's first characters.
    secret_prefix: str | None = None
    # Failed deliveries in a row; 0 after a success.
    consecutive_failures: int = 0
    # Why it was turned off.
    disabled_reason: str | None = None
    # The names of its custom headers (their values are never returned).
    auth_header_names: list[str] | None = None
    # When it was last sent a delivery.
    last_delivery_at: datetime | None = None
    created_at: datetime | None = None

update

Change only the fields you pass. Turning a disabled endpoint back on resets its failure count.

Source: Webhooks.update

Arg Type Default Notes
endpoint str required Endpoint URL or id
url str | None None New URL
description str | None None New label
event_types Sequence[str] | None None New list of events
enabled bool | None None False stops deliveries; True resumes them
auth_headers dict[str, str] | None None Replaces its headers; {} removes them
ep = client.webhooks.update(
    endpoint="https://example.com/hooks/pictograph",
    url="https://example.com/hooks/v2",
    event_types=["workflow_run.completed"],
    enabled=True,
)
pictograph webhooks update https://example.com/hooks/pictograph \
  --url https://example.com/hooks/v2 \
  --event workflow_run.completed \
  --enabled
curl -s -X PATCH "https://api.pictograph.io/api/v1/developer/webhooks/endpoints/$ENDPOINT" \
  -H "X-API-Key: $PICTOGRAPH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com/hooks/v2", "event_types": ["workflow_run.completed"], "enabled": true}'

Returns WebhookEndpoint

WebhookEndpoint · 13 fields
class WebhookEndpoint(BaseModel):
    """A registered outbound webhook destination."""
    id: str
    organization_id: str
    url: str
    description: str | None = None
    # The events it's sent; empty means every event.
    event_types: list[str] = []
    # Whether it's sent deliveries; turned off after many failures.
    enabled: bool = True
    # Goes up by one at each rotation.
    secret_version: int = 1
    # The secret's first characters.
    secret_prefix: str | None = None
    # Failed deliveries in a row; 0 after a success.
    consecutive_failures: int = 0
    # Why it was turned off.
    disabled_reason: str | None = None
    # The names of its custom headers (their values are never returned).
    auth_header_names: list[str] | None = None
    # When it was last sent a delivery.
    last_delivery_at: datetime | None = None
    created_at: datetime | None = None

rotate_secret

Make a new signing secret. For a short while deliveries are signed with both the old and the new secret, so you can switch your receiver without missing one.

Source: Webhooks.rotate_secret

Arg Type Default Notes
endpoint str required Endpoint URL or id
rotated = client.webhooks.rotate_secret(endpoint="https://example.com/hooks/pictograph")
print(rotated.secret)
pictograph webhooks rotate-secret https://example.com/hooks/pictograph
curl -s -X POST "https://api.pictograph.io/api/v1/developer/webhooks/endpoints/$ENDPOINT/rotate-secret" \
  -H "X-API-Key: $PICTOGRAPH_API_KEY"

Returns CreatedWebhookEndpoint

CreatedWebhookEndpoint · 2 fields
class CreatedWebhookEndpoint(BaseModel):
    """An endpoint and its signing secret (from create or a rotation)."""
    endpoint: WebhookEndpoint
    # The signing secret; the app shows it again under Settings → Webhooks.
    secret: str

test

Send a signed test event now and get the result. It’s logged like any delivery.

Source: Webhooks.test

Arg Type Default Notes
endpoint str required Endpoint URL or id
result = client.webhooks.test(endpoint="https://example.com/hooks/pictograph")
print(result["delivered"], result["status_code"])
pictograph webhooks test https://example.com/hooks/pictograph
curl -s -X POST "https://api.pictograph.io/api/v1/developer/webhooks/endpoints/$ENDPOINT/test" \
  -H "X-API-Key: $PICTOGRAPH_API_KEY"

Returns dict[str, Any]

deliveries

One page of the delivery log, newest first.

Source: Webhooks.deliveries

Arg Type Default Notes
endpoint str | None None Only this endpoint’s deliveries (URL or id)
status WebhookDeliveryStatus | None None Only this status: pending, delivered, failed or dead_letter
limit int 50 Page size
offset int 0 Items to skip
for d in client.webhooks.deliveries(status="failed", limit=20):
    print(d.id, d.event_type, d.attempts, d.last_status_code, d.last_error)
pictograph webhooks deliveries --status failed --limit 20
curl -s "https://api.pictograph.io/api/v1/developer/webhooks/deliveries?status=failed&limit=20" \
  -H "X-API-Key: $PICTOGRAPH_API_KEY"

Returns Sequence[WebhookDelivery]

WebhookDelivery · 12 fields
class WebhookDelivery(BaseModel):
    """One event's delivery to an endpoint, with its retries."""
    id: str
    endpoint_id: str
    organization_id: str
    event_type: str
    # Sent to your endpoint as X-Pictograph-Delivery-Id.
    delivery_id: str
    # pending (being tried), delivered, failed or dead_letter (out of retries).
    status: Literal['pending', 'delivered', 'failed', 'dead_letter']
    # Tries so far.
    attempts: int = 0
    # What the last try got back.
    last_status_code: int | None = None
    # The last try's error.
    last_error: str | None = None
    # When it's tried next.
    next_retry_at: datetime | None = None
    created_at: datetime | None = None
    # When it was delivered.
    delivered_at: datetime | None = None
Field Meaning
id Pass it to replay
delivery_id Sent to your endpoint as X-Pictograph-Delivery-Id
status pending (being tried), delivered, failed or dead_letter (out of retries)
attempts Tries so far
last_status_code, last_error What the last try got back
next_retry_at When it’s tried next
delivered_at When it was delivered

replay

Send a failed or dead_letter delivery again, with its retries reset.

Source: Webhooks.replay

Arg Type Default Notes
delivery str required Delivery id (from deliveries)
client.webhooks.replay(delivery="f3a4b5c6-7d8e-4f92-a013-b4c5d6e7f809")
pictograph webhooks replay f3a4b5c6-7d8e-4f92-a013-b4c5d6e7f809
curl -s -X POST "https://api.pictograph.io/api/v1/developer/webhooks/deliveries/$DELIVERY_ID/replay" \
  -H "X-API-Key: $PICTOGRAPH_API_KEY"

Returns None

delete

Delete an endpoint and its delivery log.

Source: Webhooks.delete

Arg Type Default Notes
endpoint str required Endpoint URL or id
client.webhooks.delete(endpoint="https://example.com/hooks/pictograph")
pictograph webhooks delete https://example.com/hooks/pictograph --yes
curl -s -X DELETE "https://api.pictograph.io/api/v1/developer/webhooks/endpoints/$ENDPOINT" \
  -H "X-API-Key: $PICTOGRAPH_API_KEY"

Returns None

Run events

A run sends these to the endpoint its webhook output names:

  • workflow_run.events - a video run’s picked events as they happen, at most one delivery a second with every event since: run_id, workflow_id and events (each like a live event, without session)
  • workflow_run.completed - what the run measured (step_results, by block) and wrote (artifacts), each artifact with a download_url valid for an hour after sending
  • workflow_run.failed - the run and workflow ids and status: "error"
{
  "event_type": "workflow_run.completed",
  "data": {
    "run_id": "5b7e2c40-...",
    "workflow_id": "a91b77d0-...",
    "status": "completed",
    "step_results": {
      "measure-1": {
        "aggregate": {"in": 42, "out": 17, "net": 25, "per_class": {"forklift": {"in": 42, "out": 17}}},
        "time_series": [{"t": 0.0, "frame": 0, "in": 0, "out": 0}],
        "per_track": [{"track_id": 7, "class": "forklift", "t": 61.3, "direction": "in"}]
      }
    },
    "artifacts": [
      {"kind": "annotated_video", "download_url": "https://..."}
    ]
  }
}

Live workflow events

A stream’s webhook output posts its live events: one workflow_stream.events delivery carries every event since the last, at most one a second. Each event says what happened (kind, and name as the app shows it), when (ts, stream time pts, frame), the frame’s classes, and for a line or zone its counts at that moment. Its event_id matches the record in the workflow’s live log, which holds the frame’s annotations.

{
  "event_type": "workflow_stream.events",
  "data": {
    "workflow_id": "a91b77d0-...",
    "workflow_name": "Dock counter",
    "endpoint_id": "3c5e9f12-...",
    "region": "us-west",
    "events": [
      {
        "event_id": "6f0d2c1e-...",
        "event": "crossing:measure-1:gate",
        "kind": "crossing",
        "name": "Crossing · Dock entrance",
        "session": "s1a2b3c4",
        "frame": 1840,
        "pts": 61.333,
        "ts": "2026-10-26T12:00:01.123Z",
        "measure": {
          "name": "Dock entrance", "label": "L1", "in": 42, "out": 17, "total": 59,
          "crossings": [{"track_id": 7, "class": "forklift", "direction": "in", "t": 61.3}]
        },
        "annotation_count": 3,
        "classes": {"forklift": 1, "person": 2},
        "captured": false
      }
    ]
  }
}
Event field Meaning
kind crossing, entry, exit, dwell, appearance or condition
event The key the webhook output picked it by
measure A line’s in, out, total and this frame’s crossings; a zone’s total (a dwell zone adds in, out, avg_time, total_time, and the visits it closed, under completed)
class An appearance’s class
captured Its frame was saved to a dataset; capture_skipped: "limit" if a frame was already saved that second

workflow_stream.ended carries the stream’s last frame and pts, and under measures each line’s and zone’s final counts by its label (L1, P1, …). Delivery ids are stable: an event batch resent by the stream is one delivery.

Verifying a delivery

Every delivery carries X-Pictograph-Signature: t=<unix_ts>,v1=<hex>. Compute HMAC-SHA256 of "{timestamp}.{raw_body}" with your signing secret and compare it in constant time. Reject a delivery more than five minutes old, so an old one can’t be replayed. During a rotation the header has several v1= values; accept the delivery if any one matches.

import hashlib
import hmac
import time

def verify(secret: str, signature_header: str, raw_body: bytes, *, tolerance: int = 300) -> bool:
    timestamp: str | None = None
    signatures: list[str] = []
    for part in signature_header.split(","):
        key, _, value = part.partition("=")
        if key == "t":
            timestamp = value
        elif key == "v1":
            signatures.append(value)
    if timestamp is None or not signatures:
        return False
    if abs(time.time() - int(timestamp)) > tolerance:
        return False  # stale: possible replay
    expected = hmac.new(
        secret.encode(), f"{timestamp}.".encode() + raw_body, hashlib.sha256
    ).hexdigest()
    return any(hmac.compare_digest(sig, expected) for sig in signatures)
Header Meaning
X-Pictograph-Signature t=<ts>,v1=<hex>, with a second v1 during a rotation
X-Pictograph-Delivery-Id The same on every try of a delivery: drop one you’ve already handled
X-Pictograph-Event-Type The event type
X-Pictograph-Timestamp The signed timestamp

Retries and auto-disable

A response other than 2xx, or no response, is retried about 30 seconds, 2 minutes, 10 minutes, 1 hour and 6 hours later. After the last try the delivery is dead_letter; replay it once your endpoint is back. An endpoint that fails many deliveries in a row is turned off; update(..., enabled=True) turns it back on. Answer with a 2xx at once and do the work afterwards: a slow answer counts as a failure.

Copied to clipboard