Third-Party and SaaS Integration Questions
Engineering a client against external provider and SaaS APIs you do not control: reading unfamiliar vendor docs and judging how far to trust them, handling provider auth and credential lifecycle (storing, rotating and revoking customer-granted credentials, refreshing a shared token safely, keeping secret keys out of client apps), living within vendor rate limits and quotas (prioritising urgent work, sharing one vendor key fairly across tenants), timeouts, retries with backoff and jitter and idempotency against flaky dependencies including writes of unknown outcome and partial batch failures, graceful degradation, circuit breaking and queue isolation when a provider is slow or down, mapping external data models to internal ones, connector and adapter design, anti-corruption layers, syncing records between SaaS systems, sandbox and contract testing against vendor APIs, and managing vendor-specific quirks, breaking changes, outages, failover and temporary integrations across many integrations. Examples span CRM, payments, shipping, messaging and AI service providers. Excludes diagnosing an individual failing call, webhook receipt mechanics, authentication protocol internals, rate limiter algorithms, API versioning policy for your own API, enterprise-wide integration architecture, bulk data ingestion into a warehouse, and choosing or contracting the vendor.
A vendor you depend on announces a breaking change to its API and event payloads in 60 days, and several downstream systems consume that data. How would you absorb this change now, and structure the integration layer so the next vendor change is cheap?
Sample Answer
The idea in plain words
You do not control the vendor's change, but you control how many places in your system know about it. The fix has two parts: a dated plan that gets one adapter working against the new API well before the enforcement date, and a structure (an anti-corruption layer, meaning a translation layer that keeps the vendor's model out of your own code) so downstream systems depend on YOUR stable internal shape, not the vendor's. Then the next vendor change touches one module.
The plan, sequenced against the deadline
Assumption: the change is enforced on day 60, the announcement is day 0, and the vendor makes the new API version available from the start both in its sandbox and, for production calls, behind an opt-in (a version header or a new base URL), while production events keep arriving in the old shape until the switch. If the new version existed only in the sandbox, the shadow run and canary below could not use live traffic: they would run against the sandbox with replayed traffic, the first real production traffic would arrive on the vendor's switch day, and the buffer would have to cover that. Work is ordered by risk, with a buffer at the end.
| Days | Step | Output |
|---|---|---|
| 0 to 5 | Inventory: find every call, every response field read, every webhook or event payload field used, and every downstream consumer. Use code search plus logs of which fields are actually read. | Usage list, consumer list, owners |
| 0 to 5 | Read the vendor's migration notes; classify each change (removed, renamed, type change, new required field, behaviour change). Rank by business impact: money, customer-facing and compliance flows first, reporting last. | Prioritised impact list |
| 5 to 20 | Define or confirm the internal model and build a new adapter for the new vendor shape beside the old one. Downstream systems still receive the same internal shape. | New adapter behind a feature flag |
| 20 to 35 | Test: contract tests on recorded payloads from the new format, the vendor's sandbox, and both-old-and-new payload fixtures for events. | Passing suites |
| 35 to 45 | Shadow run: for reads, send each live request through both adapters, compare the internal output, and investigate every difference. Live events keep arriving in the old shape until the vendor switches, so replay new-shape events (from the sandbox, a second test endpoint if the vendor offers one, or recorded samples) through the new adapter and compare with the old adapter's output for the matching old-shape events. Never shadow a write against the live vendor (it would happen twice); test writes against the sandbox or with recorded requests. | Diff report |
| 45 to 52 | Canary: 5%, then 25%, then 100% of traffic through the new adapter, watching error rate and mismatches. Go or no-go review on day 45. | Cut-over complete |
| 52 to 60 | Buffer and clean-up: fix late findings, keep the flag. | 8 days of slack |
| After day 60 | Remove the old adapter after a stable period. | Old code deleted |
The step lengths add up: 5 + 15 + 15 + 10 + 7 + 8 = 60 days.
Why those proportions: inventory and reading take 5 days because every later step depends on them. Building the adapter (15) and testing it (15) take half of the 60 days, since each changed field needs code and a test. The shadow run (10) is long enough to cover at least one full week of traffic. The canary (7) is as long as three stages need. The 8-day buffer is 8 / 60 = 13% of the calendar, because corrections to the vendor's documentation arrive late.
Terms in the table:
- Adapter: the code that translates between the vendor's shapes and your internal ones.
- Feature flag: a switch that sends traffic to the old or the new adapter without a new release.
- Contract tests: automated tests that check each side still honours the agreed request and response shapes.
- Fixtures: saved sample payloads used as test input.
- Sandbox: the vendor's test environment.
- Shadow run: send the same read requests through both adapters, compare the outputs, and use only the old adapter's result. Events can be shadowed live only if the vendor can deliver the same event in both shapes (some vendors let you register a second endpoint on a newer version); otherwise replay recorded or sandbox events through the new adapter. Writes are not shadowed on the live vendor, because each would take effect twice.
- Canary: send a small share of real traffic through the new path first. For the 7 days from day 45 to 52, an assumed schedule is 5% of traffic for 2 days, 25% for 2 days and 100% for 3 days (2 + 2 + 3 = 7). A stage passes if the error rate is no higher than on the old adapter and there are no unexplained mismatches in the internal output; otherwise flip the flag back and fix.
Rollback and fallback
Until the enforcement date the old API still works, so the feature flag is the rollback: flipping it returns traffic to the old adapter in seconds. After the date the old path is gone, so rollback means falling back to a degraded mode instead: serve last known data, queue outbound work for replay, and show users a clear notice (degraded mode: reduced but safe service while the main path is unavailable). Decide that degraded behaviour and test it before day 45, not on day 61. For event payloads, make the receiver accept both the old and the new shapes during the overlap, so the vendor's switch date does not have to match yours.
Downstream systems
Downstream consumers read the internal event or model, so they change only if the internal contract has to change. If it does (say a field that no longer exists upstream), version the internal contract, announce it with a date, and run both versions for a short overlap. Keep a list of every consumer and owner and confirm each one by name.
An illustrative before and after, with made-up payloads. The vendor renames and nests fields; each adapter maps its version to the same internal shape, so downstream systems do not notice:
vendor v1: {"cust_name": "Ada Lovelace", "amt": 1250}
vendor v2: {"customer": {"full_name": "Ada Lovelace"}, "amount_minor": 1250}
internal : {"customer_name": "Ada Lovelace", "amount_cents": 1250}
If v2 had dropped a field that consumers read, such as phone, the internal contract would get a new version whose payload omits it; for a short overlap you would publish both internal versions (the old one with phone empty), announce the end date, and remove the old one when every named consumer has moved.
Communication
Day 0: tell the consumer teams and the business owners what changes and the enforcement date. Weekly: one status line (done, at risk, next). Day 45: go or no-go. Day 52: confirmation that the cut-over is complete. Escalate early if the sandbox or the vendor's documentation is incomplete, and ask the vendor for clarification or an extension in writing.
Making the next change cheap
Keep vendor field names and quirks inside one adapter module. Define the internal model by what your product needs, not by the vendor's schema. Store recorded sample payloads as test fixtures, validate every response against the schema you expect and alert on unknown or missing fields (the aim is a small blast radius: the number of places that can break when the vendor changes stays small), subscribe to the vendor's changelog or deprecation notices, and keep a periodic check that your adapter still works against the vendor's sandbox. This is a worked illustration with an assumed 60-day calendar; the proportions should flex with the size of the change.
Common mistakes
Starting with the code instead of the inventory; letting vendor types leak into business logic; assuming rollback exists after the cut-off; testing only the happy path; finding a downstream consumer on day 58.
A customer's only integration point is a brittle SOAP API with roughly 3 second responses and strict rate limits, and they cannot change it. Design your side of the integration so that it is reliable and correct, and say how you would prove that without asking them to change anything.
Sample Answer
The idea in plain words
SOAP is an older style of web service in which messages are XML documents described by a WSDL file (a machine-readable description of the operations and message types), and errors come back as a Fault element. The constraints here are a slow service (about 3 seconds per call), strict rate limits and no ability to change the other side. The principle: you own the only part that can change, so build a protective layer around the fragile service. That layer paces calls below the limit, queues work, never repeats a call whose outcome is unknown without checking, translates the old model into your clean one (an anti-corruption layer, meaning a translation boundary that keeps the legacy model from leaking into your code), and is tested against a stand-in that misbehaves on purpose.
1. The capacity arithmetic
Assumptions (stated, not given): the limit is 20 calls per minute; each call takes 3 seconds; the customer's side generates a baseline of 12,000 requests a day, which is 8.33 per minute, and for 2 hours of the day the rate is 3 times the baseline, 25 per minute (so a busy day carries 12,000 + 2 x 60 x (25 - 8.33) = 14,000 requests); when a write is acknowledged or lost, the service needs up to 60 seconds before a query shows it (the read-after-write delay).
- Limit per day: 20 x 60 x 24 = 28,800 calls.
- Baseline demand: 12,000 / 1,440 minutes = 8.33 per minute.
- Little's law says the average number of calls in flight (sent, not yet answered) equals the arrival rate times the time each call takes. At the limit: (20 / 60 calls per second) x 3 seconds = 0.333 x 3 = 1.0. So at the limit, exactly one call is in flight at a time, and one sequential worker that waits for each answer already reaches the ceiling: the 3 second latency and the limit of one call per 3 seconds give the same ceiling. A second parallel call buys nothing and risks tripping the limit. At the paced 16 per minute (step 4) the same line gives (16 / 60) x 3 = 0.8 calls in flight on average, which one worker handles.
- Pace at 80 percent of the limit to leave headroom for clock differences and for retries: 16 per minute, one call every 60 / 16 = 3.75 seconds. That is 16 x 60 x 24 = 23,040 calls a day. Baseline demand uses 8.33 / 16 = 52.1 percent of it.
- The busy period: 3 x 8.33 = 25 per minute against 16 served, so the backlog grows by 9 per minute for 120 minutes: 9 x 120 = 1,080 requests. After the busy period it drains at 16 - 8.33 = 7.67 per minute, taking 1,080 / 7.67 = 140.9 minutes, about 2.3 hours.
So baseline load fits; the busy period does not, and the design must make that delay acceptable rather than pretend it away.
2. The design
The core is items 1, 4 and 6 (the queue with a paced worker, the asynchronous contract and the ledger for creates) with item 5 (the anti-corruption layer); items 2, 3 and 7 (two lanes, call reduction, the circuit breaker) improve behaviour under load and faults and come next. Read-after-write promises, used below, are promises that a read made right after your write shows that write.
- A durable queue in front of the service, with a single paced worker (or one worker per credential, if the limit is per credential). The pacer spaces calls at 3.75 seconds, and honours any rate-limit response the service returns by backing off further.
- Two lanes: interactive requests first, bulk work in the leftover budget. Starvation (low-priority work never getting a turn) of bulk is acceptable up to a stated age.
- Reduce the number of calls. Cache reads with a time-to-live (how long a saved copy counts as fresh) that matches how often the data truly changes. Coalesce duplicate in-flight reads for the same key (combine identical simultaneous requests into one call whose answer all of them share). Collapse many queued updates to the same record into the latest state. These can remove far more load than any tuning of pacing.
- Callers get an asynchronous contract: submit, receive a request id, poll or get notified. Do not make a user request wait on a 3 second call behind a queue.
- Anti-corruption layer: generate the client from the WSDL, then map its types into your own domain objects in one module. Map SOAP Faults to your own error classes: retryable (busy, timeout), permanent (validation), and unknown. For example, a fault whose text says the service is busy maps to
RetryableError, a fault naming an invalid field maps toPermanentError, and a fault you have never seen maps toUnknownError, which is handled like a timeout (check before resending). SOAP specifications normally deliver a Fault with an HTTP error status (500 in SOAP 1.1) but handle a Fault inside a 200 response too. - Correctness for calls that change data. SOAP has no standard idempotency key. For a create: record intent in a ledger first; after a timeout, do not resend. Query the service by your business reference to see whether it applied, and only then decide. If the service cannot be queried, mark the item "unknown" and surface it in a reconciliation report rather than guess. Updates that set a full state are naturally safe to repeat; updates that add to a value are not. A traced example with simulated time, for a create with business reference
ORD-77: at t = 0 the ledger rowORD-77is written with state INTENT and the create is sent; at t = 30 there is no answer, so the state becomes UNKNOWN and nothing is resent; at t = 33.75 (the next paced slot) the worker calls the service's query operation with referenceORD-77. If the service returns the record, the ledger row becomes APPLIED with the service's id and no second create is ever sent. If it returns nothing, the worker waits out the 60 second read-after-write delay, queries once more, and only then resends the create with the same reference. If the service has no query operation, the row stays UNKNOWN and appears in the reconciliation report (a list of items whose outcome could not be confirmed, for a human to check). - Circuit breaker: after repeated faults or timeouts, stop for a cool-off period and probe with a cheap read.
3. How to prove it without asking them to change anything
Build a stand-in service from the WSDL and from recorded real exchanges. Make it misbehave on command: respond in 3 seconds, take 30 seconds, return a rate-limit fault after the 20th call in any rolling 60 seconds (a window that slides with each call, rather than resetting at fixed minute marks), return malformed XML, apply a create and then drop the response. Run your layer against it on a simulated clock (a clock the test advances itself, so a 60 second window takes no real time) and assert:
- The call timestamps never exceed the limit in any rolling 60 seconds window. This is checked by recomputing the window from the log, not by trusting the pacer.
- After an injected "applied but response lost" fault, there is exactly one record at the stand-in for each create.
- After the busy-period trace, the queue returns to empty, and the drain time is close to the 141 minutes computed above (a failure here means the model or the pacer is wrong).
- A crash and restart mid-queue loses nothing and repeats nothing.
Then a read-only canary in production: a few cheap reads on a schedule compare real latency and fault behaviour with the stand-in, so the stand-in can be corrected. The honest limit is that a stand-in is only as good as the recordings, so keep the production canary and a daily reconciliation.
The judgment
I would commit to queue, paced single worker, call reduction, async contract, ledger-based create handling and a stand-in service for proof. If the busy-period delay is not acceptable to the customer, the lever is not faster code but fewer calls (more caching, coalescing) or a negotiated higher limit, which is a conversation with them, not a code change.
Common mistakes
- Parallel workers against a limit, which only produces faults.
- Resending a create after a timeout.
- Letting WSDL-generated types spread through the codebase.
- Tuning to the average load and ignoring the busy period.
- Testing only the happy path against the real service.
You are integrating a CRM, an ad platform, a product analytics tool and a support system, and each names and structures customer fields differently. How would you design the mapping layer so these systems can exchange data without every downstream consumer needing custom logic?
Sample Answer
The idea in plain words
Give every external system a small translator (an adapter) that converts its records into one internal shape, the canonical data model (a single agreed definition of "customer" that the rest of your product uses), and back. Downstream consumers then read only the canonical shape. This is a hub-and-spoke design: with 4 systems you write 4 adapters, instead of a separate conversion for each pair. The catch is that a canonical model is a design decision with trade-offs, so keep it small and keep the original data.
Why hub-and-spoke (counted)
Pairwise, each of the 4 systems needs a conversion to each of the other 3: 4 x 3 = 12 one-way mappings. With a canonical model each system needs one mapping into it and one out of it: 4 x 2 = 8 mappings, grouped as 4 adapters (an adapter holds both directions: one function into the canonical shape and one out of it), and a fifth system adds 2 mappings instead of 8. (Check: the fifth system pairwise needs 4 conversions out and 4 in, which is 8.)
An illustrative example (invented field names)
The field names below are assumptions, not any real product's schema.
| Meaning | CRM | Ad platform | Product analytics | Support system |
|---|---|---|---|---|
| Person's id in that system | contact_id | user_id | distinct_id | requester_id |
| hashed_email | email_prop | email_address | ||
| Name | FirstName, LastName | (none) | name | full_name |
| Consent to marketing | HasOptedOut (inverted meaning) | consent_flag | (none) | (none) |
| Last change time | LastModifiedDate | updated | last_seen | updated_at |
One record traced through the adapter
Take one illustrative CRM record: contact_id 003-884, Email " Ann@X.com " (with stray spaces and capitals), FirstName Ann, LastName Lee, HasOptedOut true, and LastModifiedDate 2026-03-02T14:05:00+02:00. The adapter trims and lower-cases the email, inverts the opt-out flag into marketing_consent, converts the timestamp to UTC (14:05 at +02:00 is 12:05 UTC), and writes a crosswalk row. The reverse function shows the way back out. The last lines show the safe default when the CRM record has no consent flag, or a null one, and the one case that grants consent.
import json
from datetime import datetime, timezone
def crm_to_canonical(rec, customer_id):
last = datetime.fromisoformat(rec["LastModifiedDate"])
if last.tzinfo is None: # a production adapter would send this record to its error output
raise ValueError("LastModifiedDate has no UTC offset; refusing to guess a zone")
last = last.astimezone(timezone.utc)
return {
"customer_id": customer_id,
"email": rec["Email"].strip().lower(),
"given_name": rec.get("FirstName") or None,
"family_name": rec.get("LastName") or None,
"marketing_consent": rec.get("HasOptedOut") is False, # only an explicit false opts in; missing or null means no consent
"source_system": "crm",
"source_id": rec["contact_id"],
"source_updated_at": last.isoformat().replace("+00:00", "Z"),
"extensions": {},
}
def canonical_to_crm(c):
return {"contact_id": c["source_id"], "Email": c["email"],
"HasOptedOut": not c["marketing_consent"]}
crm_record = {"contact_id": "003-884", "Email": " Ann@X.com ", "FirstName": "Ann",
"LastName": "Lee", "HasOptedOut": True,
"LastModifiedDate": "2026-03-02T14:05:00+02:00"}
canonical = crm_to_canonical(crm_record, "cust-1001")
print(json.dumps(canonical, indent=2))
print("crosswalk row:", ("cust-1001", "crm", "003-884"))
print("back to the CRM shape:", canonical_to_crm(canonical))
without_flag = {k: v for k, v in crm_record.items() if k != "HasOptedOut"}
print("flag missing, consent:", crm_to_canonical(without_flag, "cust-1001")["marketing_consent"])
null_flag = {**crm_record, "HasOptedOut": None}
print("flag null, consent:", crm_to_canonical(null_flag, "cust-1001")["marketing_consent"])
explicit_false = {**crm_record, "HasOptedOut": False}
print("flag false, consent:", crm_to_canonical(explicit_false, "cust-1001")["marketing_consent"])
Output
{
"customer_id": "cust-1001",
"email": "ann@x.com",
"given_name": "Ann",
"family_name": "Lee",
"marketing_consent": false,
"source_system": "crm",
"source_id": "003-884",
"source_updated_at": "2026-03-02T12:05:00Z",
"extensions": {}
}
crosswalk row: ('cust-1001', 'crm', '003-884')
back to the CRM shape: {'contact_id': '003-884', 'Email': 'ann@x.com', 'HasOptedOut': True}
flag missing, consent: False
flag null, consent: False
flag false, consent: True
Reading the output: HasOptedOut: true became marketing_consent: false, so the meaning is preserved even though the CRM stores the opposite question. The email is normalised, which is what makes exact-match identity resolution work. source_updated_at is in UTC with a Z suffix, which is what the replay rule below compares. The crosswalk row ties our cust-1001 to the CRM's 003-884. A record with no HasOptedOut field, or with a null one, maps to marketing_consent: false, the no-consent default; only an explicit HasOptedOut: false maps to true.
The design
- Canonical record, kept small: our own
customer_id;email(lower-cased, trimmed);given_name,family_name(nullable, meaning they may be empty);marketing_consent(boolean plus a time and source);source_system,source_id,source_updated_at;extensions(a map for fields only one system has). - Identity crosswalk table (a lookup table saying which vendor id belongs to which of our customers): (customer_id, system, source_id). The canonical id is ours, so no vendor id leaks into consumers.
- Per-system adapter: field mapping, type conversion (the inverted
HasOptedOutbecomesmarketing_consent = (HasOptedOut is false), so a missing or null flag cannot grant consent), unit and time-zone normalisation to UTC (a timestamp with no offset is rejected, not guessed), and an error output for records that cannot be mapped. Mapping tables live in versioned configuration, so a vendor renaming a field is a config change and a test run. - Raw payload retention: store the original record next to the canonical one (for debugging and re-mapping when the model changes).
- Field-level source of truth (the system whose value wins when systems disagree): decide per field which system wins on a conflict. For example, the CRM owns name and consent; the support system owns nothing; the ad platform's hashed email (a one-way scrambled fingerprint of the address: the same address always gives the same fingerprint, but the address cannot be recovered from it) is used only for matching, never as the stored email. Without this rule two systems overwrite each other in turn.
- Identity resolution: matching records across systems (the same person has a different id in each) is the hardest step. Start with exact match on normalised email; treat fuzzy matches (names or emails that are similar but not identical, such as "Jon" and "John") as suggestions that need review, not automatic merges.
- Change propagation: adapters emit canonical change events; consumers subscribe. A consumer needing a field the model lacks asks for a model change, which is versioned.
Trade-offs, and the decision
A canonical model has costs: it can become a lowest common denominator (fields only some systems have get dropped) or a union that nobody understands. It also becomes a shared dependency, so changes need ownership and versioning. My decision for 4 systems that need to exchange customer data: use a canonical model, deliberately thin (identity, contact, consent, timestamps), with extensions and raw payloads for the rest. If only two systems ever talk and nothing else will join, a direct mapping is cheaper and I would not build the hub.
Failure modes
- Lossy mapping: hashed email cannot be reversed, so an ad-platform record can match but not create a customer.
- Consent semantics: inverted, missing or null flags must default to "no consent", not "consent". Test the null value as well as the absent key, because
not Noneis true. - Replays (the same update delivered again) and out-of-order updates (an older update arriving after a newer one): compare
source_updated_atbefore overwriting. - Drift: a vendor adds an enum value (one more entry in a fixed list of allowed values, such as a new status option); unknown values go to a review queue, not a silent default.
Common mistakes
- Making the canonical model mirror the CRM, which re-couples everything to one vendor.
- Mapping inside each consumer.
- Dropping the raw payload and then being unable to re-map.
Running the code
Save the program as crm_adapter.py and run python crm_adapter.py with Python 3.12. It prints the output shown.
You have identified several vendor integrations a project needs, but the vendors are slow to provide technical details and you cannot afford to wait. How do you keep moving, and how do you validate the integration once you get access?
Sample Answer
The idea in plain words
When a vendor will not give you details yet, you do not wait and you do not guess silently. You write down what you believe the vendor's API will do as explicit assumptions, build against an interface contract of your own (the small set of operations your system needs from that vendor, defined in your terms), and test against a mock (a stand-in that behaves the way you assumed). When real access arrives, the job changes from building to comparing: replay real vendor behaviour against each assumption, find where they differ, and fix only the adapter. The danger to hold in mind is that a mock encodes your assumptions, so a green test suite against the mock proves your code matches your beliefs, not that it matches the vendor.
The method
- Collect everything that is public and ask for specifics. Public docs, an OpenAPI file (a machine-readable description of every endpoint, parameter and response shape), a Postman collection (a saved set of example requests that you can replay against the API), SDKs, status pages and community posts. Ask the vendor for a short list: sample request and response bodies, the authentication method, rate limits, error format, whether creates accept an idempotency key (a unique value you send so that repeating the same create returns the first result instead of making a second record), the sandbox availability, and a technical contact. A narrow, concrete request is answered faster than "send us your docs". If the vendor will answer only a few questions, ask for the sample request and response bodies, the authentication method and the idempotency answer first, because they shape the most code; the rest can be learned from the sandbox.
- Define the port. For each vendor, write a small interface your project needs (for example
create_invoice,get_invoice,list_payments_since), using your own data model. The rest of the system depends only on this interface, so the vendor's real shape cannot spread. - Write the assumptions register. One row per assumption: what you assume, how much it would hurt if wrong, who will verify it and by when. Rank by risk, scoring likelihood of being wrong (1 to 3) times impact if wrong (1 to 3), so the score runs 1 to 9. The score is likelihood multiplied by impact: 3 x 3 = 9 is the most urgent and 1 x 1 = 1 the least.
- Build a fake from the contract. Generate a stub server or an in-process fake from your assumed schema. Make it misbehave on purpose: a 429 (Too Many Requests) with a
Retry-Afterheader that says how many seconds to wait, 500s, slow responses, duplicate deliveries, a field missing, an unknown enum value (a value outside the fixed list of allowed values for that field). Code that only meets a happy-path mock tends to fail first on the real thing. - Keep escalating in parallel. Name an executive sponsor or account owner to chase the vendor, ask for a sandbox first and production later, and decide a fallback for the date you cannot move (manual upload, file drop, or shipping the feature without that integration behind a flag).
- Validate when access arrives, in widening stages. Run in this order: sandbox, then read-only calls against production, then shadow mode (your system computes what it would send but does not send it, and you compare), then one pilot customer or tenant (one customer's separate account inside the vendor's system), then everyone. At each stage run contract tests against the real API: they check the response shape, types, nullability (which fields may be null or absent), enum values, pagination, error bodies, ordering and limits against your assumptions register.
Worked example (assumed scenario)
A project needs three vendors: a payments provider, an HR system and a messaging service. Suppose the register for the payments provider looks like this (assumptions labelled, scores by hand):
| Assumption | Likelihood wrong (1-3) | Impact (1-3) | Score |
|---|---|---|---|
| A create call accepts an idempotency key | 3 | 3 | 9 |
| Amounts are integer minor units, not decimals | 2 | 3 | 6 |
| Lists are cursor-paginated | 2 | 2 | 4 |
| Timestamps are UTC ISO 8601 | 1 | 2 | 2 |
Reading the terms in the table: integer minor units means money sent as a whole number of the smallest currency unit, so 12.34 USD is the integer 1234, whereas a decimal string would be "12.34". Cursor-paginated means each page of a list comes with a token that points to the next page, so the client follows tokens until none is returned. Page-number pagination means the client asks for page 1, then 2, then 3, and stops at an empty page. The scores are likelihood times impact: 3 x 3 = 9, 2 x 3 = 6, 2 x 2 = 4, 1 x 2 = 2.
Verify in score order. The 9 (idempotency) shapes your retry design, so it is asked of the vendor in the first email and tested first in the sandbox. A repeat-create probe in the sandbox answers it: send the same create twice with the same key and see whether you get one record or two. The 6 (amount format) could silently charge the wrong amount, so a contract test sends a known amount and asserts what comes back. Illustrative result when sandbox access arrives: the idempotency assumption holds, the amount is a decimal string rather than an integer, and pagination is page-number rather than cursor. Two of the three top assumptions were wrong, and because they were isolated behind the port, the fix is a change to the adapter and the fake, with no change to the callers: the adapter now parses "12.34" into the integer 1234 once, at the boundary, and its list loop asks for page 1, 2, 3 until a page comes back empty instead of following next-page tokens.
Then move on: run shadow mode for a week, comparing the requests your system computes with what the existing process actually sent for the same cases (and with the vendor's validation or sandbox endpoint where one exists), since nothing is sent to the vendor in that stage, pilot with one tenant, and only then widen.
The judgment
Commit to the port, the register and the staged validation. The order matters more than the tooling: unblock yourself with a contract, turn each assumption into a test the day access arrives, and expose the vendor to production traffic in steps. If the delay is long enough to threaten the date, the better move is a fallback, not more guessing: ship the feature behind a flag with a manual path.
What would flip it: if the vendor is a thin pass-through with a published OpenAPI file, you can generate a typed client and skip most of the guessing; if a vendor's behaviour is the product (a payments flow with money movement), shadow mode and a pilot are not optional.
Common mistakes
- Treating the mock as evidence. It records your belief; only the vendor can confirm it.
- Letting guessed field names spread through the code instead of living in an adapter.
- Testing the happy path only, so the first 429 or timeout happens in production.
- Having no owner or date on the assumptions, so they quietly become facts.
- Going from sandbox straight to full production, with no shadow or pilot step.
Your product will depend on an external AI vision service for a core workflow. Plan the integration: what data you are willing to send it, how you test it before production, what happens when the vendor is unavailable or degraded, and how you roll it out.
Sample Answer
The idea in plain words
An external vision service takes an image and returns labels, text or detections. Because the workflow depends on it, four decisions come first: what you are willing to send (data minimisation, meaning send only what the task needs), how you will know it is good enough (a labelled test set and a measured bound, not a demo), what the product does when the service is slow, wrong or gone (degradation, meaning a reduced but working mode), and how you expose real users to it gradually (a staged rollout with a switch to turn it off). The scenario below uses assumed numbers and an unnamed vendor. In an interview, lead with the data rule and the degraded behaviour, since they decide whether the integration is safe at all; testing and rollout show how you earn trust in it.
1. What data you will send
Classify what the workflow handles into three groups and write the rule down before integration:
- Never sent: images with identity documents, children, health information, or anything your policy or the customer's contract excludes.
- Sent after reduction: crop to the region of interest, downscale to the resolution the task needs, strip metadata (EXIF can contain GPS position and device identity), blur or remove faces when they are not the subject.
- Sent as is: images that already carry nothing sensitive, such as product photos.
Also send no user identifiers: use a random per-request id that only you can map back. On the vendor side, read their documented retention and training-use terms, record which settings you chose (for example opting out of retention or training where the vendor offers it), and keep that record with the integration. If the terms cannot be met for group 1 data, that data uses a different path, such as an in-house model or manual handling.
2. How you test before production
-
Build a golden set (a fixed collection of inputs whose correct answers humans have checked, used as the yardstick every time): real-looking images with human-checked labels, covering the conditions you expect (low light, blur, rotated, odd crops, different devices) plus inputs that should be rejected (blank, corrupted, wrong format, oversized).
-
Measure accuracy with an interval, not a point. With the Wilson interval (a standard 95 percent confidence interval for a proportion), 190 correct of 200 is 95.0 percent observed, but the 95 percent interval's lower bound is 91.0 percent. With 950 correct of 1,000 the observed rate is the same and the lower bound is 93.5 percent. State the ship bar as the lower bound: for example "lower bound at least 90 percent".
The formula, for
correctright out ofnand z = 1.96 for 95 percent: with p = correct / n, the centre is (p + z^2 / (2n)) / (1 + z^2 / n), the half-width is z x sqrt(p(1-p)/n + z^2 / (4n^2)) / (1 + z^2 / n), and the interval is centre minus half-width to centre plus half-width. For 190 of 200: p = 0.95, 1 + z^2 / n = 1.0192, centre = 0.9415, half-width = 0.0311, so the interval runs from 0.9104 to 0.9726, which prints as 91.0 to 97.3 percent. The program does these steps and also finds the smallest score that clears a 90 percent bar at n = 200.
from math import sqrt
Z = 1.96 # z-score for a 95 percent interval
def wilson(correct, n, z=Z):
p = correct / n # observed rate
denom = 1 + z * z / n
centre = (p + z * z / (2 * n)) / denom
half = z * sqrt(p * (1 - p) / n + z * z / (4 * n * n)) / denom
return p, centre, half, centre - half, centre + half
for correct, n in [(190, 200), (950, 1000)]:
p, centre, half, lo, hi = wilson(correct, n)
print(f"{correct}/{n}: observed {p:.1%}, centre {centre:.4f}, half-width {half:.4f}, "
f"interval {lo:.1%} to {hi:.1%}")
need = next(k for k in range(201) if wilson(k, 200)[3] >= 0.90)
print("fewest correct of 200 whose lower bound is at least 90%:", need,
f"(observed {need / 200:.1%})")
Output:
190/200: observed 95.0%, centre 0.9415, half-width 0.0311, interval 91.0% to 97.3%
950/1000: observed 95.0%, centre 0.9483, half-width 0.0136, interval 93.5% to 96.2%
fewest correct of 200 whose lower bound is at least 90%: 189 (observed 94.5%)
Read it as: with 200 images, 190 correct clears a 90 percent lower-bound bar by about one point, and 189 is the least that does, so a bar of 90 percent needs an observed 94.5 percent, not 90 percent. At 1,000 images the interval narrows to about plus or minus 1.4 points, so a lower bound of 93.5 percent is possible at the same observed rate. A bigger golden set buys a tighter bound, not a higher score.
3. Report by slice (lighting, device, category), because an overall figure of 95 percent can hide a slice at 80 percent.
4. Test the failure paths on purpose: a fake vendor that times out, returns 429 and 500 (HTTP status codes for Too Many Requests and a server error), returns malformed JSON, and returns confidences near your threshold (a confidence is the score the vendor attaches to an answer, saying how sure it is; the threshold is the cutoff below which you send the item to a human).
5. Keep the golden set running: rerun it nightly against the live vendor. A vendor that updates its model without notice shows up as a score change, which then triggers investigation.
3. When the vendor is unavailable or degraded
Set a timeout from the vendor's latency distribution (for illustration, if the 99th percentile is 2 seconds, meaning 99 percent of calls finish faster than that, a 4 second timeout: it leaves room for the slow tail of normal calls while cutting off a hung call quickly), a limited retry with backoff (waiting longer between attempts) for transient errors, and a circuit breaker (stop calling after a run of failures, probe now and then) so a vendor outage does not pile up threads and slow your whole product.
Choose the degraded behaviour per workflow step, in advance:
| Situation | Behaviour |
|---|---|
| Vendor timeout or open breaker, step can wait | Queue the image, tell the user "processing", complete when the vendor returns |
| Step cannot wait | Fall back to manual entry or a human review queue |
| Low-confidence result | Route to human review instead of acting automatically |
| Vendor wrong at scale (golden set drops) | Flip the kill switch to the fallback path |
The fallback must be exercised before it is needed: run it in staging on a schedule, and size it, because a review queue that cannot handle a day of traffic is not a fallback.
4. How you roll it out
- Shadow mode: call the vendor for real traffic but do not act on the result; compare it with what the existing process or a human did. This tests accuracy and latency on real inputs with no user impact.
- Canary stages (releasing to a small share of traffic first, then widening): with an assumed 20,000 images a day, 1 percent is 200 images, 10 percent is 2,000, 50 percent is 10,000, then 100 percent. Advance only when the stage metrics hold (error rate, latency percentile, review-queue rate, accuracy on sampled and human-checked items).
- A kill switch (a setting you can flip in seconds, a configuration flag rather than a code deploy) that sends traffic to the fallback at once.
- Cost guard: a per-day call cap and an alert, so a bug or a price change shows up as a visible number.
The judgment
I would ship the integration behind an interface in my own code (analyze_image(image) -> result), so a second vendor or an in-house model can replace it, run shadow mode for long enough to fill the golden set with real cases, and move to production only with a measured lower bound, a tested fallback and a working kill switch. What would change it: if the data policy blocks group 1 images, the vision step is not allowed for those users at all and the workflow keeps its manual path; if the vendor offers no pinned model version, nightly regression testing becomes mandatory rather than optional.
Common mistakes
- Sending full-resolution originals with metadata because it was easier.
- Shipping on a demo and one overall accuracy number.
- Designing the happy path only; the first outage then takes down the core workflow.
- A fallback that has never been run.
- No way to turn the integration off without a deploy.
Running the code
Python 3.12, standard library only. Save the listing as wilson.py and run python wilson.py.
Unlock Full Question Bank
Get access to all 10 Third-Party and SaaS Integration interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.