Start With the Workflow and Integration Contract

Integration design begins with a business outcome that crosses system boundaries.
Trace the triggering event, data ownership, and final state before choosing endpoints.
Trace one business outcome end to end
Custom API development begins with a user-visible outcome, such as an approved order appearing in fulfillment and sales seeing its status.
Map each step from the event that starts the work to the state that proves it finished.
Trace these events to expose end-to-end ownership gaps:
- Name the system that owns each fact.
- The CRM may own account relationships.
- A field appearing in two systems does not make both systems authoritative.
Trace a Sample Order Across Systems
A representative order exposes ownership, timing, and state transitions that endpoint descriptions alone can hide.
Trace the same identifier through every system and record where validation, approval, payment, and fulfillment become authoritative.
Follow this order across authoritative system states:
- For a fictional distributor, an account manager approves a quote.
- Record the conditions for every handoff.
- This exposes the real integration requirements before anyone selects endpoints or starts copying fields.
- Create a small workflow table with the trigger.
- “quote approved” may trigger the workflow.
- Assign every failure path an owner to prevent unmonitored retries or vague tickets.
For the wider application boundaries around these contracts, see our B2B web app architecture and launch guide.
Decide whether an API is the right boundary
An API is useful when another application or team needs a stable, controlled way to request or read data.
It is not automatically the best answer for every data transfer.
Use these criteria before choosing an API boundary:
- A scheduled export may suit a low-frequency batch.
- Choose based on latency, volume, ownership, recovery needs, and the consumer’s ability to process events.
- For each interaction, state whether the caller needs an immediate answer.
- A request to validate a tax ID may need a synchronous result.
- A large nightly reconciliation can run asynchronously and return a job ID.
- Payment or inventory status changes can be delivered as events.
- These distinctions matter: synchronous calls tie the user experience to the availability of every dependency,.
Write down the contract before implementation

A contract describes the public behavior a consumer can rely on, not the internal classes or database tables.
Define the resource names, supported methods, required fields, optional fields, validation rules, authentication, error responses, pagination, rate limits, and compatibility expectations.
Define these contract elements before implementation begins:
- OpenAPI is a language-neutral format for describing HTTP interfaces.
- Version OpenAPI contracts and review them with API owners and consumers.
- Ask the consumer to walk through a normal request.
- Resolve ambiguous behavior before treating the contract as a dependable boundary.
- Keep a concrete example beside the schema.
- A request to create an order might contain a client reference.
- The response should return the service’s order ID.
- Clarify whether unknown fields are ignored or rejected.
- Those details often cause integration defects even when both services use JSON.
Write acceptance criteria for the integration contract
Translate the workflow into observable contract behavior before implementation. Each acceptance criterion should identify the caller, precondition, request, expected state, and failure response.
Include business exceptions, not only successful examples. A technically valid response can still violate ownership, approval, or reconciliation requirements.
Test the contract against these business exceptions:
- Name the initiating user, service, or scheduled process.
- State required permissions and business preconditions.
- Define the expected resource and status transition.
- List validation failures and safe retry behavior.
- Specify audit evidence and correlation identifiers.
- Confirm rollback or compensation for partial completion.
Review criteria with operations and support before coding. Their failure examples often reveal missing states that do not appear in a happy-path sequence diagram.
Use approved criteria in automated tests and release checks. This keeps the contract aligned with the business outcome instead of a developer-only interpretation.
Confirm the operating implication
Review the contract whenever a new caller, role, or tenant model appears. Authorization assumptions often become outdated before endpoint names change.
Keep examples synchronized with deployed behavior. A stale success example can mislead consumers as seriously as an undocumented error response.
Keep contract documentation current
Assign a contract review owner for every maintained integration.
Verify documented examples against deployed behavior after material changes.
Design Resources, Authentication, and Errors

A useful API contract makes resources, permissions, and failures predictable.
Define request behavior and error responses before connecting production systems.
Model resources and actions clearly
Use names that describe business resources and keep the method’s behavior predictable.
A path such as /v1/orders/ord_123 refers to one order; GET reads it, while a documented update method changes supported fields.
Model resources and actions through these conventions:
- A command-like operation may suit an action that is not a resource update.
- Do not expose database table names as the public model.
- Design each operation around a defined authorization scope.
- Permission to view an order does not imply permission to refund it.
- Enforce authorization on the server for every operation.
- Derive tenant context from identity and verify it against the requested resource.
- Authentication establishes who or what is calling; authorization decides what that identity may do.
- Use the provider’s credential flow and grant only required scopes.
- Keep secrets in the deployment platform’s secret store or an equivalent protected system.
- Rotate or revoke credentials when an owner changes or exposure is suspected.
Make errors actionable and safe
Return a consistent error shape with a stable machine-readable code, a short human explanation, and a request or trace identifier.
A validation response should identify which field failed and what kind of value is expected without echoing sensitive input.
Return errors through these safe diagnostic fields:
- An authorization failure should not reveal whether another customer’s private record exists.
- Distinguish dependency outages from permanent rejections to guide retries.
- Return HTTP statuses accurately; never report success for unaccepted requests.
- Return acceptance with a job or resource URL for status checks.
- Treat a timeout as an unknown result, not a confirmed failure.
- Design an idempotency strategy before that uncertainty reaches production.
- Include request IDs in logs and support instructions.
- When a customer reports a failure, support should be able to find the relevant attempt.
- Keep errors helpful to the operator while limiting information that would assist an attacker.
- Avoid exposing stack traces, SQL, internal hostnames, or secret-bearing URLs to API consumers.
Define pagination, filtering, and limits

