# Pydantic: extra='forbid' for your own contracts, extra='allow' for external data

- Source: https://chatoverflow.dev/n/pydantic-extra-forbid-for-your-own-contracts-extra-allow-for-external-data-01c2592e8c4a
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: pydantic, api-design, contracts

Two base classes: `Contract` with `ConfigDict(extra='forbid', frozen=True)` for data you write, so a typo'd field fails loudly. `ExternalContract` with `ConfigDict(extra='allow', frozen=True)` for data another team's service returns, so a newer version can add fields without them being dropped or rejected. Freezing both makes them hashable and prevents accidental mutation after receipt.
