Polling external services from Temporal workflows: when a callback is not available
When a third-party API offers no webhook or callback, a Temporal workflow has to find out for itself when a job has finished, a payment has cleared or a file is ready. Polling is the usual answer: the workflow asks the external service for status on a schedule until it sees a terminal state. Temporal documents this as a durable loop, meaning the loop's progress lives in the workflow history rather than in a process that could be lost. A worker can crash mid-wait and the workflow still resumes where it left off. Teams need this pattern most often with batch vendors, regulated back-office systems, partner APIs with asynchronous job queues and government or banking endpoints that only expose status queries.
The design choice that matters most is where the loop lives. A poll can be a single activity that checks once and returns, with the workflow looping around it and sleeping with a durable timer between checks. Alternatively, the activity can own the loop and rely on its retry policy, heartbeats and timeouts to keep trying. The first keeps each attempt visible in history and gives you a clean place to change the interval over time. The second is less code but makes the number of attempts harder to see and control. Choose the interval, the maximum wait and the behavior when the vendor returns an unexpected status before the build starts, because each choice changes how many requests reach the vendor.
Several facts must come from the vendor, not from Temporal's documentation. Confirm the rate limits and quotas on the status endpoint, whether it returns a clear terminal state, how long results remain available, whether it supports conditional requests or a bulk status call, and what error codes mean 'try later' versus 'stop'. Also confirm whether the vendor's SLA covers the status endpoint at all. Temporal can make the wait durable, but it cannot make the vendor faster, and a polling design that ignores quotas will be throttled or blocked by the vendor's own controls.
Polling strategies and when each fits
This table compares frequent polling, infrequent polling with durable timers, and activity retries used as a polling loop across load on the external API, detection latency, durability on worker failure and what to confirm with the vendor. Read each row against your own API's rate limits and status endpoints. The main takeaway is that the strategy sets how much load you put on the vendor and how quickly you notice a change, so choose it after you know both.
| Factor | Frequent polling in an activity | Infrequent polling with durable timers |
|---|---|---|
| Load on the external API | Highest. Each activity attempt sends a request, so load grows with worker count and poll rate | Lower. Requests happen only when the timer fires, so load depends on the interval you set |
| Latency to detect a change | Lowest, bounded by the poll interval you choose | Higher, bounded by the timer interval, so a change can wait a full interval before it is seen |
| Durability on worker failure | Heartbeats and retries resume the activity on another worker, but progress held only in memory is lost | Strong. The timer lives in workflow history, so a worker restart does not reset the wait |
| Fit for a status check that resolves in minutes | Good fit when the vendor tolerates the load and a fast answer matters | Workable, but the timer interval may be longer than the wait you want |
| What to confirm with the vendor | Documented rate limits, per-key quotas, and whether a status endpoint exists for the job | Whether the status endpoint is cheap to call, and how long the job result stays available |
| Activity retry policy role | Retries can act as the loop, but each attempt counts against the vendor's limits | Retries handle transient errors on each check, separate from the wait between checks |
| Handling of vendor throttling | Requires backoff in the activity, or the loop can amplify throttling | Easier to space out, because the next check is scheduled rather than immediate |
| Common failure | Workers poll faster than the vendor allows and receive throttling responses | Interval chosen too long, so completion is noticed late or the timer waits on a job that already finished |
How the poll, timer and check cycle fits together
The cycle starts when a workflow schedules an activity that calls the external status endpoint through a rate limit gate. The activity returns a result to the workflow, which either finishes or waits on a durable timer before the next check. Check that the timer interval, activity timeouts and retry policy agree with the rate the external service allows, since the gate and the timer together set the call volume.
Illustrative poll cycle with a rate limit gate in front of the external API.
Protecting the external service from load
A polling workflow can send far more requests than the work needs if every instance checks at the same moment and retries without limit. The six controls below work together: they set how often each check runs, how the system reacts to errors, and how many checks run at once. Review them as a set before the first production run.
Poll interval with jitter
Set the interval between checks in the workflow's timer, then add a random offset so thousands of workflows started together do not all call the API in the same second. Ask the provider for its documented rate limit and choose an interval that keeps your combined request rate well under it. Check that the timer is durable, so a worker restart does not reset the schedule.
Backoff on errors
When the provider returns a throttling or server error, lengthen the wait between attempts instead of retrying at the normal interval. Activity retry policies provide exponential backoff with a maximum interval, which can be tuned per external call. Confirm which status codes the provider uses for rate limiting and mark genuinely permanent errors as non-retryable so they do not keep hitting the API.
Concurrency caps on activities
Limit how many poll activities run at the same time on each worker so a busy period cannot multiply requests across every workflow. Worker-level settings control concurrent activity execution, and the right value depends on how many workers you run and the provider's quota. Document the cap in your runbook so an operator knows where to change it during an incident.
Task queue rate limits
Apply a rate limit to the task queue that runs the polling activities, so Temporal dispatches tasks at a set pace regardless of how many are waiting. This protects the provider when a backlog builds up after an outage. Rate limits are a next step covered in detail on the sibling page, and they should be tested against the quota you were given, not assumed.
Shared polling for many workflows
When hundreds of workflows wait on the same external resource, one shared poller that fans results out to waiting workflows can replace hundreds of independent calls. The design needs a clear owner, a way to register interest, and a way to clean up when a workflow ends early. Weigh the added coupling against the reduction in request volume before choosing it.
Stopping polls when a result is final
End the polling loop as soon as the external status becomes terminal, such as completed, failed or cancelled, and do not keep checking after the answer is known. Also stop when the workflow reaches its own deadline or receives a cancellation signal. Test each exit path, because a loop that never exits is the most common source of unnecessary provider load.
How to build a polling workflow step by step
This sequence takes a polling workflow from an API assessment to a tested, load-checked design, with a verification point at each stage so the team knows the wait loop is safe before it reaches production.
Confirm the external API's status and rate limits
Before writing any code, the platform owner and the integration engineer read the third-party API documentation and record its status endpoint, its response codes for pending and final states, its rate limit and quota rules, and whether it sends webhooks or offers a bulk status query. Ask the vendor directly about limits that are not published, such as per-account concurrency and how throttling is signaled. The step is done when the team has a short written note listing the endpoint, the terminal states, the documented limits and the owner of the account used for polling. If the vendor cannot state a limit, treat the design as unbounded until it is measured.
Define an idempotent status activity with a typed result
The integration engineer writes one Temporal activity that calls the status endpoint with a stable identifier passed in from the workflow, so repeated calls return the same answer for the same state. The activity returns a typed result with fields such as state, a terminal flag, the raw vendor status code and a retry hint, rather than a bare string or an exception for normal pending states. Pending is a normal return value, not a failure. The check is a unit test that feeds pending, succeeded and failed responses through the activity and confirms each maps to the expected typed result.
Set retry policies and mark non-retryable errors
Next, the team configures the activity's retry policy and classifies errors. Transient failures such as connection resets and server-side errors remain retryable, while authentication failures, validation errors and requests for unknown identifiers are marked non-retryable so the workflow fails fast instead of looping. Confirm how the vendor signals throttling, and make sure the activity honors that signal rather than retrying on a fixed schedule. The check is a test run against a fake service that returns each error class, with the observed attempt count matching the policy the team wrote down.
Add the durable wait between polls
The workflow code now adds the wait between status checks using a durable timer, so the pause survives worker restarts and deployments without holding a process open. The loop calls the status activity, inspects the typed result, returns on a terminal state and otherwise sleeps before the next check. Set the interval from the rate limit notes in step one and keep it configurable per workflow type, so operators can change cadence without a code change. The check is a workflow run where the timer is observed in the event history and the loop exits cleanly on the terminal state.
Set a deadline for giving up
The team defines what happens when the external job never finishes. The workflow gets an overall deadline that stops polling, and the outcome path is explicit: record an unknown or timed-out state, alert the owning team, or hand off to a human review step. Decide whether the deadline is a workflow execution timeout, a counter of polls, or both, and confirm that the chosen value reflects the vendor's documented job lifetime, which the team should obtain from the vendor. The check is a test where the fake service never reaches a terminal state, and the workflow ends on the deadline path with the expected status.
Test replay and fake external behavior
Engineers run the workflow against a fake external service that can simulate pending states, delayed completion, throttling responses, server errors and a job that never completes. They also run the workflow's replay tests on the current code version, feeding in recorded histories so that changes to the loop, timer or activity signature are caught before deployment. The step is done when all scenarios pass and replay succeeds on histories from the previous version, which confirms that in-flight polling workflows will not break when the code is released.
Run a load check against a staging endpoint
Finally, the team runs a controlled load test against the vendor's sandbox or staging endpoint, if one exists, with the expected number of concurrent polling workflows and the chosen interval. They measure the request rate the external service sees, count throttling responses and confirm that the worker's concurrency limits and the worker-side rate limiting keep traffic inside the documented quota. Ask the vendor whether the staging environment shares limits with production. The step closes when the observed request rate stays within the documented limit at the planned concurrency, and the results and interval settings are recorded for the production change.
Using activity retries as a polling loop without overloading the API
A retry policy can stand in for an explicit polling loop when each poll is a single activity call that either returns the answer or fails in a way that means "try again later." The activity runs, the external service is queried, and if the call fails Temporal schedules another attempt using the activity's retry policy. The default policy uses exponential backoff with no maximum attempts, so an activity that keeps failing keeps retrying. That default is useful for transport errors, but it is a poor fit for a polling design unless you set maximumInterval and maximumAttempts yourself. Confirm the current default values in the Temporal documentation and in your SDK before relying on them, because the backoff growth shapes how quickly your workflow notices a change and how hard it hits the API.
The key design decision is to separate two kinds of answer. A transport error, such as a timeout or a 503 from the provider, should be retried by the policy. A business answer such as "not ready" is a normal result and should not be thrown as a failure that the retry policy reacts to, because the retry behavior then tracks infrastructure faults instead of your polling schedule. Return a typed result for not ready, and let the workflow decide when to call again with a timer. Where an error is genuinely permanent, such as a rejected request or an unknown resource ID, mark it non-retryable in the activity so the policy stops immediately. Pair this with a timeout that matches the provider's response time, since a slow API can otherwise hold an attempt open for a long time.
Every retry attempt is invisible in the workflow history unless you add visibility yourself. Raising the attempt limit gives the job more chances to succeed, but it also hides how often the provider is failing, and the history shows one activity that is still running. Lower limits surface problems sooner and push the decision back to the workflow, which can record each poll, alert on repeated failures, and stop after a business deadline. Use an explicit loop with a timer when operators need to see each check, and reserve long retry chains for transient faults. Detailed tuning of attempts, intervals and coefficients belongs to the retry policies topic, which covers each setting in depth.
Security and operational considerations for polling
Polling loops hold credentials, carry payloads and generate steady traffic against both the external API and your Temporal namespace. The cards below cover where those risks sit and what to configure before a polling workflow reaches production, from access control on the Temporal service to counting polls and failures.
Configure access control before production
If no Authorizer is configured, self-hosted Temporal uses the default noopAuthorizer, which allows every API request with no authentication or access control. Polling workflows often start from other services, so an open frontend lets any caller start, signal or query them. Confirm that a ClaimMapper and an Authorizer plugin are configured and tested before any polling workflow is promoted, and that the Temporal services run on hosts not reachable from the public internet.
Temporal security docsKeep API credentials out of workflows
Credentials for the external API should be read inside the activity that makes the call, never passed as workflow input or stored in workflow variables. Anything placed in workflow arguments or results is recorded in workflow history, where it persists for the life of the execution. Ask each team to confirm which secret store the worker reads from, how tokens rotate during a long poll, and how a rotated credential reaches workers that are already running.
Encrypt payloads with a codec
Poll responses and request parameters are stored as payloads in workflow history, and history is visible to anyone who can read the namespace. Payload encryption through a custom codec, with a codec server for the Web UI, keeps response bodies unreadable at rest and in the UI. Confirm who holds the encryption keys, how keys rotate, and whether the codec runs in the client process so that plaintext never reaches the Temporal service.
Limit who can reach the namespace
A polling workflow runs in a namespace, and anyone with access to that namespace can list, describe, signal or terminate its executions. Map roles to namespace access through the ClaimMapper, separate the workers that poll from the teams that operate the service, and review which identities can cancel a poll that is still running. Temporal's documentation describes mTLS with separate internode and frontend settings, which should be part of this design.
Monitor poll counts and failures
Each poll is an activity attempt, so the number of attempts per workflow and the failure rate per external status code show whether the polling rate matches what was designed. Track attempts that end in rate-limit responses separately from timeouts. Alert when attempts for one workflow type rise above the planned interval, since that usually means retries are masking a changed contract or a stuck dependency. Confirm which metrics your Temporal deployment exports and where they go.
Audit who changes polling behavior
Changes to poll intervals, retry policies or timeouts alter the load on a third-party API and can start sustained traffic without a code review. Keep these values in version-controlled workflow or worker configuration, require review for changes, and record which deployment version was running during an incident. Check that operators can answer which build polled which endpoint on a given day, using workflow history and deployment records together.
Questions teams ask before polling external services in Temporal
What drives the cost of a polling build in Temporal?
The cost is driven by how many external services you poll, how many workflows are waiting on each one, how the polling logic handles the provider's responses, and how much testing the integration needs. Most of the spend is design and engineering time, paid to whoever builds the workflows, activities and workers. Recurring costs come from running the Temporal Service, your workers and any Temporal Cloud usage. Ask any quote to separate one-time build work from recurring operations, and to state how many distinct external APIs and polling intervals are in scope.
How long does a polling implementation take?
Duration depends on the number of external services, how well their status endpoints are documented, whether rate limits and error codes are clear, and how many completion states each workflow must handle. Teams that already run Temporal workers and task queues move faster than teams starting from a new deployment. No supplied figure sets a standard duration, so ask for a timeline derived from the written scope, with milestones for the first polled service, load testing and production rollout.
What does the work need from our team?
You will need named owners for the external APIs being polled, someone who can provide sandbox credentials and rate limit terms, and engineers who can review workflow code and worker configuration. Security and operations staff should review where workers run, how secrets reach activities and who receives alerts. Expect to provide access to test accounts and to agree on the completion signals each business process needs. Confirm these roles in the scope before work starts so decisions do not stall the build.
Can our own engineers build a polling workflow without a partner?
Yes, if your team already knows the Temporal SDK you use and can run workers reliably. The Temporal programming model is code-first, so a team with strong application engineering skills can write a polling loop using activities, retry policies and timers. The harder parts are protecting the provider from load, handling partial failures without duplicate side effects, and testing workflow changes safely. A partner is most useful when the team lacks Temporal experience or when the work must be reviewed before production.
When is polling the wrong choice for waiting on an external service?
Polling is a poor fit when the provider can send a webhook or callback reliably, when the wait is very long and the status changes rarely, or when the provider's rate limits cannot absorb your poll volume. Polling also creates load on the provider and cost on your side even when nothing has changed. If the provider offers signals, events or a message queue, compare that design with polling before you commit. Ask the provider what it supports and what its limits are, then confirm the choice in writing.
How do Temporal Cloud pricing components relate to poll volume?
Temporal Cloud pay-as-you-go pricing starts at 50 US dollars per million actions, and it also charges active storage at 0.042 dollars per GB-hour and retained storage at 0.00105 dollars per GB-hour, according to the Temporal pricing page. Each poll attempt that runs as an activity or is recorded in workflow history adds to the action count and the stored history. Frequent polling therefore raises both the action count and the storage that long-waiting workflows accumulate. Model your expected poll count per workflow and the wait duration before comparing options.
How do we protect the external service from too many polls?
Set a poll interval that matches how quickly the status can change, use exponential backoff in the retry policy, cap concurrency on the task queue, and add jitter so many workflows do not poll at the same moment. Honor any rate limit headers the provider returns. Test the design with a load profile that reflects your peak number of waiting workflows. Confirm the provider's terms on polling frequency before production, since acceptable intervals vary by provider.
Does the security review change the polling design?
Yes. Credentials used by polling activities should come from a managed secret store, not workflow code or payloads, and access to the Temporal Service should be restricted to trusted internal networks. Self-hosted Temporal with no Authorizer configured allows every API request, so confirm authorization before workers connect. Decide whether polled responses contain personal or regulated data, since that determines payload encryption and retention. Ask your security team to review these points before the build starts.
How DeployOpen scopes and delivers polling workflows on Temporal
DeployOpen plans, implements, hardens, documents and supports self-hosted open-source platforms inside your own infrastructure, including Temporal. For polling external services, we agree the polling design, worker and service boundaries, and the security controls in writing before build starts, then deliver and hand over the working system.
How we scope
- Inventory every third-party API the workflows will poll, with its rate limits, error behavior and terms of use.
- Agree the polling interval strategy, timeout and retry settings, and the backoff rules for each external service.
- Confirm the deployment target, persistence and visibility stores, and whether self-hosted Temporal or Temporal Cloud is in scope.
How we build
- Implement polling workflows with activity retries as the polling loop, using heartbeats where a check runs long.
- Configure concurrency caps and task queue limits so workers cannot overwhelm the external service during peak load.
- Test workflows with replay, simulated slow and failing APIs, and retry scenarios before any staging rollout.
How we hand over
- Deliver workflow code, worker deployment manifests and configuration with documented polling intervals and limits.
- Document runbooks for stuck polls, paused workflows, versioning changes and worker restarts for your operators.
- Walk your engineers through the design decisions and trade-offs so your team can change polling behavior safely.
How we support
- Engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts.
- Ongoing support, upgrades and continuous testing are available as a retainer after handover.
- Ask any partner for a written quote that lists the polling services, environments and deliverables it covers.