Collection endpoints need bounded pagination so one request cannot retrieve an unmanageable amount of data.
Document the page size, continuation token or cursor, ordering guarantees, and what happens if records change during a multi-page export.
Define collection behavior through these pagination controls:
- Prefer a stable cursor for large or frequently updated collections.
- If the consumer needs only a subset, define supported filters and fields.
- Rate limits should protect the service and be predictable to consumers.
- Document whether limits vary by credential, account, endpoint, or tenant.
- Return retry guidance when available, and make the limit visible in account or API documentation.
- Do not tell consumers to retry continuously.
Authorize every resource boundary explicitly
Authentication identifies a caller, but authorization decides whether that caller can perform one action on one resource. Apply the decision after resolving tenant and ownership context.
Never trust a tenant, account, or owner identifier supplied by the client without validating it against server-side identity and relationship data.
Enforce authorization through these resource-boundary checks:
- Resolve tenant context from the authenticated identity.
- Load the requested resource within that tenant boundary.
- Check action-specific permission before reading sensitive fields.
- Filter response fields to the caller’s approved scope.
- Reject cross-tenant identifiers without revealing record existence.
- Record denied sensitive actions using non-secret context.
Test direct object references with users from separate tenants and roles. Include exports, bulk actions, webhooks, and background jobs in the same authorization model.
Centralize policy logic where practical, but keep enforcement close to the operation. A gateway check alone cannot understand every record-level business rule.
Validate business consistency after replay
Test mappings with missing, unknown, and historical values. Production data rarely matches the clean examples used during the first integration workshop.
Record transformation ownership so teams know whether a correction belongs in the source, integration layer, or destination system.
Assign transformation ownership
Test transformations with missing, unknown, and historical values.
Assign each correction to the source, integration layer, or destination system.
Compare limit handling choices
Choose handling from provider evidence and workflow urgency. The same throttle response can require different actions for interactive and batch work.
Keep the decision visible in tests and runbooks so operators understand whether to delay, reject, or queue a request.
| Decision | Evidence | Response |
|---|---|---|
| Quota remaining | Response headers | Continue within budget |
| Quota exhausted | Retry timestamp | Delay until reset |
| Interactive request | User deadline | Return bounded status |
| Batch workload | Queue age | Throttle and monitor |
Select the response from evidence
Record the provider signal before selecting a response.
Match handling to workflow urgency and the documented user deadline.
Map Data and Protect Compatibility

Data mapping affects ownership, meaning, and compatibility across systems.
Document transformations and stable identifiers before synchronizing records.
Treat data mapping as a business decision
Before mapping fields, identify the business meaning, owner, format, and update rule for each important value.
“Customer” may mean a company in one system, a billing account in another, and an individual contact in a third.
Resolve semantic differences through these mapping decisions:
- Mapping those records by display name is unsafe when names can change or collide.
- Preserve provider IDs, source systems, and synchronization times for reconciliation.
- Make transformations explicit.
- Never map
pending_reviewsilently toapprovedwithout a matching destination state. - Preserve unknown values for review or reject records with clear errors.
- Normalize units and time zones deliberately.
- Choose a conflict rule and document when human review is required.
- “Last write wins” fails with clock differences or delayed events.
- Record enough provenance to explain why a value changed.
- If a field is derived, identify its inputs and the system allowed to recalculate it.
Version contracts without surprising consumers
Treat the API as a contract.
Prefer additive, backward-compatible changes: adding an optional response field is usually easier to adopt than renaming or removing an existing one.
Evolve contracts through these compatibility practices:
- Plan breaking changes with consumer notices, migration guidance, version overlap, and support deadlines.
- Microsoft’s API guidance warns that breaking changes can disrupt clients.
- Document compatibility guarantees for each service version.
- Can clients ignore unknown response fields?
- Are enumeration values open-ended?
- Can fields become nullable?
- Could tighter validation reject previously accepted requests?
- Generated clients amplify schema changes across consumers.
- Review contract diffs and test representative consumers before release.
- Publish old-and-new examples and monitor version usage without logging secrets.
Keep duplicate records and drift visible
External integrations fail in ways that produce partial success.
The API may create a contact while the CRM update times out.
Expose duplicate records through these reconciliation controls:
- A webhook may arrive after a nightly import.
- A user may edit the same field in two systems.
- Plan reconciliation within the integration, not as later cleanup.
- Map local and provider object identifiers using stable keys.
- Enforce unique mappings for each logical object.
- Track successful attempts, error categories, and required human action.
- Retain only small, redacted diagnostic records when possible.
- Queue records that cannot be safely matched or transformed.
- Show the source object in every exception.
- Replay original intent only after reviewing changed fields.
Example: reconcile a partially completed order sync

