Skip to main content
Most integrations need data from several Stora resources — sites, unit types, prices, coupons, protection levels, and more. Fetching these resources from Stora on every application request adds API round trips, uses your rate-limit allowance, and makes each request depend on API availability. A better approach is to maintain a local copy of the data you need and keep it in sync. This guide covers what to cache, how to structure your sync, and how to use webhooks to keep your local data fresh.

Why cache locally?

Three reasons to keep a local copy of Stora data:
  1. Rate limits — The API allows 10 requests per second and 60 per minute. A booking flow that fetches sites, unit types, prices, products, protection levels, and coupons on every page load will burn through that budget fast.
  2. Latency — Serving cached data from your own database avoids multiple Stora API round trips per request.
  3. Resilience — If the Stora API is temporarily unreachable, your integration can continue to serve cached data rather than failing entirely.
Caching is especially important for customer-facing flows like booking, where perceived speed directly affects conversion rates.

What to cache

Not all resources change at the same rate. Grouping them by how often they change helps you decide what to cache and how aggressively.

Tier 1: near-static resources

These represent the physical and commercial structure of a storage business. They change rarely — typically only when an operator reconfigures their offering. Cache these aggressively. They’re ideal candidates for a long-lived local cache that’s only invalidated when you receive a webhook or detect a change via polling.

Tier 2: business-event driven

These change when an operator takes a deliberate action — updating pricing, creating a promotion, or adjusting protection options. Changes are infrequent but meaningful. Cache these and invalidate on webhooks. When you receive a unit_type.updated, coupon.updated, or protection_level.updated event, re-fetch the affected resource to pick up the new data.
Price changes on unit types and protection levels trigger their respective .updated webhooks. Use these to keep cached pricing current, including Unit Type live_prices used by booking flows.

Tier 3: transactional

These change with customer and operational activity — bookings, payments, status changes. They update frequently and are often specific to a single transaction. Cache selectively based on your use case. You probably don’t need a full local copy of every invoice — but if you’re building a dashboard that shows unit occupancy across sites, caching unit status and keeping it fresh via webhooks makes sense.

Architecture

A typical caching architecture has three components:
  1. Local data store — A database or cache that holds copies of Stora resources. This is what your application reads from.
  2. Sync worker — A background process that receives webhooks, fetches fresh data from the API, and updates your local store.
  3. Your application — Reads exclusively from the local store, never directly from the Stora API during user-facing requests.
Your local store can be as simple as a Redis cache or as structured as a dedicated database table per resource type. Choose based on your query needs — if you need to filter or join across resources, a database is worth it.

Syncing multiple operators

Partner apps and developers managing several operator accounts must keep sync state separate for each connected operator. Associate snapshots, page progress, polling checkpoints, local resource mappings, and queued work with that operator connection. Never let a checkpoint or currently selected token from one operator control another operator’s sync. Run an initial sync for each newly connected operator. Reuse a previous checkpoint only for the same operator when you have a trustworthy, completed checkpoint and its corresponding local data. Otherwise, repeat the snapshot and reconciliation procedure below. Use the verified webhook connection context when queueing work and choosing credentials.

Initial sync

Register your webhook endpoint and durably retain incoming events before you fetch the initial data. Record the sync-start timestamp for each resource type, then paginate through the resources you want to cache. Buffer events until the snapshot is stored so a snapshot write cannot overwrite a newer event update.
Use the pagination metadata in each response to iterate through all pages:
Continue fetching until next is null. After storing the snapshot, reconcile buffered events by re-fetching each affected resource. Webhook delivery order is not guaranteed, so do not overwrite current data with older payloads. Serialise updates per resource so concurrent fetches cannot overwrite newer results. Retry failed reconciliation work. For resources with time-range filters, run a catch-up poll from just before the recorded sync-start timestamp. See Polling with updated_after for checkpoint handling. Continue retaining events during reconciliation, then process them as they arrive. Schedule periodic reconciliation to recover changes missed during delivery failures.

Working within rate limits

