Async webhook CI (submit + poll)
Use this pattern when trigger and poll run in different workers (message queue, shared task store, cron scheduler). Each call is stateless — no blocking journey.
Flow
- Worker A —
trigger_webhook(payload)→ persistwebhook_id,invocation_id, optionalsession_id - Worker B — if no
session_id,wait_for_webhook_session(...)orget_webhook_run(...) - Worker B —
list_session_artifacts/download_session_artifactwhen ready
Trigger worker
from stackgen import StackgenClient, StackgenConfig
client = StackgenClient(
StackgenConfig(
base_url="https://app.stackgen.com",
api_token="stackgen_…",
webhook_token="sg_aios_…",
org_id="<project-uuid>",
)
)
trigger = client.aiden.trigger_webhook(alert_body)
# Persist to queue / DB:
# trigger["webhook_id"], trigger["invocation_id"], trigger.get("session_id")import { StackgenClient, StackgenConfig } from "stackgen-sdk";
const client = new StackgenClient(
new StackgenConfig({
baseUrl: "https://app.stackgen.com",
apiToken: "stackgen_…",
webhookToken: "sg_aios_…",
orgId: "<project-uuid>",
}),
);
const trigger = await client.aiden.triggerWebhook(alertBody);
// Persist trigger.webhook_id, trigger.invocation_id, trigger.session_idScheduler worker
session_id = stored_session_id or client.aiden.wait_for_webhook_session(
webhook_id,
invocation_id,
dispatch_run_id=trigger_run_id,
)
artifacts = client.aiden.list_session_artifacts(session_id)
path = client.aiden.download_session_artifact(
session_id,
"session-report.md",
"session-report.md",
)const sessionId =
storedSessionId ??
(await client.aiden.waitForWebhookSession(webhookId, invocationId, {
dispatchRunId: triggerRunId,
}));
await client.aiden.downloadSessionArtifact(
sessionId,
"session-report.md",
"session-report.md",
);When to use the blocking journey instead
Single CI script that triggers and waits in one process: run_webhook_and_download_report.
It implements the same dual-path logic internally.
Related: Webhook → session → artifact, Network egress.