> ## Documentation Index
> Fetch the complete documentation index at: https://docs.maesn.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Keeping data fresh

> Learn best practices for keeping accounting data up to date using syncs and webhooks.

The two main strategies for keeping data up-to-date: By subscribing to updates from Webhooks or through regular polling. This page gives guidance on implementing polling efficiently.

<Steps>
  <Step title="Save your customer's Account Key">
    Get the account key from the connection process for an embedded maesn Connect link. Learn more in our [maesn Connect guide](/guides/maesn-connect).

    To authenticate your API requests to maesn, save your end users' account key in your backend. The account key will be required to poll for data in the steps below.
  </Step>

  <Step title="Synchronize data easliy & efficiently">
    Ensure that you store the timestamp of when you last fetched data from maesn as 'lastModified'. Use this timestamp in subsequent API requests to get only the data that was updated since your last GET call.
    For example, you can request `lastModified=2021-03-30T20:44:18`, and only fetch objects that are new or changed.

    ```javascript Example code snippet theme={null}
        const response = await axios.get(url, {
            params: {
                "lastModified": lastModified
            },
            headers: {
                'X-API-KEY': apiKey,
                'X-ACCOUNT-KEY': accountKey
            }
        });
    ```
  </Step>

  <Step title="Poll with the lowest viable frequency">
    Determining the optimal polling frequency is a trade-off between how fresh the data you operate on needs to be and the network traffic volume (and the associated costs) incurred.

    As an example, it would be wasteful to poll for updates every minute, if the data we are polling for is only updated once a day. On the other hand, presenting the user with stale date may degrade the user experience or even lead to errors.

    Thus, it is important to choose a polling-frequency that is high enough to provide the best possible user experience, but at the same time doesn't incur unnecessary cost. In addition, consider the [rate-limits](/rate-limits) of the maesn API and the 3rd party systems.
  </Step>
</Steps>