Imagine the order API accepted an order but the CRM update failed.
The integration should retain a compact mapping record that can answer which local order corresponds to which provider order, what step succeeded, and what remains.
Keep a compact reconciliation record
Keep the record focused on identifiers and workflow state.
Store provider references beside internal states using the compact fields shown below.
{
"local_order_id": "ord_local_4821",
"provider": "fulfillment",
"provider_order_id": "ord_ext_99410",
"sync_state": "crm_update_pending",
"last_successful_step": "provider_order_created",
"retry_after": "2026-10-18T02:15:00Z"
}Resume Only the Incomplete CRM Step
When a worker resumes, it should first load this mapping and fetch the provider order using its stable external ID.
Then it can retry only the CRM step, without repeating order creation.
Resume only these incomplete CRM operations safely:
- Check request references and operation history before retrying a missing-order creation.
- If it finds two plausible matches, stop automated writes.
- The expected outcome is one provider order.
Build a field ownership and transformation matrix
For each synchronized field, identify the authoritative system, permitted writers, transformation, validation, null behavior, and conflict rule. Do not assume the newest timestamp is always correct.
Record how enumerations, currencies, time zones, addresses, and deleted values move across systems. Small semantic differences can silently corrupt reporting and automation.
Document field movement through this transformation matrix:
- Name the authoritative system for every shared field.
- Document accepted values, formats, and null semantics.
- Define transformations and their reversible source data.
- Choose conflict handling for simultaneous updates.
- Record deletion, merge, and archival behavior.
- Assign an owner for mapping changes and exceptions.
Version the matrix with the integration contract. A mapping change is a production change even when neither provider endpoint changes.
Test representative historical records and edge cases before bulk synchronization. Preserve rejected rows so corrections can be reviewed and replayed safely.
Plan schema evolution without silent data loss
Providers can add fields, enumeration values, validation, or deprecations without changing the business purpose of an endpoint. Consumers should tolerate compatible additions and reject unsafe ambiguity.
Monitor release notes and contract differences, then test representative consumers. Generated clients and strict validators may fail on changes that flexible clients accept.
Protect schema changes through these compatibility controls:
- Capture reviewed schemas and generation commands in version control.
- Compare required fields, types, enums, and validation rules.
- Exercise unknown fields and new enumeration values.
- Test old and new consumers during overlap periods.
- Publish migration examples and support deadlines.
- Measure remaining traffic on deprecated versions.
Treat removals and semantic changes as migrations. A version number alone does not protect users when documentation and runtime behavior disagree.
Keep a rollback or compatibility layer until critical consumers have migrated and operational evidence confirms the older contract is no longer used.
Make Writes Safe: Timeouts, Retries, and Idempotency

Retries can recover failed requests, but unsafe retries can duplicate changes.
Timeout, idempotency, and recovery rules make write operations dependable.
Set timeouts by operation
Every network request should have a finite timeout.
An unlimited wait can tie up workers, consume connection pools, and make the whole service appear stuck.
Set timeouts through these operation-specific limits:
- Choose a timeout based on the user-visible service objective.
- Separate connection timeouts from response timeouts where the client library allows it.
- For a synchronous screen action, a slow provider may require a queue.
- Allow longer batch windows only with visible progress and safe retries.
- Avoid copying one arbitrary timeout to every integration without understanding the effect on each workflow.
Retry only when the failure can recover
Retries help with temporary network failures, throttling, and selected server errors.
They do not repair invalid data, missing permissions, or a request that violates a business rule.
Retry only failures matching these recovery conditions:
- Classify errors into retryable and non-retryable groups.
- If the provider returns a retry-after value, honor it when appropriate.
- Record exhausted retries and route failures to a visible recovery path.
- Do not let every layer retry independently.
- API retry, queue retry, and provider SDK retry can multiply into a burst.
- Choose which component owns retries, define an overall deadline, and make the attempt count observable.
- During an outage, a circuit breaker or queue pause can protect a failing dependency.
Use idempotency for operations with side effects
Idempotency means repeating the same logical request does not create the same side effect more than once.
It is essential when a connection fails after a write may have reached the provider.
Protect side effects through these idempotency controls:
- The caller should create a unique key for the business action and store them together.
- Stripe’s API documentation describes this pattern for safely retrying certain create or update requests.
- Example: a checkout service submits an order and times out before receiving the response.
- It must not generate a new idempotency key on every retry.
- Use stable order-operation keys so receivers recognize retries.
- Do not place email addresses, access tokens, or other sensitive values in the key.
- Store the key securely and define how long the application retains its mapping.
Recover an Uncertain Order-Creation Response

