Skip to content
James Ross
articlePublished Updated 8 min read

Capture-first connectors: building integrations before the credentials exist

By James Ross

A capture-first connector builds the request it would send, validates it against the provider's contract, records the exact payload, and stops before opening a socket. It produces durable evidence that the mapping, idempotency and state transitions are correct while the account, credentials or certification do not yet exist. The point is not to fake an integration; it is to make the untestable part small and visible.

A connector plug stopped at a glass wall before a socket while a recorder captures the payload, illustrating capture-first connectors.

This is the connector discipline used in a multi-brand commerce control plane, where every provider rail is capture-only or disabled and the network path fails closed until an activation gate passes. The same pattern is worth copying in any project that has to build against a vendor whose sandbox is weeks away.

What a capture-first connector actually records

A capture connector implements the same interface as a live adapter. It validates the input with the shared schema, builds the canonical request, computes a fingerprint and an idempotency key, writes a capture record with the payload and the intended destination, and returns a typed result that says, in effect: accepted locally, not transmitted.

That record is the artifact. It contains the provider and mode, the business key, the request fingerprint, the correlation ID, the adapter version, the validation outcome, and the raw payload with secrets excluded. It does not contain a token, a password or a live account identifier.

The value shows up in three places. A reviewer can read the exact payload that would have been sent and compare it with the vendor’s specification. A test can assert that the mapping produces the same bytes for the same input. And an operator can see, months later, which contract version a fixture was captured against.

The failure mode this prevents is the expensive one: discovering at certification that the field everyone assumed was optional is required, and that the mapping has been wrong since March.

Request fingerprinting: canonicalise, then hash

A request fingerprint is a hash of a canonical serialisation of the business request, used to tell “the same request again” apart from “a different request with the same key”. It only works if the serialisation is stable: key order, whitespace, null versus absent, number formatting and timestamp precision all have to be decided once and enforced everywhere.

A short, dependency-free canonicaliser is enough:

import { createHash } from "node:crypto";

function stable(value: unknown): string {
  if (value === null || typeof value !== "object") return JSON.stringify(value);
  if (Array.isArray(value)) return `[${value.map(stable).join(",")}]`;
  const record = value as Record<string, unknown>;
  const keys = Object.keys(record).sort();
  return `{${keys.map((k) => `${JSON.stringify(k)}:${stable(record[k])}`).join(",")}}`;
}

const fingerprint = (payload: unknown) =>
  createHash("sha256").update(stable(payload)).digest("hex");

Three rules keep fingerprints useful. Exclude volatile fields such as a generated request ID or a retry timestamp, or every retry looks like a new request. Include every field that changes the business meaning, or a changed price hashes the same as the original. Never include a secret in the payload you hash, because the fingerprint and the payload tend to end up in the same table.

The fingerprint is not the idempotency key. The key identifies the business intent and must survive a retry; the fingerprint identifies the payload and catches a key that was reused for different content. Storing both is what makes the conflict case detectable.

Idempotency: replay is not a conflict

Idempotency in a connector means a repeated request produces one business effect. The cases that matter are easy to state and easy to get wrong:

Case Key Payload Correct behaviour
Retry after a timeout Same Same fingerprint Return the original accepted result; do not create a second effect
Reused key, changed content Same Different fingerprint Reject with a conflict; do not overwrite the first result
New intent, same content New Same fingerprint Create a new effect; content identity is not intent identity

The first case is the one everybody implements. The second is the one that protects the ledger, because a connector that happily overwrites state on a key collision will eventually overwrite a posted transaction with a corrected one and lose the audit trail. The connector test matrix makes both cases explicit, with the conflict case asserting that no state is overwritten. Shopify’s inventory mutation exposes the same distinction as error codes: IDEMPOTENCY_KEY_PARAMETER_MISMATCH when a key is reused with different parameters, and IDEMPOTENCY_PREVIOUS_ATTEMPT_FAILED when the earlier attempt did not succeed (Shopify inventory error codes).

There is a subtlety about where the check lives. If the connector checks “have I seen this key?” and then writes in a separate step, two workers can both pass the check. The fix is the same as in any check-then-act race: put the uniqueness constraint in the database and let the insert decide, or hold a row lock across the check and the write. PostgreSQL’s default Read Committed isolation makes this concrete — two successive SELECT statements in the same transaction can see different data, because each command takes a new snapshot (PostgreSQL transaction isolation).

The connector model’s enforced rule follows from that: external operations use idempotency keys, request fingerprints, explicit outcome states, and reconcile-before-retry for ambiguous writes. “Reconcile before retry” is the part teams skip. A timeout does not mean the write failed; it means the outcome is unknown, and the correct next action is to read the provider’s state by a stable external ID.

Sliding-window checkpoints with overlap

A checkpoint is the durable marker that says how far a pull has consumed a source. A sliding window with overlap re-reads a small, fixed interval behind the checkpoint on every run, then discards the duplicates by external ID or event ID.

The overlap exists because clocks, commits and pagination are not atomic. A record can be committed with a timestamp just before the checkpoint but become visible just after the page was read. Without overlap, that record is skipped forever, and nothing in the system knows it is missing.

