Your data

How two-way Airtable sync works: a Postgres mirror, an outbox and webhooks

How Emberblocks mirrors an Airtable base into Postgres, pushes app edits back through an outbox and takes in Airtable's changes through webhooks.

Founder, Emberblocks

Published 13 min read

On this page
  1. Why mirror the base instead of calling Airtable on every page view?
  2. Step 1: the first import, and why the webhook comes first
  3. Step 2: edits in the app go out through an outbox
  4. Step 3: changes made in Airtable come back through webhooks
  5. What happens when both sides edit the same record?
  6. Which Airtable field types sync, and which are read-only?
  7. What this means if you run on Airtable today

Emberblocks keeps a copy of your Airtable base in Postgres. Your app reads and writes that copy at database speed, your edits push back to Airtable within seconds, and changes made in Airtable arrive through Airtable's own webhooks. The base stays where it is, and it stays the place where the structure lives. This article walks through each piece in the order the sync engine runs it: the first import, the outbox for outgoing edits, the webhooks for incoming ones, conflicts and recovery, and the field types that make the trip.

Why mirror the base instead of calling Airtable on every page view?

Airtable's Web API allows 5 requests per second per base. Go over it and you get a 429 response and have to wait 30 seconds before requests work again. A list call returns at most 100 records, with an offset to fetch the next page. Those limits are fine for a script that runs at night. They are tight for an app where a dozen people open screens at nine in the morning, each screen showing a filtered table, a count, a chart and a search box.

A front-end that calls the API on every page view spends that budget on reads. Every filter Airtable cannot express has to run after the records arrive, which means fetching more pages. A busy morning turns into 429s and a spinner. So Emberblocks never puts the API in the path of a page view. Each Airtable source gets its own Postgres schema holding one table per Airtable table. Apps read and write those tables like any other database. The API is only ever called by the sync engine, which paces itself and can wait.

SituationCall the API on every viewRead a Postgres mirror
A page viewOne or more API calls, 100 records eachOne SQL query, no API call
Filters, sorts, search, formulasLimited to what the API supports, the rest after fetchingRun in Postgres on every field
Airtable slow or rate-limitedThe screen waits or failsThe app keeps working; edits wait in the outbox
Changes made in AirtableVisible on the next callArrive when Airtable's webhook reports them
The two designs side by side.

The last row is the honest cost. A mirror is a copy, so a change made in Airtable reaches the app when the webhook reports it, not at the instant it is typed. The rest of this article is about keeping that copy correct.

Step 1: the first import, and why the webhook comes first

Connecting a base takes a personal access token with four scopes (data.records:read, data.records:write, schema.bases:read and webhook:manage) and the base id. The connect then runs in this order:

  1. Check the token and read the schema. The Meta API returns every table and field with its type and options.
  2. Map the schema. Each Airtable table becomes a Postgres table and each field a column (the mapping is in the last section). The map is keyed by Airtable's table and field ids, not their names, so renaming a field in Airtable later is a label change, not a broken sync.
  3. Create the mirror tables.
  4. Register one webhook for the whole base, watching record data and field changes, and asking Airtable to include cell values in its payloads.
  5. Import every record, table by table, 100 per page. Each mirror row is linked to its Airtable record id. Attachments are downloaded and re-hosted while their URLs are still fresh.
  6. Mark computed and complex fields read-only, so the app's forms and tables cannot edit them.

The interesting part is step 4 coming before step 5. Importing a large base takes time, and people keep working in Airtable meanwhile. If the import ran first and the webhook was registered afterwards, an edit made to a record after the import had read it, but before the webhook existed, would never be seen: no payload would record it, and the mirror would hold the old value until someone noticed.

Registering the webhook first closes that gap. Every change made during the import lands in the webhook's payload log, and the log is left untouched with its cursor at the start. The first pull after the connect replays it. Some changes are then seen twice, once by the import and once by the payload. That is harmless: the pull matches records by their Airtable id and writes their values in place, so replaying a change the import already holds leaves the row as it was.

Step 2: edits in the app go out through an outbox

Every write to a mirror table passes through one place in Emberblocks' data gateway. For a table that belongs to an Airtable source, that place does three things in one database transaction: it writes the row, it adds an entry to an outbox table describing the change (the columns touched and their new values), and it stamps the record's "last changed here" time from the database clock. Either all three commit or none do. An edit cannot be saved without being queued, and nothing is queued for an edit that rolled back.

Because the hook sits under every write path, everything that changes a row feeds the outbox: forms, inline table edits, single and bulk actions, CSV imports into the table and generated sample data. Draft and published versions of an app both write to the same mirror, so both push.

After the commit, a short debounce starts a drain for that source. The drain never holds up the person who clicked Save: their response comes from Postgres, and the push happens beside it. If the server restarts before the drain runs, nothing is lost. The outbox entry is still in its table, and a scheduled sync tick works off anything left due.