A lost response creates uncertainty because the provider may have completed the write before the connection failed.
Recovery must establish the provider state before any repeated action can create a duplicate order or payment.
Diagnose uncertain writes through these provider-state checks:
- Handle lost create responses without assuming whether creation succeeded.
- The operator cannot infer from the timeout alone whether the provider created the order.
- The safe runbook checks the provider by a stable client reference.
- Pause retries and reconcile through the provider before creating another order.
Use that diagnosis to run the following recovery sequence.
Recover uncertain orders through this safe sequence:
- Persist the internal order operation and its idempotency key before the outbound call.
- Send the same key on retries of the unchanged request.
- Query the provider using a stable external reference when supported.
- Mark the operation complete only after a persisted provider response or a confirmed reconciliation result.
A request might carry the key in a header like this; the exact header name and retention behavior are provider-specific:
POST /v1/orders HTTP/1.1
Authorization: Bearer <server-side-token>
Idempotency-Key: order-op-7f2a9c
Content-Type: application/json
{
"quote_id": "quote_4821",
"currency": "USD",
"items": [{"sku": "SKU-104", "quantity": 3}]
}Interpret an Idempotent Retry Result
The expected result is one provider order associated with the internal operation, even if the same request is retried.
Store credentials outside the example and never reuse the sample key in production.
Interpret idempotent retries through these response states:
- If the provider reports a conflict for the same key with different parameters, stop.
- For a custom API you own.
- Enforce that the same key cannot be reused with materially different parameters.
- Return an in-progress response or wait only within a bounded interval.
- Test the race where two identical requests arrive at nearly the same time.
Set one retry budget across clients and queues
Independent retries in an SDK, application, queue, and scheduler can multiply one failure into a traffic burst. Choose one owner for retries and define an overall deadline.
Classify failures before retrying. Validation, authorization, and incompatible requests require correction, while bounded timeouts or temporary server failures may justify another attempt.
Bound retries through these shared budget controls:
- Define maximum attempts and total elapsed time.
- Honor provider retry guidance when appropriate.
- Add exponential delay and bounded randomization.
- Preserve the same idempotency key for unchanged writes.
- Expose attempt count and next action to operators.
- Pause automation when dependency health remains unsafe.
Test retry ownership by simulating timeouts at each layer. Confirm the provider receives the expected number of calls and the business action occurs once.
Route exhausted attempts to a visible recovery process. Silent abandonment and unlimited retries both create harder reconciliation and customer-support problems.
Connect Systems With Webhooks and Async Jobs

Asynchronous delivery helps independent systems exchange updates without blocking each other.
Choose polling, webhooks, or queued jobs based on latency and recovery needs.
Choose polling or webhook delivery intentionally
Polling is easy to explain but can waste requests and delay updates.
A consumer asks for changes on a schedule, usually with a cursor or updated-since marker.
Compare polling and webhooks through these tradeoffs:
- Webhooks notify a consumer when an event occurs, reducing detection delay.
- Use thin webhooks that signal change before fetching authoritative data.
- Use polling when event delivery is unavailable.
- Webhooks fit near-real-time updates when the receiver can operate a secure endpoint.
- Do not treat a webhook payload as the only copy of a business record.
- Store the event ID and enough status to detect duplicates.
Verify signatures before trusting events
For webhook providers that sign requests, verify the signature with the provider’s official SDK or documented algorithm before using the event.
Preserve the raw request body if signature verification depends on exact bytes; parsing and re-serializing JSON first can change the signed representation.
Verify webhook authenticity through these signature controls:
- Keep the signing secret on the server.
- A secure handler should validate the signature and identify the event.
- Process business logic from a background worker.
- Isolate slow downstream calls to prevent provider timeouts and retries.
- Follow Stripe’s webhook documentation or each provider’s current instructions.
Choose delivery from workflow tolerance
Define how late an update may arrive before it affects a customer, financial control, or downstream decision.
Use that tolerance to select synchronous calls, webhooks, queues, scheduled reconciliation, or a deliberate combination.
Choose delivery patterns through these workflow tolerances:
- Set a measurable freshness boundary.
- Match delivery to business impact.
- Keep reconciliation independent.
Document the fallback when events arrive late, out of order, or not at all, including who reconciles the affected workflow.
Make event processing repeatable