With a limit of 60 requests per minute, a full initial sync takes time — especially for operators with large inventories. Some practical tips:
  • Prioritise by tier. Sync near-static resources (Tier 1) first, since they’re the most widely needed and least likely to change mid-sync.
  • Pace your requests. Apply limits per operator, not per token or across your entire service. Stay below each operator’s rate limit to leave headroom for its other API activity.
  • Run during quiet periods. If possible, run your initial sync outside business hours when other API usage is low.
  • Track progress. Record the last page you successfully synced so you can resume if the process is interrupted.
Estimate initial-sync requests from each collection’s size and page limit. With limit=100, fetching 2,000 units, 50 unit types, 200 products, and 10 sites takes about 24 requests: 20 for units, one for unit types, two for products, and one for sites. This excludes additional resources and retries.

Keeping your cache fresh with webhooks

Once your initial sync is complete, webhooks are the primary mechanism for keeping your cache up to date. When a resource changes in Stora, a webhook event is sent to your endpoint — your sync worker receives it and re-fetches the affected resource.

The pattern

1

Receive the webhook event

Your endpoint receives a POST request with the event payload. Verify the signature and durably enqueue the event before returning 2xx. If enqueueing fails, return a non-2xx response so Stora can retry.
2

Identify the affected resource

In a background worker, use event.type to determine what changed and event.data to identify the resource.
3

Update your local store

Re-fetch the resource and upsert it in your local store. Serialise updates per resource to prevent concurrent writes from applying older results. You can use the event payload directly if you reject stale updates. Retry worker failures from your queue because Stora does not retry acknowledged deliveries.

Which events to subscribe to

Subscribe to the events that match the resources you’re caching. Here’s a mapping of resources to their relevant webhook events:
Some resources — sites, products, product categories, contract templates, and staff — don’t have webhook events yet. For these, rely on polling with updated_after as described in the next section.

Using the event payload directly

Webhook payloads include the full resource in event.data. You can update your local store from the payload if you prevent older events from overwriting newer data. Otherwise, use the event to trigger a re-fetch.
If your cache needs expanded relationships (e.g., a unit type with its site), you may need to re-fetch from the API with the appropriate expand parameter instead.

Catching up on missed updates

Stora makes up to six delivery attempts, including the initial attempt. The five retry delays total approximately 20 hours 35 minutes, excluding request duration and job scheduling. Use polling to recover after retries are exhausted and to refresh resources without webhook events.

Polling with updated_after

The updated_after filter lets you fetch only resources that have changed since a given timestamp. This is the primary mechanism for:
  • Recovering from missed webhooks — after extended downtime, resume polling each resource type from its last completed polling checkpoint, with an overlap.
  • Syncing resources without webhooks — for resources like sites, products, and staff that don’t emit webhook events, periodic polling is the only option.
For each resource type that supports these filters, maintain a separate checkpoint for each connected operator:
  1. Record the poll-start timestamp before requesting the first page.
  2. Set updated_after to a time before the previous completed polling checkpoint. Choose an overlap that accounts for timestamp precision and clock differences.
  3. Use the same filter values for every page. You can set updated_before to the poll-start timestamp to bound the range.
  4. Fetch and apply every page. Upsert by resource ID and prevent older results from overwriting newer data.
  5. Save the poll-start timestamp as the new checkpoint only after all pages and local writes succeed. If the poll fails, keep the previous checkpoint and retry.
Do not use the poll-completion time as the checkpoint. An update made during pagination could fall before that time without appearing in the pages you fetched. Overlapping ranges repeat some records, so processing must be idempotent. Use a full reconciliation for resources without time-range filters or when you cannot establish a trustworthy checkpoint. Polling is a fallback, not a primary strategy. Use conservative intervals that respect rate limits:
Keep polling checkpoints separate from webhook-processing timestamps. A webhook for one resource does not prove that all changes before its timestamp have been synchronised.

Combining webhooks and polling

The most robust approach uses both strategies together:
  • Webhooks handle the common case — near real-time updates for resources that support them.
  • Polling handles the edges — resources without webhooks, recovery after downtime, and a safety net against missed events.
Use webhooks for prompt updates and periodic reconciliation to recover missed changes. Monitor queue failures and polling checkpoints so you can detect when the cache stops updating.