Skip to content
Docs menu

Background jobs and webhooks

Run long work without holding a connection, and get called back.

Music, a video design and a cold start can take a minute or two. Every generation route (/v1/chat, /v1/wave, /v1/composer/compose, /v1/assets/regenerate) can run in the background. The call returns at once with a request id, the work continues without your connection, and you follow it or get called back.

Start a job and wait

job = catalyst.composer.compose("epic orchestral build", duration=120, async_=True)

job.request_id                        # "req_..."
env = job.wait(timeout=600, on_progress=lambda e: print(e.status))   # long-polls; returns the finished envelope
job.get(wait=10)                      # one poll
job.cancel()
for frame in job.events():            # replays events; resumes after a dropped connection
    print(frame.event)

The first call answers 202 at once. The curl -i reply starts with HTTP/2 202 and a Location and Retry-After header; the body has this shape:

Output
{
  "success": true,
  "request_id": "req_0123456789abcdef0123",
  "service": "catalyst",
  "session_id": "my-session",
  "status": "queued",
  "data": {
    "request": {
      "id": "req_0123456789abcdef0123",
      "kind": "wave",
      "session_id": "my-session",
      "status": "queued",
      "async": true,
      "progress": {},
      "cancel_requested": false,
      "created_at": "2026-11-08T12:00:00Z",
      "started_at": null,
      "finished_at": null,
      "expires_at": "2026-12-08T12:00:00Z"
    },
    "result": null,
    "poll_after_seconds": 2
  },
  "files": [],
  "usage": {
    "plumes": 0
  },
  "error": null
}

(Recorded from the gateway's response builders: the id and times differ on every call, and kind is composer for a composer request.)

wait long-polls, so it does not hammer the API. A failed job raises its own error (for example out-of-PLUMES), a cancelled one raises a cancelled error, and running out of time raises a timeout error while the job keeps running on the server. The files in the result carry their session, so you can download them directly.

Request states

statusMeaning
queuedAccepted, not started.
runningIn progress. data.request.progress says what it is doing; files lists what exists so far.
completedDone. data.result and files hold the answer.
needs_inputThe turn is over and waits for you (for example a plan to approve). Reply with a normal chat request in the same session.
faileddata.request.error has the code, message and retryable.
cancelledStopped by you.

Follow requests (HTTP)

These calls are free. They still count against your per-minute limit, so prefer the long-poll or the event stream to tight polling.

CallWhat it does
GET /v1/requests/{id}State, progress, files so far and, when it ends, the result. Prefer: wait=25 holds the call until it changes (up to 25 s). If-None-Match with the ETag returns 304 when nothing changed.
GET /v1/requests/{id}/eventsThe events as a stream with id: numbers. Send Last-Event-ID (or ?after=) to continue after a dropped connection without missing or repeating anything.
POST /v1/requests/{id}/cancelStop it. Safe to repeat; a finished request is left as it is.
GET /v1/requestsYour requests, newest first. Filter with session_id and status; page with limit and cursor.

Watch the events of a request

Shell
curl -N -sS "https://api.falcorelabs.com/v1/requests/req_0123456789abcdef0123/events" -H "Authorization: Bearer $FALCORE_API_KEY"

Each event has an id: you can send back as Last-Event-ID to continue. A finished Wave request replays like this (shape recorded from the code that writes the events; data: lines are one line each):

Output
id: 1
event: started
data: {"event": "started", "service": "catalyst", "session_id": "my-session", "request_id": "req_0123456789abcdef0123", "timestamp": "2026-11-08T12:00:00+00:00", "data": {}}

id: 2
event: progress
data: {"event": "progress", "service": "catalyst", "session_id": "my-session", "request_id": "req_0123456789abcdef0123", "timestamp": "2026-11-08T12:00:00+00:00", "data": {"stage": "execute_plan_node", "message": "Creating the sounds"}}

id: 3
event: file
data: {"event": "file", "service": "catalyst", "session_id": "my-session", "request_id": "req_0123456789abcdef0123", "timestamp": "2026-11-08T12:00:00+00:00", "data": {"file_id": "fil_005033c8d6174369a80df306", "kind": "audio", "role": "sound", "format": "wav", "duration": 2.0, "size_bytes": 176444, "plumes": 0, "expires_at": "2026-12-08T12:00:00Z"}}

id: 4
event: usage
data: {"event": "usage", "service": "catalyst", "session_id": "my-session", "request_id": "req_0123456789abcdef0123", "timestamp": "2026-11-08T12:00:00+00:00", "data": {"plumes": 0}}

id: 5
event: done
data: {"event": "done", "service": "catalyst", "session_id": "my-session", "request_id": "req_0123456789abcdef0123", "timestamp": "2026-11-08T12:00:00+00:00", "data": {"summary": {"count": 1, "requested": 1, "failed": 0}, "files": [{"file_id": "fil_005033c8d6174369a80df306", "kind": "audio", "role": "sound", "format": "wav", "duration": 2.0, "size_bytes": 176444, "plumes": 0, "expires_at": "2026-12-08T12:00:00Z"}], "usage": {"plumes": 0}}}

Get a webhook instead of polling

With an async request add webhook_url (https, a public host name, port 443) and webhook_secret (16 characters or more; it is never shown again). When the request ends, Catalyst sends a signed POST to your URL.

from falcore import verify_webhook, WebhookVerificationError

job = catalyst.wave.generate("door knock", async_=True,
                             webhook_url="https://example.com/hook", webhook_secret="a-secret-of-16+chars")
try:
    event = verify_webhook(raw_body_bytes, request.headers["Falcore-Signature"], "a-secret-of-16+chars")
except WebhookVerificationError:
    ...  # answer 400 and ignore the delivery

Always verify with the raw request body (not re-serialised JSON), and reject a delivery whose timestamp is more than 5 minutes old.

Note

Starting a background request is charged like the same request made directly. Following it (polling, events, cancel, list) costs no PLUMES. Where background requests are not enabled yet, options.async answers 501.