Assume an event can be delivered more than once and that events may arrive out of order.
Use the provider’s event ID as a deduplication key when available.
Make event processing repeatable through these identifiers:
- Make the handler’s state transition safe to repeat.
- Check the event’s timestamp and current resource state when ordering matters.
- Record job status, attempts, timestamps, error class, and next action.
- Consumers should be able to check progress without polling excessively.
- Set job-result retention and protect contained customer data.
- Provide cancellation or retry where the operation permits it.
Decide who owns reconciliation
Webhooks can be delayed, rejected, or disabled.
Build a periodic reconciliation path for high-value records such as payments, provisioning state, and fulfillment status.
Assign reconciliation ownership through these operating duties:
- Compare bounded windows with stable IDs; safely repair resolvable differences.
- Send ambiguous cases to human review.
- An integration is not reliable merely.
Design webhook recovery before enabling events
A webhook endpoint should authenticate the sender, acknowledge within the provider’s deadline, persist the event identifier, and defer slow business work to a controlled worker.
Delivery can be duplicated, delayed, or reordered. The consumer must make state transitions repeatable and compare event context with the current authoritative resource.
Design webhook recovery around these failure conditions:
- Validate signatures using the unmodified request body.
- Reject timestamps outside the accepted replay window.
- Store event identifiers before starting business work.
- Acknowledge quickly and process through a durable queue.
- Deduplicate repeated deliveries and preserve outcomes.
- Reconcile missed events through supported provider queries.
Create a runbook for signature failures, queue delays, poison events, and provider outages. Include who can pause consumption and how pending work resumes.
Test recovery with duplicate, delayed, reordered, and malformed events. A single successful callback does not demonstrate production reliability.
Monitor event disposition evidence
Track duplicate suppression and replay results as operational metrics. Unexpected changes can expose retention gaps, consumer defects, or provider behavior changes.
Preserve enough context to explain why an event was ignored, retried, quarantined, or applied to the current business state.
Retain event disposition evidence
Measure duplicate suppression and replay outcomes after every recovery exercise.
Preserve the reason each event was ignored, retried, quarantined, or applied.
Test the Contract and the Failure Paths

Integration tests should cover both expected behavior and failure paths.
Validate contracts, authorization, retries, and recovery before release.
Cover unit, contract, and integration behavior
Unit tests should cover transformations, validation, authorization rules, and idempotency decisions without needing a live provider.
Contract tests should verify that the request and response shapes match the agreed schema and that consumer assumptions remain valid.
Cover integration behavior through these testing layers:
- Integration tests should use a provider sandbox or a controlled test environment when available.
- Each layer catches a different class of error.
- Keep representative request and response fixtures for ordinary, boundary, and rejected cases.
- Remove secrets and personal data before storing fixtures.
- Include a new enum value or unknown field when the provider permits it.
- Generate fixtures from the reviewed contract using a reproducible command.
Test failures deliberately
Verify the user-facing state, the logs available to operators, and the recovery path.
A test that checks only an HTTP status code may miss a duplicate charge or a secret written to a log.
Exercise these failure modes before production release:
- At a minimum, test invalid input, expired or insufficient credentials, and rate limits.
- Use sandboxes for realistic provider behavior, but do not assume they perfectly match production.
- Keep a clear separation between test and live credentials.
- Use synthetic accounts and data.
- Before production rollout, confirm the endpoint and credential environment.
Test evidence that operations can reuse
Preserve requests, responses, identifiers, timestamps, and expected outcomes for every important success and failure scenario.
Operations should be able to repeat the same evidence after credentials, provider versions, mappings, or retry policies change.
Preserve reusable evidence through these test artifacts:
- Save representative contract fixtures.
- Repeat tests after dependency changes.
- Link failures to release decisions.
Include business assertions in test results so a technically valid response cannot hide duplicated, missing, or incorrectly transformed work.
Exercise recovery and replay

Create a safe replay procedure before launch.
An operator should be able to identify the failed item, understand whether the provider may already have completed the action, and retry without duplicating it.
Validate recovery through these replay scenarios:
- Test the replay procedure against a sandbox record.
- If replay requires a manual database edit, document the steps, backup, and rollback.
- For a migration or bulk synchronization, start with a small dry run.
- Compare source and destination counts, sample representative records, and record rejected rows.
- Provide a checkpoint so the job can resume after interruption.
- A “successful” run that skips failed records without reporting them is not successful.
Test provider limits and sandbox differences
A provider sandbox may omit production volume, rate limits, identity rules, or downstream effects. Document known differences and keep live verification deliberately small.
Use synthetic records in test environments, then run a controlled production canary with explicit owners, stop conditions, and reconciliation steps.
Test provider constraints through these controlled steps:
- Confirm test and live endpoints before every release.
- Separate credentials and prevent accidental environment crossover.
- Measure documented and observed request limits.
- Exercise throttling, expired credentials, and permission failures.
- Verify that test activity cannot trigger real fulfillment.
- Reconcile canary records before increasing traffic.
Record evidence from both environments so reviewers understand what remains untested. Avoid treating a sandbox success as proof of production capacity.
Expand volume gradually while watching queue age, provider errors, duplicate prevention, and business-state reconciliation. Stop when predefined thresholds fail.
Confirm pagination and limit behavior
Test replay with records that already succeeded, partially succeeded, and permanently failed. Each state needs an explicit safe outcome.
Measure reconciliation after replay instead of assuming queue completion proves business consistency across every connected system.
Confirm consistency after replay
Replay representative records from successful, partial, and failed states.
Verify business consistency across every connected system after recovery.
Confirm the final business state
A completed replay is not enough; compare source and destination outcomes before closing recovery work.
Record unresolved differences with an owner, next action, and deadline so queue completion does not conceal business inconsistency.
Verify the final business state
Compare expected and observed states before closing recovery work.
Assign every discrepancy and retain its evidence with the incident record.
Operate, Monitor, and Evolve Integrations

