Skip to content

Tasks

Tasks are the core unit of work in AsyncQueue. Each task represents a job to be executed asynchronously via a webhook call.

POST /v1/tasks
FieldTypeRequiredDescription
queuestringYesTarget queue name
webhook_urlstringYesURL to call when the task executes
payloadobjectNoJSON data to send with the webhook
delayintegerNoDelay in seconds before the task becomes eligible for execution
priorityintegerNoPriority level (1-10, higher is processed first, default: 5)
max_retriesintegerNoOverride the queue’s default retry count
Terminal window
curl -X POST https://api.asyncqueue.io/v1/tasks \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"queue": "emails",
"webhook_url": "https://your-app.com/webhooks/send-email",
"payload": {"to": "[email protected]", "template": "welcome"},
"delay": 300,
"priority": 8
}'
{
"id": "task_abc123",
"queue": "emails",
"status": "pending",
"priority": 8,
"delay": 300,
"created_at": "2025-01-15T10:30:00Z"
}
GET /v1/tasks/:task_id

Returns the current state of a task, including its execution history.

Terminal window
curl https://api.asyncqueue.io/v1/tasks/task_abc123 \
-H "Authorization: Bearer YOUR_API_KEY"
{
"id": "task_abc123",
"queue": "emails",
"status": "completed",
"priority": 8,
"payload": {"to": "[email protected]", "template": "welcome"},
"attempts": [
{
"number": 1,
"status": "success",
"response_code": 200,
"executed_at": "2025-01-15T10:35:02Z"
}
],
"created_at": "2025-01-15T10:30:00Z",
"completed_at": "2025-01-15T10:35:02Z"
}
GET /v1/tasks?queue=emails&status=pending
ParameterTypeDescription
queuestringFilter by queue name
statusstringFilter by status: pending, active, completed, failed
limitintegerNumber of results (default: 20, max: 100)
offsetintegerPagination offset
DELETE /v1/tasks/:task_id

Removes a pending task from the queue. Active or completed tasks cannot be deleted.

StatusDescription
pendingWaiting in the queue (or delayed)
activeCurrently being executed
completedWebhook returned a 2xx response
failedAll retry attempts exhausted