What a drain does

  1. Takes the source's lock. One sync job per source runs at a time, so a drain, a pull and a full re-sync never overlap. That rules out races such as an incoming change arriving before a push has recorded its new Airtable id, which would otherwise create a duplicate.
  2. Folds the queue per record. Several edits to one record merge into one update, latest value per field. A record created and deleted before it was ever pushed cancels out with no API call at all.
  3. Drops read-only fields. Formulas, lookups, attachments and linked records are never sent.
  4. Sends creates, updates and deletes in batches of up to 10 records, paced to four requests a second per base, one under Airtable's limit. If Airtable still answers 429, that base pauses for 30 seconds.
  5. Records the result. A new record's Airtable id is saved on its link, along with a hash of exactly the fields that were sent. The pull uses that hash to recognise the change when it comes back.

Failures take a fixed path, so the queue never jams. A transient error retries with exponential backoff, capped at five minutes between attempts. An entry that fails 10 times moves to the source's Apply errors list and leaves the queue. An update or delete that finds the record already gone in Airtable means someone deleted it there, and the delete wins. A rejected token marks the source with an error asking you to check the token and its scopes.

Step 3: changes made in Airtable come back through webhooks

Airtable's webhook notification is only a ping: a short message with the base id and the webhook id, saying that something changed. The content of the change has to be fetched separately. Emberblocks' notify endpoint checks the ping's signature (an HMAC over the raw request body, using the webhook's secret, which is stored encrypted) and answers straight away. The pull runs separately, so Airtable never waits on it. Before answering, the endpoint sets a "needs pull" flag on the source, so if the pull is lost (a serverless instance frozen mid-run, say), the next scheduled tick does it instead.

The pull takes the same per-source lock and lists the webhook's payloads from the stored cursor, page by page. Each payload says, per table, which records were created, changed or destroyed, with their cell values. Each record is then applied in its own transaction:

  1. Echo check. If the incoming values hash to the same value the drain stored when it pushed, this is the app's own edit coming back around. It is skipped.
  2. Recency check. If the app changed the record more recently than Airtable did, the incoming change is skipped (the next section has the details).
  3. Apply. A changed record updates its mirror row, touching only the fields that changed. A record born in Airtable gets a new mirror row and a link. A destroyed record deletes its mirror row and link.

Three rules keep the pull from losing or doubling anything. The cursor is saved only after a page has been applied, and it never moves backwards, so a crash replays the page rather than skipping it. Whole payloads are skipped when their Airtable transaction number has already been seen. And a ping that arrives while a pull is running sets the flag again, which the running pull checks before it lets go of the lock.

A pull also never stalls on one bad record. A record that cannot be applied (a value the mirror column rejects, for example) goes to the Apply errors list and the rest of the page carries on. Connection failures are treated differently: they stop the pull before the cursor moves, so the page is retried instead of written off. Once a pull has changed something, screens that show those tables are told to refetch, so people see Airtable's edits without reloading.

Attachments and webhook renewal

Airtable attachment URLs are signed links that expire after a few hours, so they are never stored in the mirror. Each file is downloaded and re-hosted in Emberblocks' storage under its stable Airtable attachment id, and unchanged attachments are not downloaded again. If an old payload's links have already expired, the pull fetches the record fresh for new ones. Files over 10 MB keep their name and size in the mirror without the file, and show up as an apply error rather than blocking the sync.

Airtable disables a webhook created with a personal access token after 7 days unless it is refreshed. The scheduled tick refreshes each source's webhook once it is within two days of expiring.

What happens when both sides edit the same record?

Conflicts are settled by last write wins, per record. Every app write stamps the record's "last changed here" time, and every Airtable payload carries Airtable's timestamp. When a change comes in from Airtable:

  • The Airtable change is newer: it is applied, and any of that record's outbox entries queued at or before its timestamp are cancelled. Without that, a stale app edit still waiting in the queue could push old values over the newer ones a moment later.
  • The app change is newer: the incoming change is skipped and the outbox entry is kept. The app's edit pushes and becomes Airtable's value too.

In practice the two sides collide only in the short window before an app edit has been pushed. Once it has been pushed, both sides hold the same value, and a later Airtable edit simply applies. Because the rule works per record, not per field, the newer side wins a collision in that window even if the two people touched different fields, and the older edit is not carried over. If a record looks out of step afterwards, Full re-sync (below) makes the mirror match Airtable again.

The two timestamps come from two clocks, Postgres's and Airtable's, so nothing that has to be exact depends on comparing them. Echo detection uses content hashes, and payload dedupe uses Airtable's transaction numbers. Neither is fooled by clock drift.

  • Deletes travel both ways and beat edits. A record deleted in Airtable drops any pending app edit to it. A record deleted in the app is deleted in Airtable. Deleting something already gone is a no-op on either side.
  • Structure changes never apply themselves. When a payload reports new or changed fields or tables, the source shows that Airtable's structure changed. Refresh schema adds new tables and fields and widens select options. Fields removed in Airtable are reported and kept in the mirror, never silently dropped.
  • Pull now runs a pull immediately, for when you would rather not wait for the next ping.