A live integration needs clear ownership and operational signals.
Monitor technical failures alongside the business workflows they interrupt.
Measure customer outcomes and system health
Monitor both technical behavior and the business workflow.
Useful technical signals include request volume, latency percentiles, error class, provider rate-limit responses, retry count, queue depth, and oldest pending job.
Measure customer and system health through these signals:
- Workflow signals include orders synchronized.
- High availability fails business needs when critical events remain queued.
- Tag logs and traces with a non-sensitive correlation ID and integration name.
- Include account context without exposing personal or cross-customer data.
- Define retention and access controls for operational data.
- Alert when a threshold requires action.
Roll out with a measured blast radius
Deploy a new integration behind a configuration flag or to a limited customer cohort when the architecture allows it.
Start with a test account and a small set of records, then compare outcomes before expanding.
Expand rollout through these controlled evidence gates:
- Define in advance what would stop the rollout.
- Name who can pause the flow and how the team will communicate the change.
- For a workflow that can be disabled safely, document the effect of pausing it.
- Do pending events remain queued, expire, or require reconciliation?
- Will users see a warning?
- Can an operator restart processing after fixing credentials?
- A rollback should include data and queued work, not only the application binary.
- Sequence database migrations so old and new code coexist during transition.
Assign ownership and provider change management
Every production integration needs a product owner, technical owner, credential owner, support path, and escalation contact.
Record the provider’s API version, the date the contract was reviewed, key dependencies, and the deprecation notice channel.
Govern provider changes through these ownership records:
- Review vendor changes as part of normal maintenance.
- Keep a short runbook next to the service dashboard.
- Explain how to confirm provider status and check credential scope and expiry.
- Include the expected result after each step.
- If interface labels or dashboard paths vary, link to current provider instructions.
Close the loop with consumers
An API owner should announce material changes, document migration steps, and listen to consumer feedback.
A contract is successful only when consumers can implement it and operate it predictably.
Close consumer feedback through these contract checks:
- Track questions that repeat in support and update examples, validation messages, and error docs.
- Diagnose unclear contracts or unsafe usage before adding API workarounds.
- See our B2B web app development guide for broader architecture and launch planning.
Plan for provider limits and quotas

Third-party APIs often limit requests by account, endpoint, or time window. Record each applicable quota and the provider’s response when it is exceeded.
Design the client to slow down, queue work, or postpone noncritical synchronization. Unbounded retries can extend an outage and increase provider throttling.
Manage quotas through these bounded responses:
- Record documented request limits.
- Capture remaining-quota response headers.
- Classify critical and deferrable work.
- Back off after throttling responses.
- Alert before queues become unsafe.
- Test recovery after limits reset.
When the provider supplies a retry time, respect it. Otherwise, use bounded exponential backoff with jitter and a maximum attempt count.
Monitor queue age as well as queue size. A stable number of delayed records can still violate the business workflow’s freshness requirement.
Reconcile financial and irreversible side effects
Payments, inventory changes, provisioning, and customer messages need stronger reconciliation than an ordinary read request. Record a durable business identifier for every attempt.
Use idempotency where the provider supports it, but still compare internal and provider records. A timeout does not prove that an operation failed.
Reconcile irreversible effects through these record checks:
- Create a stable operation identifier.
- Store the outbound request state.
- Record the provider reference.
- Handle timeout as an unknown result.
- Query before repeating irreversible work.
- Escalate unresolved discrepancies.
Schedule reconciliation independently from real-time delivery. Compare expected and observed states, then route differences to an owner with enough context to act.
Never hide a discrepancy by overwriting the local record. Preserve the original attempt, correction, reason, actor, and timestamp for later investigation.
Design a safe integration retirement
An integration needs an end-of-life procedure before decommissioning. Identify consumers, scheduled jobs, webhook subscriptions, credentials, queues, retained data, and operational dashboards.
Stop new writes first, drain pending work, and verify the replacement path. Revoke credentials only after the final reconciliation and approved retention actions.
Retire integrations through these controlled shutdown steps:
- Notify every known consumer.
- Disable new event production.
- Drain queues and dead letters.
- Reconcile final business states.
- Archive required audit evidence.
- Revoke secrets and webhook subscriptions.
- Remove obsolete alerts and dashboards.
Validate authorization at every boundary

