{"templateId":"markdown","sharedDataIds":{},"props":{"metadata":{"markdoc":{"tagList":[]},"type":"markdown"},"seo":{"title":"Events - Mailgun Send","siteUrl":"https://documentation.mailgun.com","llmstxt":{"title":"Mailgun Documentation","description":"LLMS.txt containing a map of all the documentation files for Mailgun.","sections":[{"title":"Mailgun Send Documentation","description":"All of the Mailgun Send documentation.","includeFiles":["docs/mailgun/**/*.md"],"excludeFiles":["docs/mailgun/index.md"]},{"title":"Mailgun Send OAS","description":"All of the Mailgun Send API specifications.","includeFiles":["docs/mailgun/**/mailgun.yaml"],"excludeFiles":[]},{"title":"Mailgun Optimize Documentation","description":"All of the Mailgun Optimize documentation.","includeFiles":["docs/inboxready/**/*.md"],"excludeFiles":["docs/inboxready/index.md"]},{"title":"Mailgun Optimize OAS","description":"All of the Mailgun Optimize API specifications","includeFiles":["docs/inboxready/**/inboxready.yaml"],"excludeFiles":[]},{"title":"Mailgun Validate Documentation","description":"All of the Mailgun Validate documentation.","includeFiles":["docs/validate/**/*.md"],"excludeFiles":["docs/validate/index.md"]},{"title":"Mailgun Validate OAS","description":"All of the Mailgun Validate API specifications.","includeFiles":["docs/validate/**/*.yaml"],"excludeFiles":[]},{"title":"Mailgun Inspect Documentation","description":"All of the Mailgun Inspect documentation.","includeFiles":["docs/inspect/**/overview.md"],"excludeFiles":[]},{"title":"Mailgun Inspect OAS","description":"All of the Mailgun Inspect API specifications.","includeFiles":["docs/inspect/**/*.yaml"],"excludeFiles":[]}],"hide":false,"excludeFiles":[]},"description":"Event polling regularly checks or queryies the API to retrieve updates on email activities—such as deliveries, opens, clicks, bounces, or failures—instead of receiving them automatically through webhooks."},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"event-polling","__idx":0},"children":["Event Polling"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["In our system, events are generated by physical hosts and follow different routes to the event storage. Therefore, the order in which they appear in the storage and become retrievable - via the events API - does not always correspond to the order in which they occur. Consequently, this system behavior makes straight forward implementation of event polling miss some events. The page of most recent events returned by the events API may not contain all the events that occurred at that time because some of them could still be on their way to the storage engine. When the events arrive and are eventually indexed, they are inserted into the already retrieved pages which could result in the event being missed if the pages are accessed too early (i.e. before all events for the page are available)."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["To ensure that all your events are retrieved and accounted for, please implement polling in the following way:"]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Make a request to the events API specifying an ascending time range that begins sometime in the past (e.g. half an hour ago)"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Retrieve a result page"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Check the timestamp of the last event on the result page. If it is older than the threshold age (e.g. half an hour), then go to step (4), otherwise proceed to step (6)."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["The result page is trustworthy, use events from the page as you please."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Make a request using the next page URL retrieved with the result safe, proceed with step (2)."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Discard the result page for it is not trustworthy."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Pause for some time (at least 15 seconds)"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Repeat the previous request and processed with step (2)."]}]}]},"headings":[{"value":"Event Polling","id":"event-polling","depth":1}],"frontmatter":{"seo":{"title":"Events - Mailgun Send","description":"Event polling regularly checks or queryies the API to retrieve updates on email activities—such as deliveries, opens, clicks, bounces, or failures—instead of receiving them automatically through webhooks."}},"lastModified":"2025-10-02T00:09:01.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/docs/mailgun/user-manual/events/event-polling","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}