Full re-sync, for when the trail goes cold

If the webhook expired or its cursor is no longer valid (the scheduled tick did not run for a week, for instance), the gap cannot be reconstructed from payloads. The source then shows a sync-gap warning, and Full re-sync is the repair. It holds the source's lock for the whole run and:

  1. registers a fresh webhook first, if the old one is gone;
  2. reads every record from Airtable and updates or inserts its mirror row by Airtable id;
  3. deletes mirror rows whose Airtable record no longer exists, except rows with app edits still waiting to push, so unpushed work survives;
  4. moves the payload cursor to the end, since the records it just read already include those changes.

Which Airtable field types sync, and which are read-only?

The mapping is automatic. Plain values map to an editable column in both directions. Computed and complex fields sync from Airtable only, and the app treats them as read-only: forms and tables cannot edit them, and pushes leave them out.

Airtable field typeIn the mirrorEditable in the app
Single line text, long text, rich textTextYes
Email, URL, phone numberEmail, URL, phoneYes
Number, currency, percent, ratingNumberYes
DurationDuration (seconds)Yes
CheckboxYes/noYes
Date, date and timeDate, date and timeYes
Single selectSelect with the same options (up to 50)Yes
Formula, rollupThe result's type when it is a plain value, otherwise JSONNo
Count, autonumber, created time, last modified timeNumber or date and timeNo
AttachmentsA list of re-hosted filesNo
Multiple select, linked records, lookups, collaborators, created by, last modified by, barcode, button, AI textJSONNo
Any type the engine has not seen beforeJSONNo
As mapped by the sync engine today.

Two edge cases. A single select whose choices are all unusable (empty, over 100 characters or containing control characters) maps to plain text. And the mirror holds up to 50 tables and up to 60 fields per table, so a wider table stops the connect with a message naming it.

Read-only does not mean invisible. A formula result still shows, filters and sorts like any other column of its type, Emberblocks formulas can compute on top of it, and a linked-record field still holds the ids of the records it points to. What you cannot do from the app is change those fields. Edit them in Airtable and the change arrives through the webhook.

What this means if you run on Airtable today

The design gives Airtable teams a front-end without asking them to move. The base stays the source of truth for structure, and the people who live in Airtable's grid keep working there. Staff, field teams and clients get an app with roles and per-user rows that reads Postgres, so it stays fast however busy the morning is. That is the setup the Airtable front-end page describes, and the hedge suggested in what to do after Airtable's Bending Spoons acquisition.

If the screens your team relies on today are Airtable Interfaces, the Airtable Interfaces migration guide maps each page type to a block. If you are weighing a full move, the Airtable alternatives page compares the options, and the data sources guide covers the setup steps.

Where the mirror falls short, plainly:

  • Linked records, attachments, multiple selects and lookups are read-only in the app.
  • Conflicts are settled per record, not per field.
  • Structure changes need a click on Refresh schema; they are never applied automatically.
  • One source mirrors one base, and a source holds as many rows as its row cap allows.
  • Airtable comments, views and permissions are not synced. Roles in the app are set up in Emberblocks.

Questions people ask

Does Emberblocks call the Airtable API when someone opens a page?
No. Every page view reads the Postgres mirror. Only the sync engine calls the API, to push app edits, to fetch webhook payloads and to re-read the base during a full re-sync.
How quickly do edits travel between the app and Airtable?
Edits made in the app push back to Airtable within seconds, through the outbox. Changes made in Airtable arrive when Airtable's webhook reports them and the pull applies the payload.
What happens if Airtable is down or rate-limits the sync?
The app keeps working on the mirror. Outgoing edits wait in the outbox and retry with backoff; a 429 pauses that base for 30 seconds. Incoming changes wait in the webhook's payload log until the next pull.
Can I edit linked records and attachments from the app?
Not yet. Linked records, attachments, multiple selects, lookups and computed fields sync from Airtable and are read-only in the app. Edit them in Airtable and the change comes through the webhook.
What happens when I add a field in Airtable?
The source shows that Airtable's structure changed. Click Refresh schema and the new field appears as a new column. Fields you remove in Airtable are reported and kept in the mirror.

Sources

  1. Airtable Web API: rate limits
  2. Airtable Web API: list records
  3. Airtable Web API: webhooks overview
  4. Airtable Web API: create a webhook
  5. Airtable Web API: list webhook payloads
  6. Airtable Web API: webhooks specification
  7. Airtable Support: attachment URL behavior

Written by

Apostolos builds Emberblocks, a visual app builder for internal tools on your own data, from Thessaloniki, Greece. Spotted something wrong or out of date? Write to hello@emberblocks.com.

Keep reading

Ready to build on your own data?

Connect Postgres, Airtable or a spreadsheet export and publish a working app your team can use today. Builders are always free.