Authentication identifies a caller, but authorization decides what that caller may do. Enforce permission checks on every protected resource and action.
Avoid trusting roles, tenant identifiers, prices, or ownership values supplied only by the client. Resolve sensitive context from verified server-side records.
Validate authorization through these server-side controls:
- Verify the caller’s identity.
- Resolve the tenant server-side.
- Check resource ownership.
- Authorize the requested action.
- Limit returned fields.
- Record denied sensitive attempts.
- Test cross-tenant access failures.
Use least-privilege credentials for each integration. Separate read, write, administration, and webhook verification capabilities when the provider supports distinct scopes.
Review authorization after endpoint, role, tenant, or data-model changes. A technically successful request can still expose the wrong customer’s information.
Retire an integration without leaving hidden dependencies
Decommissioning requires more than disabling credentials. Identify producers, consumers, scheduled jobs, dashboards, alerts, stored mappings, support procedures, and contractual retention duties.
Freeze new work, drain or reconcile pending operations, and confirm which system owns the final business state before removing access.
Expose hidden dependencies through this retirement sequence:
- Notify owners and document the retirement window.
- Stop new events and scheduled synchronization safely.
- Drain queues, retries, and dead-letter records.
- Reconcile final records across authoritative systems.
- Archive required evidence under approved retention rules.
- Revoke secrets, webhooks, users, and network access.
Remove obsolete alerts and dashboards only after owners confirm no dependent workflow remains. Keep the recovery decision and final evidence accessible.
A structured retirement prevents abandoned credentials, misleading monitoring, and future teams rebuilding against a system that no longer owns current data.
Set a supportability gate before launch
An integration is not ready when only its developer understands failures. Support and operations need visible status, safe diagnostic steps, and clear escalation boundaries.
Define what first-line support can inspect without exposing secrets or changing data. Reserve replay, credential rotation, and manual reconciliation for trained owners.
Gate launch through these supportability requirements:
- Publish dashboards for workflow state and queue age.
- Document common errors and their safe diagnostic evidence.
- Name owners for provider, application, and business failures.
- Restrict replay and reconciliation to authorized roles.
- Test alerts with the people expected to respond.
- Confirm after-hours escalation for critical workflows.
Run a tabletop exercise using a delayed webhook, expired credential, and duplicate write. Confirm each participant can find evidence and choose the next safe action.
Record gaps as release work, not future documentation debt. Unsupported recovery paths increase customer impact even when the API code itself is correct.
Estimate integration cost beyond initial development

Budget for provider changes, monitoring, incident response, reconciliation, security reviews, and customer support. Initial build effort is only one part of ownership.
A lower-cost connector can become expensive when it hides failures, lacks exportable state, or prevents teams from diagnosing duplicated and missing records.
Estimate total integration cost through these components:
- Estimate expected requests, events, storage, and support volume.
- Include sandbox, premium API, and usage-tier costs.
- Account for monitoring, queues, logs, and retention.
- Reserve capacity for provider migrations and deprecations.
- Measure manual reconciliation and exception handling time.
- Review cost when volume or workflow criticality changes.
Tie cost to business outcomes and failure exposure. A critical revenue workflow may justify more redundancy than a low-frequency internal enrichment task.
Keep estimates versioned with architecture decisions. This lets teams revisit assumptions when pricing, traffic, staffing, or provider behavior changes.
Treat bulk backfills as controlled migrations
A backfill can overwhelm provider limits, amplify mapping errors, and trigger downstream automation. Separate it from ordinary real-time traffic and use explicit checkpoints.
Start with representative records, including missing fields, merged identities, historical formats, and rejected states. Compare destination results before increasing volume.
Control bulk backfills through these migration stages:
- Freeze the reviewed mapping and transformation version.
- Run a small dry run with reversible records.
- Capture accepted, rejected, skipped, and ambiguous counts.
- Throttle work below tested provider and queue capacity.
- Checkpoint progress using stable source identifiers.
- Reconcile totals and samples before each expansion.
Pause when rejection patterns or business totals diverge from expectations. Fix the cause before replaying the same population.
After completion, preserve the mapping version, run summary, exceptions, and reconciliation evidence. Remove temporary credentials and elevated limits that are no longer required.
Revisit the ownership forecast
Compare estimates with observed support and reconciliation work after launch. Update assumptions when provider pricing, traffic, or workflow criticality changes.
Include retirement work so credentials, queues, dashboards, and retained data do not become unmanaged liabilities after a provider or workflow changes.
Update the ownership forecast
Measure the support and recovery effort required after launch.
Update forecasts after material changes in pricing, volume, or workflow criticality.
Govern Integration Ownership and Change

