Async
Introduction
Sources can accept work asynchronously. The caller gets 202 Accepted with a
job id and poll URL. The job still competes for the source's concurrency limit.
When the upstream finishes, swarmvia posts a signed webhook and the poll
endpoint returns the result.
Async needs at least one active webhook destination. Enable async on Sources → Concurrency, then attach a destination from Webhooks. Sync proxy stays the default. Team and Business plans only.
Admission modes
| Mode | How it triggers | reason on poll / webhook |
|---|---|---|
| Header | X-Swarmvia-Async: 1 on a normal source request |
requested |
| On open wait | Request would wait for a slot → accept as a job instead of holding the connection | busy |
| On queue timeout | Open wait hits queue timeout → accept as a job instead of 504 queue_timeout |
wait_timeout |
All three share one job pipeline. Slot timing: the concurrency slot is held only while the upstream fetch runs (not while the job waits in the queue).
Async bypasses the shared response cache.
No active destination
A source with async on but no active destination falls back to sync. That covers both cases: nothing attached yet, and every attached webhook deactivated after repeated delivery failures.
In that state the source behaves exactly as it would with async off:
X-Swarmvia-Async: 1returns the upstream response, not202.- On open wait and on queue timeout do not promote. A request waits for a slot
as usual and gets
429or504 queue_timeouton its own terms.
No jobs are created while a source is in this state, so nothing sits unclaimed. Attach a working destination (or re-enable a deactivated one) and the next request goes back through the async path.
A source that never enabled async still rejects X-Swarmvia-Async: 1 with
400 async_disabled.
Accept response
{
"jobId": "job_…",
"status": "accepted",
"pollUrl": "https://api.swarmvia.cloud/pools/your-source/jobs/job_…",
"webhook": { "destinations": 2 }
}pollUrl is
https://api.swarmvia.cloud/pools/{source}/jobs/{jobId}, on the API host, not
your source's endpoint or a custom domain. {source} is your source subdomain. Job ids are job_ followed by hex.
Database sources are the exception: their handles poll on the source's own
endpoint — see Database sources.
Poll
GET (or HEAD) the pollUrl with the same source auth as a normal request. Poll is there for callers that cannot receive a webhook. When destinations are configured,
the webhook remains the primary completion signal.
Accept is 202 with status: "accepted". Poll always returns 200 for a
known job, with status set to the current lifecycle value:
accepted → queued → running → terminal completed | failed | expired
There is no job-level pending. On API sources, queued covers everything
before swarmvia sends the request upstream (waiting for a slot, fetching the
credential). running means the request is being sent or has been sent.
| Case | HTTP | Body |
|---|---|---|
| Unknown or wrong-source job | 404 | { "error": "job_not_found" } |
Past expiresAt, still non-terminal |
200 | status: "expired" |
| Terminal job still in store | 200 | that terminal status |
Every poll body includes jobId, status, reason, createdAt,
updatedAt, and expiresAt. Terminal jobs may include result (upstream
status, headers, size-capped body). When destinations are on the job,
webhook reports destinations, delivered, and failed counts.
Retention
Job retention defaults to 86400 seconds (24 hours). Configurable per source from 60 seconds to 604800 (7 days).
Retries
swarmvia sends an API source's upstream request at most once per job.
- Anything that goes wrong before the request is sent is retried with backoff
(5 s, 10 s, 20 s, … up to 5 minutes, 8 deliveries in all): no free slot, a
temporarily unavailable credential, a source still being configured, or a
storage error. Throttled
429responses are still retried inside the request as described under Concurrency. - Once the request has been sent, the job is never sent again. If swarmvia
lost track of it after sending (for example, the worker restarted before
the response was stored), the job fails with
result.status502andresult.erroroutcome_unknown. The request may or may not have reached your upstream, so check there before you resubmit a write. - If the 8 deliveries run out before the request is sent, the job fails with
result.status503and anerrornaming the last reason, ending in(gave up after 8 attempts). Nothing was sent upstream.
These failures go to your webhook destinations like any other terminal outcome. A job that fails on its last delivery gets one webhook attempt, or none if the source's configuration is still unavailable; poll the job to see its result.
Webhooks
See Webhooks for destinations, signing, and retries.
Limitations
- On API sources, async requires at least one active webhook destination; without one the source serves sync. Database sources return handles with async enabled alone.
- Max request body retained for a job defaults to 1 MiB (configurable per source).
- Job retention defaults to 24 hours (configurable from 60 seconds to 7 days).
- Webhook delivery is at-least-once; receivers must be idempotent on
jobId. - Destination count per source is plan-capped.