Skip to main content

Overview

Polling provides a pull-based mechanism for retrieving automation task results. After submitting a task via the Remote Dispatch API, you can periodically check for completion using the Get Task Status endpoint.

Simple Setup

No webhook endpoints or server infrastructure required to get started

Firewall Friendly

Works in restricted network environments without opening inbound ports

No Server Required

Perfect for scripts, CLI tools, and applications without a web server

Full Control

You decide when and how often to check for results

How Polling Works

When you submit an automation task, you receive a requestId that you can use to poll for the task status until it completes.
1

Submit Task

Send a request to the Remote Dispatch API and receive a requestId
2

Wait

Wait for an appropriate interval before checking status
3

Check Status

Call the Get Task Status endpoint with your requestId
4

Handle Response

If status is pending, go back to step 2. Otherwise, process the result.
Polling is ideal for simple integrations, scripts, and environments where setting up webhook endpoints isn’t feasible.

Basic Implementation

Here’s how to implement basic polling in different languages:

Polling with Timeout

Here’s a complete example with timeout handling:

Response Handling

The Get Task Status endpoint returns different statuses that you should handle appropriately:
The task is still running. Continue polling after waiting.

Best Practices

Use Reasonable Intervals

Poll every 5-10 seconds to balance responsiveness with API efficiency

Set Timeouts

Always implement maximum timeouts to prevent infinite polling loops

Handle All Statuses

Implement handlers for success, error, input-required, and timeout scenarios

Log Progress

Log polling attempts for debugging and monitoring purposes

Handle Network Errors

Wrap API calls in try-except to handle transient network failures gracefully

Consider Webhooks

For production apps with many concurrent tasks, webhooks may be more efficient

Comparison: Polling vs Webhooks

FeaturePollingWebhooks
Setup ComplexityLowMedium
InfrastructureNone requiredWeb server needed
Real-time UpdatesNo (delayed by interval)Yes
Resource UsageHigher (active requests)Lower
Firewall FriendlyYesRequires open ports
ScalabilityLimitedExcellent
Best ForScripts, simple appsProduction systems
Start with polling for development and simple use cases. Migrate to webhooks when you need real-time notifications or are handling high volumes of tasks.

Common Issues

Problem: Making too many requests and hitting rate limits.Solution: Use a reasonable polling interval of 5-10 seconds. This balances responsiveness with API efficiency.
Problem: Script runs forever if a task never completes.Solution: Always set a maximum timeout for your polling loop.
Problem: Code breaks when receiving unexpected status values.Solution: Handle all possible statuses: pending, success, error, and input-required.
Problem: Network errors crash the polling loop.Solution: Wrap API calls in try-except and implement retry logic.