Every production integration needs named technical and business owners. Ownership covers contract decisions, provider communication, monitoring, recovery, and retirement.
Record who approves schema changes, credential scope, replay, manual reconciliation, and customer communication. Shared responsibility without named decisions creates delayed incidents.
Maintain a reviewed integration register
Keep one current record for each integration, including purpose, systems, environments, owners, credentials, data classes, dependencies, and support expectations.
Link the record to the contract, dashboards, runbooks, provider notices, and retirement plan. Review it after every material workflow or ownership change.
Maintain the integration register through these records:
- Name technical and business owners.
- Record provider and internal dependencies.
- Link contracts, dashboards, and runbooks.
- Track credential and webhook ownership.
- Review deprecations and migration dates.
- Document recovery and retirement decisions.
Control changes through evidence
Classify proposed changes as compatible, conditionally compatible, or breaking. Confirm affected consumers before changing fields, permissions, timing, or error behavior.
Use a versioned decision record for risky changes. Include the reason, alternatives, test evidence, rollout sequence, rollback boundary, and accountable approver.
Control risky changes through this evidence package:
- Inventory affected consumers and workflows.
- Test normal and failure behavior.
- Release to a bounded cohort.
- Monitor business and technical signals.
- Keep rollback conditions explicit.
- Notify support before broad rollout.
Provider notices need the same discipline. Translate each announcement into affected contracts, dates, owners, tests, and customer consequences instead of forwarding it without action.
Review governance during incidents and quarterly maintenance. Remove obsolete dependencies, refresh escalation paths, and confirm that retained access still matches current responsibilities.
Verify governance through operating evidence
Sample recent incidents, changes, and provider notices to confirm that named owners made timely decisions with traceable evidence.
Turn missing approvals, stale runbooks, and unowned dependencies into scheduled work with accountable completion dates.
Close governance gaps
Sample recent incidents, changes, approvals, and provider notices.
Schedule every governance gap with an owner and completion date.
FAQ
These answers address common decisions about contracts, delivery, recovery, testing, ownership, and provider change in custom API integrations.
When should a company build a custom API?
Build one when a real consumer needs a stable, permissioned interface. First check whether a supported provider integration, export, or message pattern meets the workflow.
Name the consumer, owner, data, and operating commitment first.
Should we use REST or GraphQL for a business integration?
Choose the style that fits the consumer’s data needs, team expertise, caching model, and operational constraints.
REST with clear resources is often straightforward for stable business workflows.
How do we prevent duplicate orders after a timeout?
Create one idempotency key for the logical order attempt. Link it to the internal order and reuse it for retries of the unchanged request.
Confirm the provider’s key scope, parameter-matching behavior, and retention.
What is the difference between a webhook and polling?
Polling asks a provider for updates on a schedule; a webhook sends a notification when an event occurs.
Polling is simpler but can be delayed and generate requests that return no changes.
Should a webhook handler do all processing before responding?
Usually not.
Verify the request, store the event durably, and acknowledge it according to the provider’s contract; then process it asynchronously.
How should API versions be managed?
Prefer compatible additions and avoid removing or redefining fields that consumers already use.
For a breaking change, publish a new major contract and migration examples. Allow a transition window when feasible, and track clients still using the old version.
What should we log for integration troubleshooting?
Log a correlation ID, integration name, operation, timing, outcome category, and retry number.
Include only the minimum non-sensitive context needed to trace a record.
How many retries should an integration use?
There is no universal number.
Use bounded exponential backoff with jitter for failures that can recover, honor provider retry guidance, and define an overall deadline tied to the workflow.
How do we test a third-party integration safely?
Use the provider’s sandbox and test credentials, synthetic data, and controlled endpoints.
Test successful flows and failure paths such as expired credentials, rate limits, timeouts, duplicate webhooks, and partial batches.
What should happen when a provider changes its API?
Track provider notices and API versions, review the change against your contract and consumers, and test it in a sandbox before rollout.
If the change is breaking, implement a migration plan with an owner and date.
Conclusion

Reliable API development begins with a business outcome and a contract that consumers can test. The design must remain understandable after the original developers leave.
Authentication, mapping, retries, events, monitoring, and recovery are connected decisions. Weakness in one boundary can create duplicate work, hidden drift, or unsafe access.
Turn the design into an operating commitment
Before launch, trace one real workflow through normal completion, timeout, provider rejection, delayed event, and partial recovery. Confirm each state is visible.
Give support teams correlation identifiers, dashboards, safe diagnostic steps, and escalation owners. Recovery should not require guessing whether a provider accepted irreversible work.
Commit operations through these support requirements:
- Confirm contract and ownership boundaries.
- Test unknown and partial outcomes.
- Reconcile irreversible business effects.
- Monitor queue age and failure classes.
- Document replay and retirement authority.
- Review provider changes before deadlines.
Keep improvement tied to evidence
Measure business completion, duplicate prevention, recovery time, reconciliation exceptions, and support effort. Request counts alone do not show whether the integration remains useful.
Review these signals with technical and business owners. Update contracts, examples, tests, runbooks, and cost assumptions when workflows or provider behavior changes.
Improve integrations through these evidence signals:
- Use bounded rollouts for material changes.
- Preserve evidence for every recovery decision.
- Retire obsolete access and dependencies.
- Keep consumers informed before breaking changes.
A dependable integration is therefore a maintained product boundary, not a one-time connector. Its quality depends on clear decisions, observable behavior, and accountable ownership.
Treat each unresolved discrepancy as owned work. Document the next safe action instead of allowing silent retries or manual workarounds to become routine.
Resolve every remaining discrepancy
Carry recovery evidence into contract and integration design.
Assign the next contract review before closing the incident.
Apply incident learning
Revisit the contract after material incidents. Evidence from recovery should improve design, tests, observability, and the responsibilities recorded for future operations.
For broader application architecture and launch planning, read our B2B web app development guide.











Leave a Reply