The pattern has four parts:

  1. A monotonic cursor, not a timestamp alone. Use the provider’s sequence or a compound (updated_at, id) cursor, because timestamps tie and clocks drift.
  2. A bounded overlap window. Re-read the last N minutes or the last page of IDs, where N is larger than the observed commit-to-visibility lag.
  3. Deduplication at the business key. Every pulled record carries a stable external ID; the insert is ON CONFLICT DO NOTHING or an upsert guarded by a version.
  4. A separate full reconciliation. The incremental window catches normal traffic; a scheduled full pass catches the records the window missed.

A checkpoint also has to be stored with the same transaction that consumes the page, or a crash between “wrote records” and “advanced cursor” replays the page. Replaying a page is safe when deduplication works, which is why the overlap and the idempotent write are one design, not two.

Why “disabled by default” is a feature

A connector that is disabled until explicitly authorised is safer than a connector that is enabled until someone remembers to turn it off. The default state decides which failure you get: an accidental send, or an accidental silence. For anything that moves money, stock or a customer’s order, the second failure is much cheaper.

The control plane enforces this in several layers. Runtime registries resolve only explicitly allowlisted adapter IDs and modes. Connector configuration carries an immutable provider and mode, so a mock cannot quietly become live. Network dispatch fails closed unless current authorisation and rollout gates pass. The worker rejects an unsupported connector type before it creates a job side effect. And no UI label may call a simulated result “sent”, “delivered”, “paid” or “synced” without identifying it as simulated.

The last rule is cultural, not technical, and it is the one that decays first. A green tick next to “Synced” is a claim. If the sync was a capture, the tick is a lie, and the operator who trusts it will make the next decision on false information.

Mode Network Durable artifact What it can prove What it cannot prove
manual No Order, event, audit record Validation, holds, operator recovery Throughput, provider behaviour
csv No Import run, row errors, canonical records Atomic commit, replay safety, mapping Real-time latency, API semantics
mock No Sync run, mock external ID Adapter contract and failure handling Anything about the vendor
capture No Fingerprint, payload, intended request Request shape, idempotency, evidence That the provider accepts it
sandbox Test tenant Provider IDs, error codes Credentials, payload acceptance, errors Production volume and edge cases
network Production Real effects and reconciliation The live path Nothing beyond what is reconciled

Which should you choose? Build the adapter once and run it in capture from the first day, because the payload is the part you can get wrong without anyone noticing. Promote to sandbox only when a test tenant and current specifications exist, and to network only when reconciliation, pause controls and a named owner are in place. Skipping straight to network saves a week and costs a quarter.

What broke and what we changed

A capture result can be labelled like a delivery. A job result that says “sent” when nothing left the process is the failure this rule exists to prevent, because it trains operators to trust the wrong screen. Every mock or capture outcome now carries a source marker and a visible “Simulated” label, and the connector model prohibits the words “sent”, “delivered”, “paid” or “synced” on a simulated result.

Capture fixtures are easy to mistake for certification evidence. A fixture proves the request matches the specification, not that the provider accepts it. The status document separates implemented, verified, capture-only, externally activated and human-accepted, which makes certification a separate phase with its own evidence instead of a checkbox at the end.

A replayed job is the obvious way to consume inventory twice. The connector model’s retry rules are built around explicit outcomes: validation and invariant failures are terminal until an operator corrects the input, configured transient faults are retryable, cancellation before shipment releases eligible reservations through a guarded operation, and replayed jobs and pull windows reuse existing records rather than double-consuming stock. The database test asserts one fulfillment, one shipment, one invoice and reconciled totals after a replay.

A test suite that reaches the network is slow and flaky. The connector lane runs with outbound network disabled and proves the adapters work without external reachability, which is the only way the suite stays a gate rather than a suggestion.

Frequently asked questions

What is a capture-first connector?

A capture-first connector is an integration adapter that validates and records the request it would send to a provider, without making the network call. It implements the same interface as the live adapter, so the mapping, idempotency and state transitions are exercised for real; only the transport is absent. The recorded payload becomes the artifact a reviewer or contract test checks.

Is a capture connector just a mock?

No. A mock returns a fabricated response so a workflow can proceed. A capture connector records the outbound request and its fingerprint, and returns an explicit "accepted locally, not transmitted" outcome. The mock proves the workflow; the capture proves the request. Confusing the two is how a demo becomes a false claim of integration.

Why store both an idempotency key and a fingerprint?

The key identifies the business intent across retries, while the fingerprint identifies the payload. With both, the connector can tell a safe replay of the same request from a dangerous reuse of the same key with different content. Without the fingerprint, a changed payload under an existing key looks like a retry and silently overwrites the original result.

How large should the checkpoint overlap be?

Large enough to cover the observed delay between a record being committed at the source and becoming visible to the pull, with margin for clock skew. Measure that lag rather than guessing; a window that is too small silently skips records, and a window that is too large re-reads work you already did. Deduplication by external ID makes the large window merely wasteful instead of harmful.

Why disable a connector by default instead of enabling it with a flag?

The default decides which failure is more likely. Enabled by default produces accidental external writes when configuration is copied or a flag is missed; disabled by default produces a visible silence that an operator investigates. For stock, orders and money, an accidental write is harder to undo than an accidental pause.

Do capture connectors slow down the real integration later?

They usually shorten it. The adapter boundary, schemas, idempotency keys, error taxonomy and sync-run records already exist and are tested, so certification is about credentials, provider-specific behaviour and reconciliation rather than about building the integration. The capture records also give the vendor conversation a concrete payload to argue about.