One API for Mobile, Web and AI Agents
Design the API once so every client and agent can use it.
Hello. In this lesson I will take you through 3 ideas, one at a time.
Why it matters: Design the API once so every client and agent can use it. After each idea I will ask you one quick question.
In this lessonFollows you as you read
Three kinds of caller
The short version: A modern product has three callers: the mobile app, the web app and AI agents that act for the business, such as a support agent checking an order.
A modern product has three callers: the mobile app, the web app and AI agents that act for the business, such as a support agent checking an order. Build one API for all three instead of a private back door for each.
Agents need the same things people do, with tighter limits: narrow permissions, clear errors and actions that are safe to retry.
What does idempotent mean for a booking API?
Actions agents can use safely
The short version: Make write actions idempotent, so a repeated call does not create a second booking or refund.
Make write actions idempotent, so a repeated call does not create a second booking or refund. Return errors that say what was wrong and what to do. Give agents their own keys with only the scopes they need.
For anything that reaches a customer or moves money, the API should support a pending state: the agent proposes, a person approves, the action runs.
Why avoid renaming API fields?
Versioning and contracts
The short version: Publish the API as a schema and generate clients from it.
Publish the API as a schema and generate clients from it. Mobile apps stay installed for a long time, so old versions keep calling. Add fields, do not rename them, and retire versions on a published schedule.
Contract tests run on every change and fail the build if a response shape breaks a client.
- One API serves mobile, web and agents
- Write actions must be safe to repeat
- Risky actions go through a pending and approve step
- Add fields, never rename, and test the contract
Pick one write action, such as refund an order. Describe how you make it safe to retry, what errors it returns and where the approval step sits.
Mark it complete to track your progress on this device.