Polling usage
Implementation guide for the polling pattern in Tradecloud API v2
Last updated
Implementation guide for the polling pattern in Tradecloud API v2
Last updated
The polling API offers an alternative to the webhook API for retrieving order or shipment updates. Both approaches have different advantages and considerations:
The polling pattern consists of three essential steps:
Fetch - Retrieve orders or shipments changed since the last poll
Process - Handle the retrieved new or updated data
Persist - Store the latest timestamp for the next polling cycle
Set up a scheduled process to fetch all orders or shipments that have been created or changed since your last poll.
Use a consistent polling interval (typically 5 minutes)
Include the lastUpdatedAt
from previous poll response as the lastUpdatedAfter
filter
Set limit=100
(maximum allowed value) to control response size
Handle pagination when needed:
If response contains total
> 100, not all updates were returned
Either decrease the polling period (recommended) or use offset
parameter for paging
Orders (delivery schedule)
For orders using delivery schedule feature
Orders (single delivery)
For orders using single delivery per line
Shipments
For shipment updates
Implement logic to handle the fetched new or updated orders or shipments.
When working with order endpoints:
Use data.lines.lastUpdatedAt
to identify which specific lines changed since the lastUpdatedAfter
time you provided.
Filter by status using data.lines.status
fields:
processStatus
inProgressStatus
logisticsStatus
deliveryLineStatus
When working with shipment endpoint:
Use data.lines.meta.lastUpdatedAt
to identify changed shipment lines since the lastUpdatedAfter
time you provided.
Filter by data.status
to focus on relevant shipment statuses
Store the lastUpdatedAt
value to use as lastUpdatedAfter
in subsequent requests.
When the poll response is empty, keep using the same timestamp until you get results.
The timestamp has format YYYY-MM-DDThh:mm:ss.SSSZ
(ISO 8601)
Store this in persistent storage (database, file system, etc.)
Your storage solution must survive application restarts or crashes
If the response contains no data, reuse your current lastUpdatedAfter
value
For first-time polling, use a historical date to fetch existing records
Your poll results may include outdated data in case of a request. See for managing outdated data.