Skip to content

Wait/Signal

Wait/Signal lets you create tasks that pause in a “waiting” state after executing their callback, then resume when your system - or a third party - sends a signal. This is useful for human-in-the-loop workflows, payment confirmations, external approvals, and multi-step processes that depend on outside events.

  1. Create a task with waitForSignal: true
  2. AsyncQueue calls your callback URL as usual
  3. Instead of completing, the task transitions to waiting and returns a signalToken
  4. When you’re ready, send a signal with the token to complete or fail the task
  5. If no signal arrives within maxWaitTime, the task times out automatically
Your App AsyncQueue Your Callback
│ │ │
│── POST /v1/tasks ─────────▶│ │
│ waitForSignal: true │ │
│◀── 201 { signalToken } ───│ │
│ │── HTTP callback ──────────▶│
│ │◀── 200 OK ────────────────│
│ │ (status: "waiting") │
│ │ │
│ ... time passes ... │ │
│ │ │
│── POST /v1/signals/:token ▶│ │
│ { status: "completed" } │ │
│◀── 200 { task } ──────────│ │

Add waitForSignal: true to your task creation request. The response includes a one-time signalToken.

Terminal window
curl -X POST https://api.asyncqueue.io/v1/tasks \
-H "X-API-Key: async_your_key" \
-H "Content-Type: application/json" \
-d '{
"targetUrl": "https://your-api.com/start-process",
"method": "POST",
"body": "{\"orderId\": \"order_123\"}",
"waitForSignal": true,
"maxWaitTime": 3600,
"onCompleteUrl": "https://your-api.com/webhook"
}'

Response:

{
"task": {
"id": "019d2b00-1234-7000-a000-000000000001",
"status": "pending",
"waitForSignal": true,
"maxWaitTime": 3600
},
"signalToken": "a1b2c3d4e5f6..."
}

Important: Store the signalToken securely. It is returned only once at creation time and never again.

When you’re ready to resolve the task, send a POST request to the signal endpoint. No API key is required - the token itself authenticates the request.

Terminal window
curl -X POST https://api.asyncqueue.io/v1/signals/a1b2c3d4e5f6... \
-H "Content-Type: application/json" \
-d '{
"status": "completed",
"result": { "downloadUrl": "https://cdn.example.com/output.pdf" }
}'
Terminal window
curl -X POST https://api.asyncqueue.io/v1/signals/a1b2c3d4e5f6... \
-H "Content-Type: application/json" \
-d '{
"status": "failed",
"error": "Payment was declined"
}'
FieldTypeRequiredDescription
statusstringYes"completed" or "failed"
resultanyNoResult data (for completed signals)
errorstringNoError message (for failed signals)

A wait/signal task goes through these states:

StatusDescription
pendingTask created, waiting to be processed
processingCallback URL is being called
waitingCallback succeeded, waiting for external signal
completedSignal received with status: "completed"
failedSignal received with status: "failed"
timeoutNo signal received within maxWaitTime
cancelledTask was cancelled (waiting tasks can be cancelled)

Wait/signal tasks have two result fields:

  • startResult - The HTTP response from the initial callback (stored when task enters “waiting”)
  • result - The final result provided by the signal

This lets you capture data from both the initial callback and the signal resolution.

If no signal arrives within maxWaitTime seconds (default: 30), the task automatically transitions to timeout status. Set a longer maxWaitTime for processes that take more time:

{
"targetUrl": "https://your-api.com/start",
"waitForSignal": true,
"maxWaitTime": 86400
}

This gives the task 24 hours to receive a signal.

Tasks in the waiting state can be cancelled like pending or delayed tasks:

Terminal window
curl -X POST https://api.asyncqueue.io/v1/tasks/{taskId}/cancel \
-H "X-API-Key: async_your_key"

Cancelling a waiting task invalidates its signal token and removes the timeout watchdog.

  • Payment confirmations - Start a checkout, wait for payment webhook from Stripe/PayPal
  • Human approvals - Trigger a review process, wait for a manager to approve or reject
  • File processing - Upload a file to a converter, wait for the conversion to finish
  • Third-party integrations - Start an external process, wait for a callback when done
  • Multi-step workflows - Chain steps where each depends on an external event
  • Signal tokens are 256-bit random values (64 hex characters)
  • Only the SHA-256 hash is stored, the raw token is returned once
  • Tokens are one-time use and invalidated after signaling
  • Tokens auto-expire based on maxWaitTime
  • The signal endpoint is rate-limited by IP (30 requests per minute)