LearnThatStack Ace your next interview
API Design · question
Question 70 of 92

How do you design APIs for third-party integrations?

expert
← All API Design questions
Re-explain
Visual ↓

Treat the API as a product other companies build on, so stability and developer experience matter as much as features. Partners can't redeploy on your schedule, so a breaking change costs far more than in an internal API.

  1. Put developer experience first. Give partners clear documentation and an interactive API explorer. Add SDKs in popular languages and a sandbox environment.
  2. Pick an access model. Public APIs are open to all developers, partner APIs have restricted access, and private APIs are for internal use.
  3. Make onboarding self-service. Partners register and manage their own API keys. They pick a usage tier with billing, and know which support channels to use.

Offer the integration patterns partners expect. Webhook notifications and polling endpoints cover most needs. Add real-time APIs over WebSockets for live data and batch processing APIs for bulk work. Partners subscribe to webhook events through an endpoint like this one.

POST /partners/webhooks
Authorization: Bearer partner_token
{
  "url": "https://partner.com/webhook",
  "events": ["order.created", "order.updated"],
  "secret": "webhook_secret"
}
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

The diagram below the answer is the concept . Jump to it ↓

Tailored explanation · switch back to · ·
What should the new diagram focus on?
Guided practice for API Design One question at a time. Answer out loud, get graded, see what you missed.
Related concept

Documentation: the docs come from the spec, not a hand-written copy

Hand-written docs are a second copy of what the code does, and copies go out of date. A spec that generates the reference, clients and checks cannot go out of date.

For this question · chapters 2 and 3 of 3This answer puts developer experience first for partners. Watch a mock server reply from the spec before your endpoint exists. Then watch a partner make a first working call with a self-service key and a sandbox, plus an example that runs and a clear error.

2/3 One spec, many outputs
openapiOne spec, many outputswritten once, generated five timesgenerated5of 5outputs by hand0of 5a person writes4one fileopenapi.yamlthe only copy14 paths9 schemas22 examples11 errorsdesign firstwrite the file firstgenerate the handlerscode firstannotate the handlersemit the file from themgeneratedthe referenceevery path and fieldgenerated, never typedgeneratedclient SDKsfour languagesnone of them by handgenerateda mock serveranswers the examplesbefore you build itgeneratedrequest validationthe schema, at the edgerefuses what it forbidsgeneratedcontract testsCI compares the answersa dropped field failswhat a person still writesnothing below generates thesewhy you would call itthe auth guidewhat to do about each errormigration notesgeneration removes the drift. it does not write the explanation
openapiOne spec, many outputsgenerated5of 5outputs by hand0of 5one fileopenapi.yamlthe only copy14 paths9 schemas22 examples11 errorswritten first, or read out of the codegeneratedthe referenceevery path and fieldgeneratedclient SDKsfour languagesgenerateda mock serveranswers the examplesgeneratedrequest validationthe schema, at the edgegeneratedcontract testsCI compares the answerswhat a person still writes4why you would call itthe auth guidewhat to do about each errormigration notesgeneration cannot write the reasons

One spec, many outputs

  1. There are two ways to get one OpenAPI file. Write the file first and generate the handlers from it, or annotate the handlers and generate the file from them. Both ways produce the same file: 14 paths and 9 schemas, with 22 examples and 11 error codes. Five outputs could come from that file, but today a person types every one of them.
  2. The reference page is now an output of the spec file, so nobody types the page any more. Every path, field and example on the page comes from that file, so the page always matches the code. The difference from chapter one is in how the page is built. The page does not depend on anyone remembering to update it.
  3. In chapter one, a renamed field broke the partner's integration. Here the same spec file generates client libraries in four languages. Nobody writes those libraries by hand. So a field renamed in the spec changes in all four libraries on the next release. A build step now handles the exact change that broke the partner's integration.
  4. The examples in the spec file are enough for a mock server to answer requests. The mock server replies before the real endpoint exists. So your partner waits zero days and starts building on day one. The examples in a spec are also worth writing properly, because a server is going to return them.
  5. At the edge, the schema refuses any request with a field the schema does not define. The schema returns a 400 that names that field. So the spec file has a new role: the document that describes the API now enforces the API. A document you can run cannot be wrong without anyone noticing.
  6. Drift, where the code no longer matches the spec, now fails the build. In CI, contract tests use the spec file as the test fixture and check every response against the matching schema. So a handler that drops a field fails the build. Chapter one's bug would have failed the build on your machine the day the bug shipped, not nine days later in a stranger's ticket.
  7. Generation from the spec stops here, and this is the honest half of the answer. People write why to call this endpoint and how auth works end to end. They also write what to do about each error, and migration notes for a breaking change. An integrator reads these four documents first. Generation removes drift, but it does not write the explanation.
Chapter 2 · step 1 of 7

There are two ways to get one OpenAPI file. Write the file first and generate the handlers from it, or annotate the handlers and generate the file from them. Both ways produce the same file: 14 paths and 9 schemas, with 22 examples and 11 error codes. Five outputs could come from that file, but today a person types every one of them.

1 of 7 Use ← → or swipe See the concept: all 3 chapters in it

© LearnThatStack - diagrams may not be republished without permission.

How well did you know this?
AI:

Saved in this browser - sign in to keep your review list.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Interview lens How interviewers actually use this question

Likely follow-ups

What you can say

  1. I treat a third-party API as a product other companies build on, and because partners can't redeploy on my schedule, stability and developer experience matter as much as features.
  2. So developer experience comes first, with clear docs, an interactive API explorer, SDKs in the popular languages, and a sandbox where partners can test safely.
  3. I decide early whether the API is public, partner-only, or private, and I make onboarding self-service so partners manage their own keys, pick a usage tier, and know where to get support.
  4. For integration patterns, webhooks and polling cover most needs, and I add WebSockets for live data and batch APIs for bulk work.
  5. Partners subscribe to webhooks with a POST that sets their callback URL, the events they want like order.created, and a shared secret for checking each delivery.
  6. The cost is that every endpoint and event I publish becomes a promise I have to keep, so I'd rather launch a smaller API and grow it than remove things later.

Weak answers to avoid

  • Designs it like an internal API Naming resources and verbs isn't the point. Partners are outside developers, so talk about stability, docs, SDKs, a sandbox, and self-service onboarding.
  • Treats breaking changes as cheap Partners ship on their own schedule, so a break can take their product down. Say how you avoid breaks, and how you version and give notice when you can't.
  • Webhooks with no secret or retries Without a signing secret partners can't tell your calls from forged ones, and without retries a missed event is gone. Name both.
  • Hand-issued keys, no access model Emailing keys by hand doesn't scale past a few partners. Say whether the API is public, partner-only, or private, and how partners get their own keys and pick a tier.
Interview lens

Likely follow-ups, what you can say, and the weak answers to avoid.

Sign in free to open it Free account - the lens opens as soon as you're back.

Want a quick review of the fundamentals? See the API Design cheatsheet.

← Back to all API Design questions
Pro · $10/mo

74 of 92 API Design answers are in Pro.

Full answers, code samples, and AI explanations that go simpler or deeper. Cancel anytime.

  • Full answers + code
  • AI explanations, simpler or deeper
  • 1,000 AI credits / month
  • Cancel anytime