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 arequestId that you can use to poll for the task status until it completes.
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:- Pending
- Success
- Error
- Input Required
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
| Feature | Polling | Webhooks |
|---|---|---|
| Setup Complexity | Low | Medium |
| Infrastructure | None required | Web server needed |
| Real-time Updates | No (delayed by interval) | Yes |
| Resource Usage | Higher (active requests) | Lower |
| Firewall Friendly | Yes | Requires open ports |
| Scalability | Limited | Excellent |
| Best For | Scripts, simple apps | Production systems |
Common Issues
Polling Too Frequently
Polling Too Frequently
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.
No Timeout Implemented
No Timeout Implemented
Problem: Script runs forever if a task never completes.Solution: Always set a maximum timeout for your polling loop.
Not Handling All Status Types
Not Handling All Status Types
Problem: Code breaks when receiving unexpected status values.Solution: Handle all possible statuses:
pending, success, error, and input-required.Missing Error Handling for API Calls
Missing Error Handling for API Calls
Problem: Network errors crash the polling loop.Solution: Wrap API calls in try-except and implement retry logic.