Development and QA

Polling the SMS API: intervals, Retry-After and a stopping rule

Observe orders with one controlled polling loop, shared account limits, delays after temporary errors and a clear stop after a terminal result.

Four connected nodes represent the catalog, a quote, an order and a received message.

Frequent polling does not make an SMS arrive sooner. It adds requests and makes errors harder to interpret. Use one controlled observer per order instead of starting a timer in every tab or task.

Follow the documented interval

Lucky Monkey documentation recommends checking each order no more often than every five seconds. Account-wide limits also matter: several keys do not create separate request budgets for one owner.

Keep observation separate from purchase creation. Repeating a status GET does not require a new order, and a failed read does not justify another purchase.

Handle temporary errors deliberately

For 429, wait for Retry-After. After connection problems, use a bounded increasing delay with modest jitter to avoid synchronized retries. Do not start another observer while an existing one still owns that order.

  • Preserve one order ID for the operation.
  • Avoid overlapping requests.
  • Distinguish connection failures from order states.
  • Stop ordinary polling after a documented terminal outcome.

Waiting is not automatically failure

allocating, pending and waiting describe different stages. Keep the same ID while pending is being reconciled instead of creating another purchase. Check the current contract for exact state meanings.

Test the observer with fixtures

Simulate delayed responses, 429, temporary unavailability and completion in staging. Confirm that polling stops after the result and that uncertainty is visible to the user. Read the API documentation and safe creation-retry guide.

Sources and further reading

← All articles