What is an API contract?
Every consumer of your API — a frontend, a partner, a microservice — depends on the precise shape of your responses: user.id is an integer, created_at is ISO-8601, items is always an array. That implicit agreement is the contract. Nobody signs it, everybody relies on it.
What is schema drift?
Drift is the contract changing without anyone deciding it should. A refactor renames userName to username. An ORM upgrade turns an integer into a string. A "harmless" cleanup drops a field only one consumer used. Your functional tests pass — the endpoint still returns 200 with plausible JSON — and three days later a partner integration is down and the postmortem says "no code change on their side."
Contract testing vs integration testing
| Contract testing | End-to-end integration testing | |
|---|---|---|
| What runs | Schema validation against each service in isolation | All services deployed together |
| Speed | Milliseconds per check | Minutes; flaky environments |
| Failure signal | "Field X changed type on endpoint Y" | "Checkout flow failed somewhere" |
| When it catches drift | At build time, before merge | Often after deploy — or in production |
They're complements, not rivals — but if you have neither, contracts give far more protection per minute invested.
How to adopt contract testing
- Capture the current shape of each endpoint's responses — this becomes the baseline contract.
- Validate every build against it. Any type change, missing field or new required parameter fails the build.
- Make changes explicit. When a change is intentional, update the contract in the same change set — now it's a reviewed decision, not drift.
- Version deliberately. Additive changes are usually safe; breaking changes get a new version and a deprecation window.
Contract testing with Flasqo
Flasqo's contract module learns your response schemas and verifies every run against them, flagging drift down to the field level — alongside the functional, load and chaos suites in the same dashboard. Free to use: set up your first contract check.