HomeBlogHow to Build a Third-Party API...

Engineering Guide · 9 min read · September 13, 2026

How to Build a Third-Party API Integration Platform

B2B startups hit a growth ceiling when enterprise prospects demand native CRM, ERP, and HRIS integrations. This blueprint covers build-vs-buy economics, normalized connector interfaces, encrypted OAuth token vaults with distributed refresh locks, and per-tenant queue isolation.

Author
Smit Desai
Published
September 13, 2026
Read time
9 min read
Topic
APIs & Integrations
Services
Custom Web · Mobile Apps · All Services

Every B2B startup hits the same inflection point when moving from self-serve plans to mid-market contracts: prospects stop accepting CSV uploads and ask which CRMs, accounting platforms, or ticketing systems you sync with natively.

Building one Salesforce integration as a one-off background job is manageable. Building a multi-tenant third-party API integration platform that supports ten providers across hundreds of customer workspaces is a completely different engineering problem. Every vendor handles pagination differently, rotates OAuth refresh tokens with subtle race conditions, and enforces incompatible rate limits.

If you are planning your SaaS integration layer—or evaluating services to accelerate delivery—this blueprint breaks down the core components that survive production traffic.

Third-Party API Integration Platform Architecture


Build vs. Embedded iPaaS: Checking the Unit Economics

Before writing a connector framework, evaluate whether owning the runtime actually helps your startup.

Dimension Custom Connector Platform Embedded iPaaS Unified API Aggregator
Time to First 3 Connectors 4–8 weeks 1–2 weeks 1 week
Marginal Cost per Tenant Negligible (compute/queue) Scales per tenant or workflow Scales per connected account
Custom Field / Object Depth Unlimited Limited by visual builder Restricted to lowest common model
Rate-Limit & Retry Control Full per-tenant tuning Shared vendor policies Abstracted away
Best Use Case Core product sync engine Peripheral workflow triggers Shallow read-only enrichment

A common hybrid strategy works best for startups: use an aggregator only for secondary categories you do not differentiate on, and build your own connector runtime for the two or three integrations your buyers use every day.


Designing a Normalized Connector Runtime

Separate your control plane (tenant UI, OAuth callbacks, field mappings, sync schedules) from your data plane (stateless workers pulling and pushing records). Every third-party provider implements a single TypeScript contract so orchestration code never branches on vendor names.

export interface SyncCursor {
  cursorToken: string | null;
  updatedSinceIso: string;
}

export interface ConnectorCapabilities {
  supportsWebhooks: boolean;
  supportsDeltaQuery: boolean;
  maxRequestsPerMinute: number;
}

export interface ThirdPartyConnector<TRecord> {
  readonly provider: string;
  readonly capabilities: ConnectorCapabilities;

  pullBatch(
    credentials: DecryptedCredentials,
    cursor: SyncCursor
  ): Promise<{ records: TRecord[]; nextCursor: SyncCursor | null }>;

  pushBatch(
    credentials: DecryptedCredentials,
    records: TRecord[]
  ): Promise<Array<{ localId: string; externalId?: string; error?: string }>>;
}

By forcing cursor pagination and partial-batch error reporting into the interface itself, your orchestrator handles partial CRM failures without dropping an entire batch.


OAuth2 Token Vault and Distributed Refresh Locking

Most SaaS providers now issue rotating single-use refresh tokens. If two sync workers see an expired access token at the same moment and both call POST /oauth/token, the second request fails—and many providers immediately revoke the entire authorization grant, disconnecting your customer.

Encrypted Connection Schema

Store encrypted credentials per tenant connection with an explicit encryption key version so you can rotate keys cleanly:

CREATE TABLE tenant_connections (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    tenant_id UUID NOT NULL,
    provider VARCHAR(32) NOT NULL,
    access_token_enc BYTEA NOT NULL,
    refresh_token_enc BYTEA,
    key_version INT NOT NULL DEFAULT 1,
    expires_at TIMESTAMPTZ NOT NULL,
    status VARCHAR(24) NOT NULL DEFAULT 'active',
    UNIQUE (tenant_id, provider)
);

Mutex Around Token Refresh

Before calling a provider's refresh endpoint, acquire a short-lived Redis lock keyed by oauth_refresh:${connectionId}. When a second worker enters the lock, it re-reads PostgreSQL first; if expires_at is now in the future, it skips the refresh call altogether and uses the fresh token.

export async function getValidAccessToken(connectionId: string): Promise<string> {
  const current = await loadConnection(connectionId);
  if (current.expiresAt.getTime() > Date.now() + 60_000) {
    return decryptToken(current.accessTokenEnc);
  }

  return withRedisLock(`oauth_refresh:${connectionId}`, 10_000, async () => {
    const fresh = await loadConnection(connectionId);
    if (fresh.expiresAt.getTime() > Date.now() + 60_000) {
      return decryptToken(fresh.accessTokenEnc);
    }
    const tokens = await refreshProviderOAuth(fresh);
    await saveEncryptedTokens(connectionId, tokens);
    return tokens.accessToken;
  });
}

That sixty-second buffer prevents mid-flight expirations when network latency pushes an API call close to token expiry.


Per-Tenant Queues and Noisy-Neighbor Isolation

When a new enterprise customer connects a HubSpot instance with 400,000 contacts, your initial historical backfill should never stall incremental five-record webhook updates for smaller tenants.

Three Rules for Queue Isolation

  1. Separate backfill from realtime queues: Give incremental webhooks dedicated worker concurrency while backfills drain on lower-priority workers.
  2. Respect upstream Retry-After headers: When a provider returns HTTP 429, pause that specific tenant_connection_id in Redis until now + retryAfter rather than letting 20 jobs burn through retry attempts.
  3. Cap per-tenant concurrency: Limit any single tenant to a fixed slice of active jobs so one workspace cannot saturate your database connection pool.

For detailed worker and Redis queue tuning, see our post on scaling background jobs and queues, and align your webhook receiver buffering with standard webhook processing patterns.


Schema Mapping, Contracts, and Customer Observability

Startups underestimate how much time support teams spend answering, "Why didn't this invoice sync?" Build observability into the platform schema from week one:

  • Contract-first internal APIs: Publish your normalized webhook and sync APIs using the OpenAPI Specification so frontend dashboards and CLI tools share exact schemas.
  • Per-run sync summaries: Record records_read, records_written, records_failed, and duration_ms for every sync execution.
  • Actionable customer error states: Translate raw HTTP 403 or field-validation errors into human-readable remediation messages ("Missing tax code mapping on line item") with a single-click retry button.

Building Your Integration Layer with SmitDev

At SmitDev, we help founders and engineering leaders ship multi-tenant integration platforms without burning two quarters on trial-and-error infrastructure. Across 170+ shipped case studies globally, we have built custom connector frameworks, billing bridges, and high-throughput webhook pipelines for SaaS teams in the US, UK, Europe, UAE, Australia, and Singapore.

Whether you want to hire a dedicated developer at $55/day (8–9 hours of daily engineering) or lock in predictable velocity on our $1,999/month dedicated delivery model, we build clean, maintainable connector platforms you fully own.

Planning an integration platform for your SaaS roadmap? Start a technical scoping conversation with Smit.

Written by Smit Desai · Principal Full-Stack & FDSE

8+ years shipping production systems · 171 case studies · 300+ WordPress servers managed for Finland partners.

Next Steps and Recommended Resources

Next Steps · Recommended Resources

Pillar 1 · Custom Web & SaaS

Custom Web Application Development

Production Laravel, Next.js, API, and multi-tenant SaaS systems engineered end to end at $55/day (8–9 hrs) or $1,999/mo.

Comparison · Buyer Guide

SmitDev vs Software Agencies

See side-by-side economics, senior code ownership, and onboarding speed vs traditional dev shops and marketplaces.

01 — Frequently asked questions

apis & integrations

Should an early-stage startup build an integration platform from scratch or buy an embedded iPaaS?

If integrations are secondary features like Slack notifications, buy an embedded iPaaS to ship faster. If deep, high-volume bidirectional sync with custom customer objects is central to your product value, build a thin internal connector runtime so you own margins and reliability.

How do you avoid invalidating single-use OAuth refresh tokens under concurrent API calls?

Wrap token refresh inside a distributed Redis mutex keyed by tenant_connection_id. Only one worker calls the provider's token endpoint, writes the new encrypted refresh token to PostgreSQL, and lets waiting workers read the updated token.

How do you prevent one large enterprise tenant from starving other customers' sync jobs?

Avoid a single global FIFO queue. Partition queues by tenant tier or use fair-scheduling round-robin workers so a 500,000-record initial backfill does not delay lightweight incremental webhooks for other customers.

How should a multi-tenant integration platform handle custom CRM fields per customer?

Keep core canonical fields strictly typed, store tenant-specific field mapping rules as JSONB configuration, and attach an unmapped raw_metadata column or selective pass-through map validated at sync time.

03 — Have an engineering need?

hire the right expertise

Let's talk tech.

Deciding between an embedded forward deployed engineer or a senior full stack developer? Share your technical context and timeline.

Solitaire Corporate Park, Makarba, Ahmedabad, Gujarat 380015, India · IST (UTC+5:30) · --:-- IST · Mon–Fri 09:00–18:00 IST · US & EU overlap daily

No newsletter, no CRM. Just a reply.